Index: src/ia32/lithium-codegen-ia32.cc |
diff --git a/src/ia32/lithium-codegen-ia32.cc b/src/ia32/lithium-codegen-ia32.cc |
index 25138df9de2df992a19b878d10ba3cbe003db6d6..b07a006bb4f1df417f87baf2890752d85110de72 100644 |
--- a/src/ia32/lithium-codegen-ia32.cc |
+++ b/src/ia32/lithium-codegen-ia32.cc |
@@ -2200,23 +2200,29 @@ void LCodeGen::DoLoadNamedField(LLoadNamedField* instr) { |
} |
-void LCodeGen::EmitLoadField(Register result, |
- Register object, |
- Handle<Map> type, |
- Handle<String> name) { |
+void LCodeGen::EmitLoadFieldOrConstantFunction(Register result, |
+ Register object, |
+ Handle<Map> type, |
+ Handle<String> name) { |
LookupResult lookup; |
type->LookupInDescriptors(NULL, *name, &lookup); |
- ASSERT(lookup.IsProperty() && lookup.type() == FIELD); |
- int index = lookup.GetLocalFieldIndexFromMap(*type); |
- int offset = index * kPointerSize; |
- if (index < 0) { |
- // Negative property indices are in-object properties, indexed |
- // from the end of the fixed part of the object. |
- __ mov(result, FieldOperand(object, offset + type->instance_size())); |
+ ASSERT(lookup.IsProperty() && |
+ (lookup.type() == FIELD || lookup.type() == CONSTANT_FUNCTION)); |
+ if (lookup.type() == FIELD) { |
+ int index = lookup.GetLocalFieldIndexFromMap(*type); |
+ int offset = index * kPointerSize; |
+ if (index < 0) { |
+ // Negative property indices are in-object properties, indexed |
+ // from the end of the fixed part of the object. |
+ __ mov(result, FieldOperand(object, offset + type->instance_size())); |
+ } else { |
+ // Non-negative property indices are in the properties array. |
+ __ mov(result, FieldOperand(object, JSObject::kPropertiesOffset)); |
+ __ mov(result, FieldOperand(result, offset + FixedArray::kHeaderSize)); |
+ } |
} else { |
- // Non-negative property indices are in the properties array. |
- __ mov(result, FieldOperand(object, JSObject::kPropertiesOffset)); |
- __ mov(result, FieldOperand(result, offset + FixedArray::kHeaderSize)); |
+ Handle<JSFunction> function(lookup.GetConstantFunctionFromMap(*type)); |
+ LoadHeapObject(result, Handle<HeapObject>::cast(function)); |
} |
} |
@@ -2239,7 +2245,7 @@ void LCodeGen::DoLoadNamedFieldPolymorphic(LLoadNamedFieldPolymorphic* instr) { |
NearLabel next; |
__ cmp(FieldOperand(object, HeapObject::kMapOffset), map); |
__ j(not_equal, &next); |
- EmitLoadField(result, object, map, name); |
+ EmitLoadFieldOrConstantFunction(result, object, map, name); |
__ jmp(&done); |
__ bind(&next); |
} |
@@ -2248,7 +2254,7 @@ void LCodeGen::DoLoadNamedFieldPolymorphic(LLoadNamedFieldPolymorphic* instr) { |
if (instr->hydrogen()->need_generic()) { |
NearLabel generic; |
__ j(not_equal, &generic); |
- EmitLoadField(result, object, map, name); |
+ EmitLoadFieldOrConstantFunction(result, object, map, name); |
__ jmp(&done); |
__ bind(&generic); |
__ mov(ecx, name); |
@@ -2256,7 +2262,7 @@ void LCodeGen::DoLoadNamedFieldPolymorphic(LLoadNamedFieldPolymorphic* instr) { |
CallCode(ic, RelocInfo::CODE_TARGET, instr, RESTORE_CONTEXT); |
} else { |
DeoptimizeIf(not_equal, instr->environment()); |
- EmitLoadField(result, object, map, name); |
+ EmitLoadFieldOrConstantFunction(result, object, map, name); |
} |
__ bind(&done); |
} |