OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/code-stubs.h" | 5 #include "src/code-stubs.h" |
6 | 6 |
7 #include <sstream> | 7 #include <sstream> |
8 | 8 |
9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
10 #include "src/code-factory.h" | 10 #include "src/code-factory.h" |
(...skipping 2444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2455 } | 2455 } |
2456 | 2456 |
2457 assembler->Bind(&if_valueissmi); | 2457 assembler->Bind(&if_valueissmi); |
2458 assembler->Goto(if_equal); | 2458 assembler->Goto(if_equal); |
2459 } | 2459 } |
2460 | 2460 |
2461 void GenerateEqual_Simd128Value_HeapObject( | 2461 void GenerateEqual_Simd128Value_HeapObject( |
2462 CodeStubAssembler* assembler, compiler::Node* lhs, compiler::Node* lhs_map, | 2462 CodeStubAssembler* assembler, compiler::Node* lhs, compiler::Node* lhs_map, |
2463 compiler::Node* rhs, compiler::Node* rhs_map, | 2463 compiler::Node* rhs, compiler::Node* rhs_map, |
2464 CodeStubAssembler::Label* if_equal, CodeStubAssembler::Label* if_notequal) { | 2464 CodeStubAssembler::Label* if_equal, CodeStubAssembler::Label* if_notequal) { |
2465 typedef CodeStubAssembler::Label Label; | 2465 assembler->BranchIfSimd128Equal(lhs, lhs_map, rhs, rhs_map, if_equal, |
2466 typedef compiler::Node Node; | 2466 if_notequal); |
2467 | |
2468 // Check if {lhs} and {rhs} have the same map. | |
2469 Label if_mapsame(assembler), if_mapnotsame(assembler); | |
2470 assembler->Branch(assembler->WordEqual(lhs_map, rhs_map), &if_mapsame, | |
2471 &if_mapnotsame); | |
2472 | |
2473 assembler->Bind(&if_mapsame); | |
2474 { | |
2475 // Both {lhs} and {rhs} are Simd128Values with the same map, need special | |
2476 // handling for Float32x4 because of NaN comparisons. | |
2477 Label if_float32x4(assembler), if_notfloat32x4(assembler); | |
2478 Node* float32x4_map = | |
2479 assembler->HeapConstant(assembler->factory()->float32x4_map()); | |
2480 assembler->Branch(assembler->WordEqual(lhs_map, float32x4_map), | |
2481 &if_float32x4, &if_notfloat32x4); | |
2482 | |
2483 assembler->Bind(&if_float32x4); | |
2484 { | |
2485 // Both {lhs} and {rhs} are Float32x4, compare the lanes individually | |
2486 // using a floating point comparison. | |
2487 for (int offset = Float32x4::kValueOffset - kHeapObjectTag; | |
2488 offset < Float32x4::kSize - kHeapObjectTag; | |
2489 offset += sizeof(float)) { | |
2490 // Load the floating point values for {lhs} and {rhs}. | |
2491 Node* lhs_value = assembler->Load(MachineType::Float32(), lhs, | |
2492 assembler->IntPtrConstant(offset)); | |
2493 Node* rhs_value = assembler->Load(MachineType::Float32(), rhs, | |
2494 assembler->IntPtrConstant(offset)); | |
2495 | |
2496 // Perform a floating point comparison. | |
2497 Label if_valueequal(assembler), if_valuenotequal(assembler); | |
2498 assembler->Branch(assembler->Float32Equal(lhs_value, rhs_value), | |
2499 &if_valueequal, &if_valuenotequal); | |
2500 assembler->Bind(&if_valuenotequal); | |
2501 assembler->Goto(if_notequal); | |
2502 assembler->Bind(&if_valueequal); | |
2503 } | |
2504 | |
2505 // All 4 lanes match, {lhs} and {rhs} considered equal. | |
2506 assembler->Goto(if_equal); | |
2507 } | |
2508 | |
2509 assembler->Bind(&if_notfloat32x4); | |
2510 { | |
2511 // For other Simd128Values we just perform a bitwise comparison. | |
2512 for (int offset = Simd128Value::kValueOffset - kHeapObjectTag; | |
2513 offset < Simd128Value::kSize - kHeapObjectTag; | |
2514 offset += kPointerSize) { | |
2515 // Load the word values for {lhs} and {rhs}. | |
2516 Node* lhs_value = assembler->Load(MachineType::Pointer(), lhs, | |
2517 assembler->IntPtrConstant(offset)); | |
2518 Node* rhs_value = assembler->Load(MachineType::Pointer(), rhs, | |
2519 assembler->IntPtrConstant(offset)); | |
2520 | |
2521 // Perform a bitwise word-comparison. | |
2522 Label if_valueequal(assembler), if_valuenotequal(assembler); | |
2523 assembler->Branch(assembler->WordEqual(lhs_value, rhs_value), | |
2524 &if_valueequal, &if_valuenotequal); | |
2525 assembler->Bind(&if_valuenotequal); | |
2526 assembler->Goto(if_notequal); | |
2527 assembler->Bind(&if_valueequal); | |
2528 } | |
2529 | |
2530 // Bitwise comparison succeeded, {lhs} and {rhs} considered equal. | |
2531 assembler->Goto(if_equal); | |
2532 } | |
2533 } | |
2534 | |
2535 assembler->Bind(&if_mapnotsame); | |
2536 assembler->Goto(if_notequal); | |
2537 } | 2467 } |
2538 | 2468 |
2539 // ES6 section 7.2.12 Abstract Equality Comparison | 2469 // ES6 section 7.2.12 Abstract Equality Comparison |
2540 compiler::Node* GenerateEqual(CodeStubAssembler* assembler, ResultMode mode, | 2470 compiler::Node* GenerateEqual(CodeStubAssembler* assembler, ResultMode mode, |
2541 compiler::Node* lhs, compiler::Node* rhs, | 2471 compiler::Node* lhs, compiler::Node* rhs, |
2542 compiler::Node* context) { | 2472 compiler::Node* context) { |
2543 // This is a slightly optimized version of Object::Equals represented as | 2473 // This is a slightly optimized version of Object::Equals represented as |
2544 // scheduled TurboFan graph utilizing the CodeStubAssembler. Whenever you | 2474 // scheduled TurboFan graph utilizing the CodeStubAssembler. Whenever you |
2545 // change something functionality wise in here, remember to update the | 2475 // change something functionality wise in here, remember to update the |
2546 // Object::Equals method as well. | 2476 // Object::Equals method as well. |
(...skipping 2515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5062 if (type->Is(Type::UntaggedPointer())) { | 4992 if (type->Is(Type::UntaggedPointer())) { |
5063 return Representation::External(); | 4993 return Representation::External(); |
5064 } | 4994 } |
5065 | 4995 |
5066 DCHECK(!type->Is(Type::Untagged())); | 4996 DCHECK(!type->Is(Type::Untagged())); |
5067 return Representation::Tagged(); | 4997 return Representation::Tagged(); |
5068 } | 4998 } |
5069 | 4999 |
5070 } // namespace internal | 5000 } // namespace internal |
5071 } // namespace v8 | 5001 } // namespace v8 |
OLD | NEW |