OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 1196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1207 } | 1207 } |
1208 | 1208 |
1209 | 1209 |
1210 void LCodeGen::DoExternalArrayLength(LExternalArrayLength* instr) { | 1210 void LCodeGen::DoExternalArrayLength(LExternalArrayLength* instr) { |
1211 Register result = ToRegister(instr->result()); | 1211 Register result = ToRegister(instr->result()); |
1212 Register array = ToRegister(instr->InputAt(0)); | 1212 Register array = ToRegister(instr->InputAt(0)); |
1213 __ movl(result, FieldOperand(array, ExternalPixelArray::kLengthOffset)); | 1213 __ movl(result, FieldOperand(array, ExternalPixelArray::kLengthOffset)); |
1214 } | 1214 } |
1215 | 1215 |
1216 | 1216 |
| 1217 void LCodeGen::DoElementsKind(LElementsKind* instr) { |
| 1218 Register result = ToRegister(instr->result()); |
| 1219 Register input = ToRegister(instr->InputAt(0)); |
| 1220 |
| 1221 // Load map into |result|. |
| 1222 __ movq(result, FieldOperand(input, HeapObject::kMapOffset)); |
| 1223 // Load the map's "bit field 2" into |result|. We only need the first byte. |
| 1224 __ movzxbq(result, FieldOperand(result, Map::kBitField2Offset)); |
| 1225 // Retrieve elements_kind from bit field 2. |
| 1226 __ and_(result, Immediate(Map::kElementsKindMask)); |
| 1227 __ shr(result, Immediate(Map::kElementsKindShift)); |
| 1228 } |
| 1229 |
| 1230 |
1217 void LCodeGen::DoValueOf(LValueOf* instr) { | 1231 void LCodeGen::DoValueOf(LValueOf* instr) { |
1218 Register input = ToRegister(instr->InputAt(0)); | 1232 Register input = ToRegister(instr->InputAt(0)); |
1219 Register result = ToRegister(instr->result()); | 1233 Register result = ToRegister(instr->result()); |
1220 ASSERT(input.is(result)); | 1234 ASSERT(input.is(result)); |
1221 Label done; | 1235 Label done; |
1222 // If the object is a smi return the object. | 1236 // If the object is a smi return the object. |
1223 __ JumpIfSmi(input, &done, Label::kNear); | 1237 __ JumpIfSmi(input, &done, Label::kNear); |
1224 | 1238 |
1225 // If the object is not a value type, return the object. | 1239 // If the object is not a value type, return the object. |
1226 __ CmpObjectType(input, JS_VALUE_TYPE, kScratchRegister); | 1240 __ CmpObjectType(input, JS_VALUE_TYPE, kScratchRegister); |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1585 Register left = ToRegister(instr->InputAt(0)); | 1599 Register left = ToRegister(instr->InputAt(0)); |
1586 Register right = ToRegister(instr->InputAt(1)); | 1600 Register right = ToRegister(instr->InputAt(1)); |
1587 int false_block = chunk_->LookupDestination(instr->false_block_id()); | 1601 int false_block = chunk_->LookupDestination(instr->false_block_id()); |
1588 int true_block = chunk_->LookupDestination(instr->true_block_id()); | 1602 int true_block = chunk_->LookupDestination(instr->true_block_id()); |
1589 | 1603 |
1590 __ cmpq(left, right); | 1604 __ cmpq(left, right); |
1591 EmitBranch(true_block, false_block, equal); | 1605 EmitBranch(true_block, false_block, equal); |
1592 } | 1606 } |
1593 | 1607 |
1594 | 1608 |
| 1609 void LCodeGen::DoCmpConstantEq(LCmpConstantEq* instr) { |
| 1610 Register left = ToRegister(instr->InputAt(0)); |
| 1611 Register result = ToRegister(instr->result()); |
| 1612 |
| 1613 Label done; |
| 1614 __ cmpq(left, Immediate(instr->hydrogen()->right())); |
| 1615 __ LoadRoot(result, Heap::kTrueValueRootIndex); |
| 1616 __ j(equal, &done, Label::kNear); |
| 1617 __ LoadRoot(result, Heap::kFalseValueRootIndex); |
| 1618 __ bind(&done); |
| 1619 } |
| 1620 |
| 1621 |
| 1622 void LCodeGen::DoCmpConstantEqAndBranch(LCmpConstantEqAndBranch* instr) { |
| 1623 Register left = ToRegister(instr->InputAt(0)); |
| 1624 int true_block = chunk_->LookupDestination(instr->true_block_id()); |
| 1625 int false_block = chunk_->LookupDestination(instr->false_block_id()); |
| 1626 |
| 1627 __ cmpq(left, Immediate(instr->hydrogen()->right())); |
| 1628 EmitBranch(true_block, false_block, equal); |
| 1629 } |
| 1630 |
| 1631 |
1595 void LCodeGen::DoIsNull(LIsNull* instr) { | 1632 void LCodeGen::DoIsNull(LIsNull* instr) { |
1596 Register reg = ToRegister(instr->InputAt(0)); | 1633 Register reg = ToRegister(instr->InputAt(0)); |
1597 Register result = ToRegister(instr->result()); | 1634 Register result = ToRegister(instr->result()); |
1598 | 1635 |
1599 // If the expression is known to be a smi, then it's | 1636 // If the expression is known to be a smi, then it's |
1600 // definitely not null. Materialize false. | 1637 // definitely not null. Materialize false. |
1601 // Consider adding other type and representation tests too. | 1638 // Consider adding other type and representation tests too. |
1602 if (instr->hydrogen()->value()->type().IsSmi()) { | 1639 if (instr->hydrogen()->value()->type().IsSmi()) { |
1603 __ LoadRoot(result, Heap::kFalseValueRootIndex); | 1640 __ LoadRoot(result, Heap::kFalseValueRootIndex); |
1604 return; | 1641 return; |
(...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2371 // All done. | 2408 // All done. |
2372 __ bind(&done); | 2409 __ bind(&done); |
2373 } | 2410 } |
2374 | 2411 |
2375 | 2412 |
2376 void LCodeGen::DoLoadElements(LLoadElements* instr) { | 2413 void LCodeGen::DoLoadElements(LLoadElements* instr) { |
2377 Register result = ToRegister(instr->result()); | 2414 Register result = ToRegister(instr->result()); |
2378 Register input = ToRegister(instr->InputAt(0)); | 2415 Register input = ToRegister(instr->InputAt(0)); |
2379 __ movq(result, FieldOperand(input, JSObject::kElementsOffset)); | 2416 __ movq(result, FieldOperand(input, JSObject::kElementsOffset)); |
2380 if (FLAG_debug_code) { | 2417 if (FLAG_debug_code) { |
2381 Label done; | 2418 Label done, ok, fail; |
2382 __ CompareRoot(FieldOperand(result, HeapObject::kMapOffset), | 2419 __ CompareRoot(FieldOperand(result, HeapObject::kMapOffset), |
2383 Heap::kFixedArrayMapRootIndex); | 2420 Heap::kFixedArrayMapRootIndex); |
2384 __ j(equal, &done, Label::kNear); | 2421 __ j(equal, &done, Label::kNear); |
2385 __ CompareRoot(FieldOperand(result, HeapObject::kMapOffset), | 2422 __ CompareRoot(FieldOperand(result, HeapObject::kMapOffset), |
2386 Heap::kFixedCOWArrayMapRootIndex); | 2423 Heap::kFixedCOWArrayMapRootIndex); |
2387 __ j(equal, &done, Label::kNear); | 2424 __ j(equal, &done, Label::kNear); |
2388 Register temp((result.is(rax)) ? rbx : rax); | 2425 Register temp((result.is(rax)) ? rbx : rax); |
2389 __ push(temp); | 2426 __ push(temp); |
2390 __ movq(temp, FieldOperand(result, HeapObject::kMapOffset)); | 2427 __ movq(temp, FieldOperand(result, HeapObject::kMapOffset)); |
2391 __ movzxbq(temp, FieldOperand(temp, Map::kInstanceTypeOffset)); | 2428 __ movzxbq(temp, FieldOperand(temp, Map::kBitField2Offset)); |
2392 __ subq(temp, Immediate(FIRST_EXTERNAL_ARRAY_TYPE)); | 2429 __ and_(temp, Immediate(Map::kElementsKindMask)); |
2393 __ cmpq(temp, Immediate(kExternalArrayTypeCount)); | 2430 __ shr(temp, Immediate(Map::kElementsKindShift)); |
| 2431 __ cmpl(temp, Immediate(JSObject::FAST_ELEMENTS)); |
| 2432 __ j(equal, &ok, Label::kNear); |
| 2433 __ cmpl(temp, Immediate(JSObject::FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND)); |
| 2434 __ j(less, &fail, Label::kNear); |
| 2435 __ cmpl(temp, Immediate(JSObject::LAST_EXTERNAL_ARRAY_ELEMENTS_KIND)); |
| 2436 __ j(less_equal, &ok, Label::kNear); |
| 2437 __ bind(&fail); |
| 2438 __ Abort("Check for fast or external elements failed"); |
| 2439 __ bind(&ok); |
2394 __ pop(temp); | 2440 __ pop(temp); |
2395 __ Check(below, "Check for fast elements failed."); | |
2396 __ bind(&done); | 2441 __ bind(&done); |
2397 } | 2442 } |
2398 } | 2443 } |
2399 | 2444 |
2400 | 2445 |
2401 void LCodeGen::DoLoadExternalArrayPointer( | 2446 void LCodeGen::DoLoadExternalArrayPointer( |
2402 LLoadExternalArrayPointer* instr) { | 2447 LLoadExternalArrayPointer* instr) { |
2403 Register result = ToRegister(instr->result()); | 2448 Register result = ToRegister(instr->result()); |
2404 Register input = ToRegister(instr->InputAt(0)); | 2449 Register input = ToRegister(instr->InputAt(0)); |
2405 __ movq(result, FieldOperand(input, | 2450 __ movq(result, FieldOperand(input, |
(...skipping 1861 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4267 RegisterEnvironmentForDeoptimization(environment); | 4312 RegisterEnvironmentForDeoptimization(environment); |
4268 ASSERT(osr_pc_offset_ == -1); | 4313 ASSERT(osr_pc_offset_ == -1); |
4269 osr_pc_offset_ = masm()->pc_offset(); | 4314 osr_pc_offset_ = masm()->pc_offset(); |
4270 } | 4315 } |
4271 | 4316 |
4272 #undef __ | 4317 #undef __ |
4273 | 4318 |
4274 } } // namespace v8::internal | 4319 } } // namespace v8::internal |
4275 | 4320 |
4276 #endif // V8_TARGET_ARCH_X64 | 4321 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |