Commit a8b2d9a1 authored by zhengxing.li's avatar zhengxing.li Committed by Commit bot

X87: [runtime] Use "the hole" instead of smi 0 as sentinel for context extension.

  port 9e644881 (r32407)

  original commit message:
  This way we avoid the %_IsSmi magic that is required in TurboFan to
  (efficiently) check abitrary context slots for smi 0. Checking against
  "the hole" is common in the AstGraphBuilder and "the hole" is also used
  to mark other context slots as not initialized.

BUG=

Review URL: https://codereview.chromium.org/1486913002

Cr-Commit-Position: refs/heads/master@{#32441}
parent d0a3ad06
......@@ -1187,10 +1187,9 @@ void FullCodeGenerator::EmitLoadGlobalCheckExtensions(VariableProxy* proxy,
while (s != NULL) {
if (s->num_heap_slots() > 0) {
if (s->calls_sloppy_eval()) {
// Check that extension is NULL.
__ cmp(ContextOperand(context, Context::EXTENSION_INDEX),
Immediate(0));
__ j(not_equal, slow);
// Check that extension is "the hole".
__ JumpIfNotRoot(ContextOperand(context, Context::EXTENSION_INDEX),
Heap::kTheHoleValueRootIndex, slow);
}
// Load next context in chain.
__ mov(temp, ContextOperand(context, Context::PREVIOUS_INDEX));
......@@ -1216,9 +1215,9 @@ void FullCodeGenerator::EmitLoadGlobalCheckExtensions(VariableProxy* proxy,
__ cmp(FieldOperand(temp, HeapObject::kMapOffset),
Immediate(isolate()->factory()->native_context_map()));
__ j(equal, &fast, Label::kNear);
// Check that extension is NULL.
__ cmp(ContextOperand(temp, Context::EXTENSION_INDEX), Immediate(0));
__ j(not_equal, slow);
// Check that extension is "the hole".
__ JumpIfNotRoot(ContextOperand(temp, Context::EXTENSION_INDEX),
Heap::kTheHoleValueRootIndex, slow);
// Load next context in chain.
__ mov(temp, ContextOperand(temp, Context::PREVIOUS_INDEX));
__ jmp(&next);
......@@ -1240,19 +1239,18 @@ MemOperand FullCodeGenerator::ContextSlotOperandCheckExtensions(Variable* var,
for (Scope* s = scope(); s != var->scope(); s = s->outer_scope()) {
if (s->num_heap_slots() > 0) {
if (s->calls_sloppy_eval()) {
// Check that extension is NULL.
__ cmp(ContextOperand(context, Context::EXTENSION_INDEX),
Immediate(0));
__ j(not_equal, slow);
// Check that extension is "the hole".
__ JumpIfNotRoot(ContextOperand(context, Context::EXTENSION_INDEX),
Heap::kTheHoleValueRootIndex, slow);
}
__ mov(temp, ContextOperand(context, Context::PREVIOUS_INDEX));
// Walk the rest of the chain without clobbering esi.
context = temp;
}
}
// Check that last extension is NULL.
__ cmp(ContextOperand(context, Context::EXTENSION_INDEX), Immediate(0));
__ j(not_equal, slow);
// Check that last extension is "the hole".
__ JumpIfNotRoot(ContextOperand(context, Context::EXTENSION_INDEX),
Heap::kTheHoleValueRootIndex, slow);
// This function is used only for loads, not stores, so it's safe to
// return an esi-based operand (the write barrier cannot be allowed to
......
......@@ -85,6 +85,12 @@ class MacroAssembler: public Assembler {
CompareRoot(with, index);
j(equal, if_equal, if_equal_distance);
}
void JumpIfRoot(const Operand& with, Heap::RootListIndex index,
Label* if_equal,
Label::Distance if_equal_distance = Label::kNear) {
CompareRoot(with, index);
j(equal, if_equal, if_equal_distance);
}
// Compare the object in a register to a value and jump if they are not equal.
void JumpIfNotRoot(Register with, Heap::RootListIndex index,
......@@ -93,6 +99,12 @@ class MacroAssembler: public Assembler {
CompareRoot(with, index);
j(not_equal, if_not_equal, if_not_equal_distance);
}
void JumpIfNotRoot(const Operand& with, Heap::RootListIndex index,
Label* if_not_equal,
Label::Distance if_not_equal_distance = Label::kNear) {
CompareRoot(with, index);
j(not_equal, if_not_equal, if_not_equal_distance);
}
// ---------------------------------------------------------------------------
// GC Support
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment