Changeset 206082 in webkit
- Timestamp:
- Sep 18, 2016 10:40:11 AM (8 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JSTests/ChangeLog
r206065 r206082 1 2016-09-18 Yusuke Suzuki <utatane.tea@gmail.com> 2 3 [JSC] Do not need to use defineProperty to define methods for object literals 4 https://bugs.webkit.org/show_bug.cgi?id=162111 5 6 Reviewed by Saam Barati. 7 8 * stress/object-literal-methods.js: Added. 9 (shouldBe): 10 (throw.new.Error.let.object.get name): 11 (throw.new.Error): 12 (shouldBe.let.object.get name): 13 (shouldBe.let.object.get prototype): 14 (shouldBe.let.object.get 42): 15 1 16 2016-09-16 Yusuke Suzuki <utatane.tea@gmail.com> 2 17 -
trunk/Source/JavaScriptCore/ChangeLog
r206065 r206082 1 2016-09-18 Yusuke Suzuki <utatane.tea@gmail.com> 2 3 [JSC] Do not need to use defineProperty to define methods for object literals 4 https://bugs.webkit.org/show_bug.cgi?id=162111 5 6 Reviewed by Saam Barati. 7 8 When we receive the following code, 9 10 var object = { method() { } }; 11 12 currently, we use defineProperty to define "method" function for "object". 13 This patch replaces it with the ordinary put_by_id_direct / put_by_val_direct 14 because the following 2 conditions are met. 15 16 1. While methods in classes have special attributes ({configurable: true, writable: true, enumerable: false}), 17 the attributes of methods in object literals is just the same to the other normal properties ({configurable: true, writable: true, enumerable: true}). 18 This means that we can use the usual put_by_id_direct / put_by_val_direct to define method properties for object literals. 19 20 2. Furthermore, all the own properties that can reside in objects created by object literals have {configurable: true}. 21 So there is no need to check conflict by defineProperty. Always overwriting is OK. 22 23 let name = 'method'; 24 var object = { get [name]() { }, method() { } }; 25 // Latter method wins. 26 27 On the other hand, in class syntax, conflict check is necessary since "prototype" own property is defined as {configurable: false}. 28 29 class Hello { static prototype() { } } // Should throw error by defineProperty's check. 30 31 This means that conflict check done in defneProperty is not necessary for object literals' properties. 32 33 * bytecompiler/NodesCodegen.cpp: 34 (JSC::PropertyListNode::emitPutConstantProperty): 35 1 36 2016-09-16 Yusuke Suzuki <utatane.tea@gmail.com> 2 37 -
trunk/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp
r206065 r206082 588 588 { 589 589 RefPtr<RegisterID> value = generator.emitNode(node.m_assign); 590 if (node.needsSuperBinding()) {590 if (node.needsSuperBinding()) 591 591 emitPutHomeObject(generator, value.get(), newObj); 592 592 593 if (node.isClassProperty()) { 594 ASSERT(node.needsSuperBinding()); 593 595 RefPtr<RegisterID> propertyNameRegister; 594 596 if (node.name()) … … 597 599 propertyNameRegister = generator.emitNode(node.m_expression); 598 600 599 unsigned attributes = BytecodeGenerator::PropertyConfigurable | BytecodeGenerator::PropertyWritable;600 if (!node.isClassProperty())601 attributes |= BytecodeGenerator::PropertyEnumerable;602 601 generator.emitSetFunctionNameIfNeeded(node.m_assign, value.get(), propertyNameRegister.get()); 603 generator.emitCallDefineProperty(newObj, propertyNameRegister.get(), 604 value.get(), nullptr, nullptr, attributes, m_position); 602 generator.emitCallDefineProperty(newObj, propertyNameRegister.get(), value.get(), nullptr, nullptr, BytecodeGenerator::PropertyConfigurable | BytecodeGenerator::PropertyWritable, m_position); 605 603 return; 606 604 }
Note: See TracChangeset
for help on using the changeset viewer.