Index: src/ia32/builtins-ia32.cc |
diff --git a/src/ia32/builtins-ia32.cc b/src/ia32/builtins-ia32.cc |
index c849dbbb75f56cf2b82c4d72dd932245c8cef744..4da4cb1db2b98eaf30861fc1f6be7f507e76f48d 100644 |
--- a/src/ia32/builtins-ia32.cc |
+++ b/src/ia32/builtins-ia32.cc |
@@ -151,14 +151,13 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm, |
__ cmp(Operand::StaticVariable(debug_step_in_fp), Immediate(0)); |
__ j(not_equal, &rt_call); |
- // Fall back to runtime if the original constructor and function differ. |
- __ cmp(edx, edi); |
+ // Verify that the original constructor is a JSFunction. |
+ __ CmpObjectType(edx, JS_FUNCTION_TYPE, ebx); |
__ j(not_equal, &rt_call); |
- // Verified that the constructor is a JSFunction. |
// Load the initial map and verify that it is in fact a map. |
- // edi: constructor |
- __ mov(eax, FieldOperand(edi, JSFunction::kPrototypeOrInitialMapOffset)); |
+ // edx: original constructor |
+ __ mov(eax, FieldOperand(edx, JSFunction::kPrototypeOrInitialMapOffset)); |
// Will both indicate a NULL and a Smi |
__ JumpIfSmi(eax, &rt_call); |
// edi: constructor |
@@ -166,6 +165,11 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm, |
__ CmpObjectType(eax, MAP_TYPE, ebx); |
__ j(not_equal, &rt_call); |
+ // Fall back to runtime if the expected base constructor and base |
+ // constructor differ. |
+ __ cmp(edi, FieldOperand(eax, Map::kConstructorOrBackPointerOffset)); |
+ __ j(not_equal, &rt_call); |
+ |
// Check that the constructor is not constructing a JSFunction (see |
// comments in Runtime_NewObject in runtime.cc). In which case the |
// initial map's instance type would be JS_FUNCTION_TYPE. |
@@ -194,7 +198,7 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm, |
__ push(edx); |
__ push(edi); |
- __ push(edi); // constructor |
+ __ push(eax); // initial map |
__ CallRuntime(Runtime::kFinalizeInstanceSize, 1); |
__ pop(edi); |