| Index: src/x64/lithium-codegen-x64.cc
|
| diff --git a/src/x64/lithium-codegen-x64.cc b/src/x64/lithium-codegen-x64.cc
|
| index 7c70094fbf03cda94da80d04a01e604d2b42d75e..b8dcb4564a321f7796227420ed9e8ef562f0e0fd 100644
|
| --- a/src/x64/lithium-codegen-x64.cc
|
| +++ b/src/x64/lithium-codegen-x64.cc
|
| @@ -5154,45 +5154,69 @@ void LCodeGen::EmitPushTaggedOperand(LOperand* operand) {
|
|
|
|
|
| void LCodeGen::DoTypeofIsAndBranch(LTypeofIsAndBranch* instr) {
|
| - Register input = ToRegister(instr->value());
|
| -
|
| - Condition final_branch_condition =
|
| - EmitTypeofIs(instr->TrueLabel(chunk_),
|
| - instr->FalseLabel(chunk_), input, instr->type_literal());
|
| - if (final_branch_condition != no_condition) {
|
| - EmitBranch(instr, final_branch_condition);
|
| + switch (instr->hydrogen()->state()) {
|
| + case HTypeofIsAndBranch::kUnKnown: {
|
| + Register input = ToRegister(instr->value());
|
| + Condition final_branch_condition = EmitTypeofIs(instr, input);
|
| + if (final_branch_condition != no_condition) {
|
| + EmitBranch(instr, final_branch_condition);
|
| + }
|
| + break;
|
| + }
|
| + case HTypeofIsAndBranch::kAlwaysTrue: {
|
| + __ jmp(instr->TrueLabel(chunk_));
|
| + break;
|
| + }
|
| + case HTypeofIsAndBranch::kAlwaysFalse: {
|
| + __ jmp(instr->FalseLabel(chunk_));
|
| + break;
|
| + }
|
| + default:
|
| + UNREACHABLE();
|
| }
|
| }
|
|
|
|
|
| -Condition LCodeGen::EmitTypeofIs(Label* true_label,
|
| - Label* false_label,
|
| - Register input,
|
| - Handle<String> type_name) {
|
| +Condition LCodeGen::EmitTypeofIs(LTypeofIsAndBranch* instr, Register input) {
|
| + Label* true_label = instr->TrueLabel(chunk_);
|
| + Label* false_label = instr->FalseLabel(chunk_);
|
| + Handle<String> type_name = instr->type_literal();
|
| + int left_block = instr->TrueDestination(chunk_);
|
| + int right_block = instr->FalseDestination(chunk_);
|
| + int next_block = GetNextEmittedBlock();
|
| +
|
| + Label::Distance true_distance = Label::kFar;
|
| + Label::Distance false_distance = Label::kFar;
|
| + if (left_block == next_block) {
|
| + true_distance = Label::kNear;
|
| + } else if (right_block == next_block) {
|
| + false_distance = Label::kNear;
|
| + }
|
| +
|
| Condition final_branch_condition = no_condition;
|
| if (type_name->Equals(heap()->number_string())) {
|
| - __ JumpIfSmi(input, true_label);
|
| + __ JumpIfSmi(input, true_label, true_distance);
|
| __ CompareRoot(FieldOperand(input, HeapObject::kMapOffset),
|
| Heap::kHeapNumberMapRootIndex);
|
|
|
| final_branch_condition = equal;
|
|
|
| } else if (type_name->Equals(heap()->string_string())) {
|
| - __ JumpIfSmi(input, false_label);
|
| + __ JumpIfSmi(input, false_label, false_distance);
|
| __ CmpObjectType(input, FIRST_NONSTRING_TYPE, input);
|
| - __ j(above_equal, false_label);
|
| + __ j(above_equal, false_label, false_distance);
|
| __ testb(FieldOperand(input, Map::kBitFieldOffset),
|
| Immediate(1 << Map::kIsUndetectable));
|
| final_branch_condition = zero;
|
|
|
| } else if (type_name->Equals(heap()->symbol_string())) {
|
| - __ JumpIfSmi(input, false_label);
|
| + __ JumpIfSmi(input, false_label, false_distance);
|
| __ CmpObjectType(input, SYMBOL_TYPE, input);
|
| final_branch_condition = equal;
|
|
|
| } else if (type_name->Equals(heap()->boolean_string())) {
|
| __ CompareRoot(input, Heap::kTrueValueRootIndex);
|
| - __ j(equal, true_label);
|
| + __ j(equal, true_label, true_distance);
|
| __ CompareRoot(input, Heap::kFalseValueRootIndex);
|
| final_branch_condition = equal;
|
|
|
| @@ -5202,8 +5226,8 @@ Condition LCodeGen::EmitTypeofIs(Label* true_label,
|
|
|
| } else if (type_name->Equals(heap()->undefined_string())) {
|
| __ CompareRoot(input, Heap::kUndefinedValueRootIndex);
|
| - __ j(equal, true_label);
|
| - __ JumpIfSmi(input, false_label);
|
| + __ j(equal, true_label, true_distance);
|
| + __ JumpIfSmi(input, false_label, false_distance);
|
| // Check for undetectable objects => true.
|
| __ movq(input, FieldOperand(input, HeapObject::kMapOffset));
|
| __ testb(FieldOperand(input, Map::kBitFieldOffset),
|
| @@ -5212,29 +5236,29 @@ Condition LCodeGen::EmitTypeofIs(Label* true_label,
|
|
|
| } else if (type_name->Equals(heap()->function_string())) {
|
| STATIC_ASSERT(NUM_OF_CALLABLE_SPEC_OBJECT_TYPES == 2);
|
| - __ JumpIfSmi(input, false_label);
|
| + __ JumpIfSmi(input, false_label, false_distance);
|
| __ CmpObjectType(input, JS_FUNCTION_TYPE, input);
|
| - __ j(equal, true_label);
|
| + __ j(equal, true_label, true_distance);
|
| __ CmpInstanceType(input, JS_FUNCTION_PROXY_TYPE);
|
| final_branch_condition = equal;
|
|
|
| } else if (type_name->Equals(heap()->object_string())) {
|
| - __ JumpIfSmi(input, false_label);
|
| + __ JumpIfSmi(input, false_label, false_distance);
|
| if (!FLAG_harmony_typeof) {
|
| __ CompareRoot(input, Heap::kNullValueRootIndex);
|
| - __ j(equal, true_label);
|
| + __ j(equal, true_label, true_distance);
|
| }
|
| __ CmpObjectType(input, FIRST_NONCALLABLE_SPEC_OBJECT_TYPE, input);
|
| - __ j(below, false_label);
|
| + __ j(below, false_label, false_distance);
|
| __ CmpInstanceType(input, LAST_NONCALLABLE_SPEC_OBJECT_TYPE);
|
| - __ j(above, false_label);
|
| + __ j(above, false_label, false_distance);
|
| // Check for undetectable objects => false.
|
| __ testb(FieldOperand(input, Map::kBitFieldOffset),
|
| Immediate(1 << Map::kIsUndetectable));
|
| final_branch_condition = zero;
|
|
|
| } else {
|
| - __ jmp(false_label);
|
| + __ jmp(false_label, false_distance);
|
| }
|
|
|
| return final_branch_condition;
|
|
|