Changeset 33326
- Timestamp:
- 05/12/08 23:03:27 (6 months ago)
- Location:
- branches/squirrelfish/JavaScriptCore
- Files:
-
- 6 modified
-
ChangeLog (modified) (1 diff)
-
VM/CodeGenerator.cpp (modified) (1 diff)
-
VM/CodeGenerator.h (modified) (1 diff)
-
VM/Machine.cpp (modified) (1 diff)
-
VM/Opcode.h (modified) (1 diff)
-
kjs/nodes.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/squirrelfish/JavaScriptCore/ChangeLog
r33325 r33326 1 2008-05-03 Oliver Hunt <oliver@apple.com> 2 3 Reviewed by Maciej. 4 5 Bug 18864: SquirrelFish: Support getter and setter definition in object literals 6 <https://bugs.webkit.org/show_bug.cgi?id=18864> 7 8 Add new opcodes to allow us to add getters and setters to an object. These are 9 only used by the codegen for object literals. 10 11 * VM/CodeGenerator.cpp: 12 (KJS::CodeGenerator::emitPutGetter): 13 (KJS::CodeGenerator::emitPutSetter): 14 * VM/CodeGenerator.h: 15 * VM/Machine.cpp: 16 (KJS::Machine::privateExecute): 17 * VM/Opcode.h: 18 * kjs/nodes.cpp: 19 (KJS::PropertyListNode::emitCode): 20 1 21 2008-05-02 Maciej Stachowiak <mjs@apple.com> 2 22 -
branches/squirrelfish/JavaScriptCore/VM/CodeGenerator.cpp
r33314 r33326 752 752 } 753 753 754 RegisterID* CodeGenerator::emitPutGetter(RegisterID* base, const Identifier& property, RegisterID* value) 755 { 756 instructions().append(machine().getOpcode(op_put_getter)); 757 instructions().append(base->index()); 758 instructions().append(addConstant(property)); 759 instructions().append(value->index()); 760 return value; 761 } 762 763 RegisterID* CodeGenerator::emitPutSetter(RegisterID* base, const Identifier& property, RegisterID* value) 764 { 765 instructions().append(machine().getOpcode(op_put_setter)); 766 instructions().append(base->index()); 767 instructions().append(addConstant(property)); 768 instructions().append(value->index()); 769 return value; 770 } 771 754 772 RegisterID* CodeGenerator::emitDeletePropId(RegisterID* dst, RegisterID* base, const Identifier& property) 755 773 { -
branches/squirrelfish/JavaScriptCore/VM/CodeGenerator.h
r33305 r33326 202 202 RegisterID* emitDeletePropVal(RegisterID* dst, RegisterID* base, RegisterID* property); 203 203 RegisterID* emitPutPropIndex(RegisterID* base, unsigned index, RegisterID* value); 204 RegisterID* emitPutGetter(RegisterID* base, const Identifier& property, RegisterID* value); 205 RegisterID* emitPutSetter(RegisterID* base, const Identifier& property, RegisterID* value); 204 206 205 207 RegisterID* emitCall(RegisterID*, RegisterID*, RegisterID*, ArgumentsNode*); -
branches/squirrelfish/JavaScriptCore/VM/Machine.cpp
r33324 r33326 1709 1709 return r[r0].u.jsValue; 1710 1710 } 1711 BEGIN_OPCODE(op_put_getter) { 1712 /* put_getter base(r) property(id) function(r) 1713 1714 Sets register function on register base as the getter named 1715 by identifier property. Base and function are assumed to be 1716 objects as this op should only be used for getters defined 1717 in object literal form. 1718 1719 Unlike many opcodes, this one does not write any output to 1720 the register file. 1721 */ 1722 1723 int base = (++vPC)->u.operand; 1724 int property = (++vPC)->u.operand; 1725 int function = (++vPC)->u.operand; 1726 1727 ASSERT(r[base].u.jsValue->isObject()); 1728 JSObject* baseObj = static_cast<JSObject*>(r[base].u.jsValue); 1729 Identifier& ident = codeBlock->identifiers[property]; 1730 ASSERT(r[function].u.jsValue->isObject()); 1731 baseObj->defineGetter(exec, ident, static_cast<JSObject* >(r[function].u.jsValue)); 1732 1733 ++vPC; 1734 NEXT_OPCODE; 1735 } 1736 BEGIN_OPCODE(op_put_setter) { 1737 /* put_setter base(r) property(id) function(r) 1738 1739 Sets register function on register base as the setter named 1740 by identifier property. Base and function are assumed to be 1741 objects as this op should only be used for setters defined 1742 in object literal form. 1743 1744 Unlike many opcodes, this one does not write any output to 1745 the register file. 1746 */ 1747 1748 int base = (++vPC)->u.operand; 1749 int property = (++vPC)->u.operand; 1750 int function = (++vPC)->u.operand; 1751 1752 ASSERT(r[base].u.jsValue->isObject()); 1753 JSObject* baseObj = static_cast<JSObject*>(r[base].u.jsValue); 1754 Identifier& ident = codeBlock->identifiers[property]; 1755 ASSERT(r[function].u.jsValue->isObject()); 1756 baseObj->defineSetter(exec, ident, static_cast<JSObject* >(r[function].u.jsValue)); 1757 1758 ++vPC; 1759 NEXT_OPCODE; 1760 } 1711 1761 BEGIN_OPCODE(op_jsr) { 1712 1762 /* jsr retAddrDst(r) target(offset) -
branches/squirrelfish/JavaScriptCore/VM/Opcode.h
r33231 r33326 87 87 macro(op_delete_prop_val) \ 88 88 macro(op_put_prop_index) \ 89 macro(op_put_getter) \ 90 macro(op_put_setter) \ 89 91 \ 90 92 macro(op_jmp) \ -
branches/squirrelfish/JavaScriptCore/kjs/nodes.cpp
r33306 r33326 963 963 break; 964 964 } 965 // FIXME: No support for getters and setters yet, as it caused a performance regression 965 case PropertyNode::Getter: { 966 generator.emitPutGetter(newObj.get(), p->m_node->name(), value); 967 break; 968 } 969 case PropertyNode::Setter: { 970 generator.emitPutSetter(newObj.get(), p->m_node->name(), value); 971 break; 972 } 966 973 default: 967 974 ASSERT_NOT_REACHED();