ES6: Allow duplicate property names
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 14 May 2015 01:32:25 +0000 (01:32 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 14 May 2015 01:32:25 +0000 (01:32 +0000)
commit9fe7ea11a6dbc5dfb3b279bfbe1eceb09dccec87
tree620d389a2f9ec64d31134aadceaa14fd0edb7330
parent6d7d286ad0c7fb0e287222e6b45794979b51c5f5
ES6: Allow duplicate property names
https://bugs.webkit.org/show_bug.cgi?id=142895

Patch by Joseph Pecoraro <pecoraro@apple.com> on 2015-05-13
Reviewed by Geoffrey Garen.

Source/JavaScriptCore:

Introduce new `op_put_getter_by_id` and `op_put_setter_by_id` opcodes
that will define a single getter or setter property on an object.

The existing `op_put_getter_setter` opcode is still preferred for
putting both a getter and setter at the same time but cannot be used
for putting an individual getter or setter which is needed in
some cases.

Add a new slow path when generating bytecodes for a property list
with computed properties, as computed properties are the only time
the list of properties cannot be determined statically.

* bytecompiler/NodesCodegen.cpp:
(JSC::PropertyListNode::emitBytecode):
- fast path for all constant properties
- slow but paired getter/setter path if there are no computed properties
- slow path, individual put operation for every property, if there are computed properties

* parser/Nodes.h:
Distinguish a Computed property from a Constant property.

* parser/Parser.cpp:
(JSC::Parser<LexerType>::parseProperty):
(JSC::Parser<LexerType>::parsePropertyMethod):
Distingish Computed and Constant properties.

(JSC::Parser<LexerType>::parseObjectLiteral):
When we drop into strict mode it is because we saw a getter
or setter, so be more explicit.

(JSC::Parser<LexerType>::parseStrictObjectLiteral):
Eliminate duplicate property syntax error exception.

* parser/SyntaxChecker.h:
(JSC::SyntaxChecker::getName):
* parser/ASTBuilder.h:
(JSC::ASTBuilder::getName): Deleted.
No longer used.

* runtime/JSObject.h:
(JSC::JSObject::putDirectInternal):
When updating a property. If the Accessor attribute changed
update the Structure.

* runtime/JSObject.cpp:
(JSC::JSObject::putGetter):
(JSC::JSObject::putSetter):
Called by the opcodes, just perform the same operation that
__defineGetter__ or __defineSetter__ would do.

(JSC::JSObject::putDirectNonIndexAccessor):
This transition is now handled in putDirectInternal.

* runtime/Structure.h:
Add needed export.

* bytecode/BytecodeList.json:
* bytecode/BytecodeUseDef.h:
(JSC::computeUsesForBytecodeOffset):
(JSC::computeDefsForBytecodeOffset):
* bytecode/CodeBlock.cpp:
(JSC::CodeBlock::dumpBytecode):
* bytecompiler/BytecodeGenerator.cpp:
(JSC::BytecodeGenerator::emitPutGetterById):
(JSC::BytecodeGenerator::emitPutSetterById):
* bytecompiler/BytecodeGenerator.h:
* jit/JIT.cpp:
(JSC::JIT::privateCompileMainPass):
* jit/JIT.h:
* jit/JITInlines.h:
(JSC::JIT::callOperation):
* jit/JITOperations.cpp:
* jit/JITOperations.h:
* jit/JITPropertyAccess.cpp:
(JSC::JIT::emit_op_put_getter_by_id):
(JSC::JIT::emit_op_put_setter_by_id):
* jit/JITPropertyAccess32_64.cpp:
(JSC::JIT::emit_op_put_getter_by_id):
(JSC::JIT::emit_op_put_setter_by_id):
* llint/LLIntSlowPaths.cpp:
(JSC::LLInt::LLINT_SLOW_PATH_DECL):
* llint/LLIntSlowPaths.h:
* llint/LowLevelInterpreter.asm:
New bytecodes. Modelled after existing op_put_getter_setter.

LayoutTests:

* js/object-literal-duplicate-properties-expected.txt: Added.
* js/object-literal-duplicate-properties.html: Added.
* js/script-tests/object-literal-duplicate-properties.js: Added.
Include a new test all about testing duplicate property names
and their expected cascading results.

* ietestcenter/Javascript/11.1.5_4-4-b-1-expected.txt:
* ietestcenter/Javascript/11.1.5_4-4-b-2-expected.txt:
* ietestcenter/Javascript/11.1.5_4-4-c-1-expected.txt:
* ietestcenter/Javascript/11.1.5_4-4-c-2-expected.txt:
* ietestcenter/Javascript/11.1.5_4-4-d-1-expected.txt:
* ietestcenter/Javascript/11.1.5_4-4-d-2-expected.txt:
* ietestcenter/Javascript/11.1.5_4-4-d-3-expected.txt:
* ietestcenter/Javascript/11.1.5_4-4-d-4-expected.txt:
ES5 behavior for duplciate properties has changed.

* js/mozilla/strict/11.1.5-expected.txt:
* js/object-literal-syntax-expected.txt:
* js/script-tests/object-literal-syntax.js:
Update other tests and values now that duplicate properties
are allowed, and their cascade order behaves correctly.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@184324 268f45cc-cd09-0410-ab3c-d52691b4dbfc
40 files changed:
LayoutTests/ChangeLog
LayoutTests/ietestcenter/Javascript/11.1.5_4-4-b-1-expected.txt
LayoutTests/ietestcenter/Javascript/11.1.5_4-4-b-2-expected.txt
LayoutTests/ietestcenter/Javascript/11.1.5_4-4-c-1-expected.txt
LayoutTests/ietestcenter/Javascript/11.1.5_4-4-c-2-expected.txt
LayoutTests/ietestcenter/Javascript/11.1.5_4-4-d-1-expected.txt
LayoutTests/ietestcenter/Javascript/11.1.5_4-4-d-2-expected.txt
LayoutTests/ietestcenter/Javascript/11.1.5_4-4-d-3-expected.txt
LayoutTests/ietestcenter/Javascript/11.1.5_4-4-d-4-expected.txt
LayoutTests/js/mozilla/strict/11.1.5-expected.txt
LayoutTests/js/object-literal-duplicate-properties-expected.txt [new file with mode: 0644]
LayoutTests/js/object-literal-duplicate-properties.html [new file with mode: 0644]
LayoutTests/js/object-literal-syntax-expected.txt
LayoutTests/js/script-tests/object-literal-duplicate-properties.js [new file with mode: 0644]
LayoutTests/js/script-tests/object-literal-syntax.js
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/bytecode/BytecodeList.json
Source/JavaScriptCore/bytecode/BytecodeUseDef.h
Source/JavaScriptCore/bytecode/CodeBlock.cpp
Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h
Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp
Source/JavaScriptCore/jit/CCallHelpers.h
Source/JavaScriptCore/jit/JIT.cpp
Source/JavaScriptCore/jit/JIT.h
Source/JavaScriptCore/jit/JITInlines.h
Source/JavaScriptCore/jit/JITOperations.cpp
Source/JavaScriptCore/jit/JITOperations.h
Source/JavaScriptCore/jit/JITPropertyAccess.cpp
Source/JavaScriptCore/jit/JITPropertyAccess32_64.cpp
Source/JavaScriptCore/llint/LLIntSlowPaths.cpp
Source/JavaScriptCore/llint/LLIntSlowPaths.h
Source/JavaScriptCore/llint/LowLevelInterpreter.asm
Source/JavaScriptCore/parser/ASTBuilder.h
Source/JavaScriptCore/parser/Nodes.h
Source/JavaScriptCore/parser/Parser.cpp
Source/JavaScriptCore/parser/SyntaxChecker.h
Source/JavaScriptCore/runtime/JSObject.cpp
Source/JavaScriptCore/runtime/JSObject.h
Source/JavaScriptCore/runtime/Structure.h