OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 5136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5147 __ Push(ToHandle(LConstantOperand::cast(operand))); | 5147 __ Push(ToHandle(LConstantOperand::cast(operand))); |
5148 } else if (operand->IsRegister()) { | 5148 } else if (operand->IsRegister()) { |
5149 __ push(ToRegister(operand)); | 5149 __ push(ToRegister(operand)); |
5150 } else { | 5150 } else { |
5151 __ push(ToOperand(operand)); | 5151 __ push(ToOperand(operand)); |
5152 } | 5152 } |
5153 } | 5153 } |
5154 | 5154 |
5155 | 5155 |
5156 void LCodeGen::DoTypeofIsAndBranch(LTypeofIsAndBranch* instr) { | 5156 void LCodeGen::DoTypeofIsAndBranch(LTypeofIsAndBranch* instr) { |
5157 Register input = ToRegister(instr->value()); | 5157 switch (instr->hydrogen()->state()) { |
5158 | 5158 case HTypeofIsAndBranch::kUnKnown: { |
5159 Condition final_branch_condition = | 5159 Register input = ToRegister(instr->value()); |
5160 EmitTypeofIs(instr->TrueLabel(chunk_), | 5160 Condition final_branch_condition = EmitTypeofIs(instr, input); |
5161 instr->FalseLabel(chunk_), input, instr->type_literal()); | 5161 if (final_branch_condition != no_condition) { |
5162 if (final_branch_condition != no_condition) { | 5162 EmitBranch(instr, final_branch_condition); |
5163 EmitBranch(instr, final_branch_condition); | 5163 } |
| 5164 break; |
| 5165 } |
| 5166 case HTypeofIsAndBranch::kAlwaysTrue: { |
| 5167 __ jmp(instr->TrueLabel(chunk_)); |
| 5168 break; |
| 5169 } |
| 5170 case HTypeofIsAndBranch::kAlwaysFalse: { |
| 5171 __ jmp(instr->FalseLabel(chunk_)); |
| 5172 break; |
| 5173 } |
| 5174 default: |
| 5175 UNREACHABLE(); |
5164 } | 5176 } |
5165 } | 5177 } |
5166 | 5178 |
5167 | 5179 |
5168 Condition LCodeGen::EmitTypeofIs(Label* true_label, | 5180 Condition LCodeGen::EmitTypeofIs(LTypeofIsAndBranch* instr, Register input) { |
5169 Label* false_label, | 5181 Label* true_label = instr->TrueLabel(chunk_); |
5170 Register input, | 5182 Label* false_label = instr->FalseLabel(chunk_); |
5171 Handle<String> type_name) { | 5183 Handle<String> type_name = instr->type_literal(); |
| 5184 int left_block = instr->TrueDestination(chunk_); |
| 5185 int right_block = instr->FalseDestination(chunk_); |
| 5186 int next_block = GetNextEmittedBlock(); |
| 5187 |
| 5188 Label::Distance true_distance = Label::kFar; |
| 5189 Label::Distance false_distance = Label::kFar; |
| 5190 if (left_block == next_block) { |
| 5191 true_distance = Label::kNear; |
| 5192 } else if (right_block == next_block) { |
| 5193 false_distance = Label::kNear; |
| 5194 } |
| 5195 |
5172 Condition final_branch_condition = no_condition; | 5196 Condition final_branch_condition = no_condition; |
5173 if (type_name->Equals(heap()->number_string())) { | 5197 if (type_name->Equals(heap()->number_string())) { |
5174 __ JumpIfSmi(input, true_label); | 5198 __ JumpIfSmi(input, true_label, true_distance); |
5175 __ CompareRoot(FieldOperand(input, HeapObject::kMapOffset), | 5199 __ CompareRoot(FieldOperand(input, HeapObject::kMapOffset), |
5176 Heap::kHeapNumberMapRootIndex); | 5200 Heap::kHeapNumberMapRootIndex); |
5177 | 5201 |
5178 final_branch_condition = equal; | 5202 final_branch_condition = equal; |
5179 | 5203 |
5180 } else if (type_name->Equals(heap()->string_string())) { | 5204 } else if (type_name->Equals(heap()->string_string())) { |
5181 __ JumpIfSmi(input, false_label); | 5205 __ JumpIfSmi(input, false_label, false_distance); |
5182 __ CmpObjectType(input, FIRST_NONSTRING_TYPE, input); | 5206 __ CmpObjectType(input, FIRST_NONSTRING_TYPE, input); |
5183 __ j(above_equal, false_label); | 5207 __ j(above_equal, false_label, false_distance); |
5184 __ testb(FieldOperand(input, Map::kBitFieldOffset), | 5208 __ testb(FieldOperand(input, Map::kBitFieldOffset), |
5185 Immediate(1 << Map::kIsUndetectable)); | 5209 Immediate(1 << Map::kIsUndetectable)); |
5186 final_branch_condition = zero; | 5210 final_branch_condition = zero; |
5187 | 5211 |
5188 } else if (type_name->Equals(heap()->symbol_string())) { | 5212 } else if (type_name->Equals(heap()->symbol_string())) { |
5189 __ JumpIfSmi(input, false_label); | 5213 __ JumpIfSmi(input, false_label, false_distance); |
5190 __ CmpObjectType(input, SYMBOL_TYPE, input); | 5214 __ CmpObjectType(input, SYMBOL_TYPE, input); |
5191 final_branch_condition = equal; | 5215 final_branch_condition = equal; |
5192 | 5216 |
5193 } else if (type_name->Equals(heap()->boolean_string())) { | 5217 } else if (type_name->Equals(heap()->boolean_string())) { |
5194 __ CompareRoot(input, Heap::kTrueValueRootIndex); | 5218 __ CompareRoot(input, Heap::kTrueValueRootIndex); |
5195 __ j(equal, true_label); | 5219 __ j(equal, true_label, true_distance); |
5196 __ CompareRoot(input, Heap::kFalseValueRootIndex); | 5220 __ CompareRoot(input, Heap::kFalseValueRootIndex); |
5197 final_branch_condition = equal; | 5221 final_branch_condition = equal; |
5198 | 5222 |
5199 } else if (FLAG_harmony_typeof && type_name->Equals(heap()->null_string())) { | 5223 } else if (FLAG_harmony_typeof && type_name->Equals(heap()->null_string())) { |
5200 __ CompareRoot(input, Heap::kNullValueRootIndex); | 5224 __ CompareRoot(input, Heap::kNullValueRootIndex); |
5201 final_branch_condition = equal; | 5225 final_branch_condition = equal; |
5202 | 5226 |
5203 } else if (type_name->Equals(heap()->undefined_string())) { | 5227 } else if (type_name->Equals(heap()->undefined_string())) { |
5204 __ CompareRoot(input, Heap::kUndefinedValueRootIndex); | 5228 __ CompareRoot(input, Heap::kUndefinedValueRootIndex); |
5205 __ j(equal, true_label); | 5229 __ j(equal, true_label, true_distance); |
5206 __ JumpIfSmi(input, false_label); | 5230 __ JumpIfSmi(input, false_label, false_distance); |
5207 // Check for undetectable objects => true. | 5231 // Check for undetectable objects => true. |
5208 __ movq(input, FieldOperand(input, HeapObject::kMapOffset)); | 5232 __ movq(input, FieldOperand(input, HeapObject::kMapOffset)); |
5209 __ testb(FieldOperand(input, Map::kBitFieldOffset), | 5233 __ testb(FieldOperand(input, Map::kBitFieldOffset), |
5210 Immediate(1 << Map::kIsUndetectable)); | 5234 Immediate(1 << Map::kIsUndetectable)); |
5211 final_branch_condition = not_zero; | 5235 final_branch_condition = not_zero; |
5212 | 5236 |
5213 } else if (type_name->Equals(heap()->function_string())) { | 5237 } else if (type_name->Equals(heap()->function_string())) { |
5214 STATIC_ASSERT(NUM_OF_CALLABLE_SPEC_OBJECT_TYPES == 2); | 5238 STATIC_ASSERT(NUM_OF_CALLABLE_SPEC_OBJECT_TYPES == 2); |
5215 __ JumpIfSmi(input, false_label); | 5239 __ JumpIfSmi(input, false_label, false_distance); |
5216 __ CmpObjectType(input, JS_FUNCTION_TYPE, input); | 5240 __ CmpObjectType(input, JS_FUNCTION_TYPE, input); |
5217 __ j(equal, true_label); | 5241 __ j(equal, true_label, true_distance); |
5218 __ CmpInstanceType(input, JS_FUNCTION_PROXY_TYPE); | 5242 __ CmpInstanceType(input, JS_FUNCTION_PROXY_TYPE); |
5219 final_branch_condition = equal; | 5243 final_branch_condition = equal; |
5220 | 5244 |
5221 } else if (type_name->Equals(heap()->object_string())) { | 5245 } else if (type_name->Equals(heap()->object_string())) { |
5222 __ JumpIfSmi(input, false_label); | 5246 __ JumpIfSmi(input, false_label, false_distance); |
5223 if (!FLAG_harmony_typeof) { | 5247 if (!FLAG_harmony_typeof) { |
5224 __ CompareRoot(input, Heap::kNullValueRootIndex); | 5248 __ CompareRoot(input, Heap::kNullValueRootIndex); |
5225 __ j(equal, true_label); | 5249 __ j(equal, true_label, true_distance); |
5226 } | 5250 } |
5227 __ CmpObjectType(input, FIRST_NONCALLABLE_SPEC_OBJECT_TYPE, input); | 5251 __ CmpObjectType(input, FIRST_NONCALLABLE_SPEC_OBJECT_TYPE, input); |
5228 __ j(below, false_label); | 5252 __ j(below, false_label, false_distance); |
5229 __ CmpInstanceType(input, LAST_NONCALLABLE_SPEC_OBJECT_TYPE); | 5253 __ CmpInstanceType(input, LAST_NONCALLABLE_SPEC_OBJECT_TYPE); |
5230 __ j(above, false_label); | 5254 __ j(above, false_label, false_distance); |
5231 // Check for undetectable objects => false. | 5255 // Check for undetectable objects => false. |
5232 __ testb(FieldOperand(input, Map::kBitFieldOffset), | 5256 __ testb(FieldOperand(input, Map::kBitFieldOffset), |
5233 Immediate(1 << Map::kIsUndetectable)); | 5257 Immediate(1 << Map::kIsUndetectable)); |
5234 final_branch_condition = zero; | 5258 final_branch_condition = zero; |
5235 | 5259 |
5236 } else { | 5260 } else { |
5237 __ jmp(false_label); | 5261 __ jmp(false_label, false_distance); |
5238 } | 5262 } |
5239 | 5263 |
5240 return final_branch_condition; | 5264 return final_branch_condition; |
5241 } | 5265 } |
5242 | 5266 |
5243 | 5267 |
5244 void LCodeGen::DoIsConstructCallAndBranch(LIsConstructCallAndBranch* instr) { | 5268 void LCodeGen::DoIsConstructCallAndBranch(LIsConstructCallAndBranch* instr) { |
5245 Register temp = ToRegister(instr->temp()); | 5269 Register temp = ToRegister(instr->temp()); |
5246 | 5270 |
5247 EmitIsConstructCall(temp); | 5271 EmitIsConstructCall(temp); |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5471 FixedArray::kHeaderSize - kPointerSize)); | 5495 FixedArray::kHeaderSize - kPointerSize)); |
5472 __ bind(&done); | 5496 __ bind(&done); |
5473 } | 5497 } |
5474 | 5498 |
5475 | 5499 |
5476 #undef __ | 5500 #undef __ |
5477 | 5501 |
5478 } } // namespace v8::internal | 5502 } } // namespace v8::internal |
5479 | 5503 |
5480 #endif // V8_TARGET_ARCH_X64 | 5504 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |