Index: src/ia32/lithium-ia32.cc |
diff --git a/src/ia32/lithium-ia32.cc b/src/ia32/lithium-ia32.cc |
index 6f87a256c57da9b565f4c00119d7434f3ef54d46..d7ca3e2999fa094320e3da5459330bd17b518061 100644 |
--- a/src/ia32/lithium-ia32.cc |
+++ b/src/ia32/lithium-ia32.cc |
@@ -1688,7 +1688,13 @@ LInstruction* LChunkBuilder::DoCheckSmi(HCheckSmi* instr) { |
LInstruction* LChunkBuilder::DoCheckFunction(HCheckFunction* instr) { |
- LOperand* value = UseAtStart(instr->value()); |
+ // If the target is in new space, we'll emit a global cell compare and so |
+ // want the value in a register. If the target gets promoted before we |
+ // emit code, we will still get the register but will do an immediate |
+ // compare instead of the cell compare. This is safe. |
+ LOperand* value = Isolate::Current()->heap()->InNewSpace(*instr->target()) |
+ ? UseRegisterAtStart(instr->value()) |
+ : UseAtStart(instr->value()); |
return AssignEnvironment(new LCheckFunction(value)); |
} |