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 2324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2335 } | 2335 } |
2336 | 2336 |
2337 assembler->Bind(&if_valueissmi); | 2337 assembler->Bind(&if_valueissmi); |
2338 assembler->Goto(if_equal); | 2338 assembler->Goto(if_equal); |
2339 } | 2339 } |
2340 | 2340 |
2341 void GenerateEqual_Simd128Value_HeapObject( | 2341 void GenerateEqual_Simd128Value_HeapObject( |
2342 CodeStubAssembler* assembler, compiler::Node* lhs, compiler::Node* lhs_map, | 2342 CodeStubAssembler* assembler, compiler::Node* lhs, compiler::Node* lhs_map, |
2343 compiler::Node* rhs, compiler::Node* rhs_map, | 2343 compiler::Node* rhs, compiler::Node* rhs_map, |
2344 CodeStubAssembler::Label* if_equal, CodeStubAssembler::Label* if_notequal) { | 2344 CodeStubAssembler::Label* if_equal, CodeStubAssembler::Label* if_notequal) { |
2345 typedef CodeStubAssembler::Label Label; | 2345 assembler->BranchIfSimd128Equal(lhs, lhs_map, rhs, rhs_map, if_equal, |
2346 typedef compiler::Node Node; | 2346 if_notequal); |
2347 | |
2348 // Check if {lhs} and {rhs} have the same map. | |
2349 Label if_mapsame(assembler), if_mapnotsame(assembler); | |
2350 assembler->Branch(assembler->WordEqual(lhs_map, rhs_map), &if_mapsame, | |
2351 &if_mapnotsame); | |
2352 | |
2353 assembler->Bind(&if_mapsame); | |
2354 { | |
2355 // Both {lhs} and {rhs} are Simd128Values with the same map, need special | |
2356 // handling for Float32x4 because of NaN comparisons. | |
2357 Label if_float32x4(assembler), if_notfloat32x4(assembler); | |
2358 Node* float32x4_map = | |
2359 assembler->HeapConstant(assembler->factory()->float32x4_map()); | |
2360 assembler->Branch(assembler->WordEqual(lhs_map, float32x4_map), | |
2361 &if_float32x4, &if_notfloat32x4); | |
2362 | |
2363 assembler->Bind(&if_float32x4); | |
2364 { | |
2365 // Both {lhs} and {rhs} are Float32x4, compare the lanes individually | |
2366 // using a floating point comparison. | |
2367 for (int offset = Float32x4::kValueOffset - kHeapObjectTag; | |
2368 offset < Float32x4::kSize - kHeapObjectTag; | |
2369 offset += sizeof(float)) { | |
2370 // Load the floating point values for {lhs} and {rhs}. | |
2371 Node* lhs_value = assembler->Load(MachineType::Float32(), lhs, | |
2372 assembler->IntPtrConstant(offset)); | |
2373 Node* rhs_value = assembler->Load(MachineType::Float32(), rhs, | |
2374 assembler->IntPtrConstant(offset)); | |
2375 | |
2376 // Perform a floating point comparison. | |
2377 Label if_valueequal(assembler), if_valuenotequal(assembler); | |
2378 assembler->Branch(assembler->Float32Equal(lhs_value, rhs_value), | |
2379 &if_valueequal, &if_valuenotequal); | |
2380 assembler->Bind(&if_valuenotequal); | |
2381 assembler->Goto(if_notequal); | |
2382 assembler->Bind(&if_valueequal); | |
2383 } | |
2384 | |
2385 // All 4 lanes match, {lhs} and {rhs} considered equal. | |
2386 assembler->Goto(if_equal); | |
2387 } | |
2388 | |
2389 assembler->Bind(&if_notfloat32x4); | |
2390 { | |
2391 // For other Simd128Values we just perform a bitwise comparison. | |
2392 for (int offset = Simd128Value::kValueOffset - kHeapObjectTag; | |
2393 offset < Simd128Value::kSize - kHeapObjectTag; | |
2394 offset += kPointerSize) { | |
2395 // Load the word values for {lhs} and {rhs}. | |
2396 Node* lhs_value = assembler->Load(MachineType::Pointer(), lhs, | |
2397 assembler->IntPtrConstant(offset)); | |
2398 Node* rhs_value = assembler->Load(MachineType::Pointer(), rhs, | |
2399 assembler->IntPtrConstant(offset)); | |
2400 | |
2401 // Perform a bitwise word-comparison. | |
2402 Label if_valueequal(assembler), if_valuenotequal(assembler); | |
2403 assembler->Branch(assembler->WordEqual(lhs_value, rhs_value), | |
2404 &if_valueequal, &if_valuenotequal); | |
2405 assembler->Bind(&if_valuenotequal); | |
2406 assembler->Goto(if_notequal); | |
2407 assembler->Bind(&if_valueequal); | |
2408 } | |
2409 | |
2410 // Bitwise comparison succeeded, {lhs} and {rhs} considered equal. | |
2411 assembler->Goto(if_equal); | |
2412 } | |
2413 } | |
2414 | |
2415 assembler->Bind(&if_mapnotsame); | |
2416 assembler->Goto(if_notequal); | |
2417 } | 2347 } |
2418 | 2348 |
2419 // ES6 section 7.2.12 Abstract Equality Comparison | 2349 // ES6 section 7.2.12 Abstract Equality Comparison |
2420 compiler::Node* GenerateEqual(CodeStubAssembler* assembler, ResultMode mode, | 2350 compiler::Node* GenerateEqual(CodeStubAssembler* assembler, ResultMode mode, |
2421 compiler::Node* lhs, compiler::Node* rhs, | 2351 compiler::Node* lhs, compiler::Node* rhs, |
2422 compiler::Node* context) { | 2352 compiler::Node* context) { |
2423 // This is a slightly optimized version of Object::Equals represented as | 2353 // This is a slightly optimized version of Object::Equals represented as |
2424 // scheduled TurboFan graph utilizing the CodeStubAssembler. Whenever you | 2354 // scheduled TurboFan graph utilizing the CodeStubAssembler. Whenever you |
2425 // change something functionality wise in here, remember to update the | 2355 // change something functionality wise in here, remember to update the |
2426 // Object::Equals method as well. | 2356 // Object::Equals method as well. |
(...skipping 2505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4932 if (type->Is(Type::UntaggedPointer())) { | 4862 if (type->Is(Type::UntaggedPointer())) { |
4933 return Representation::External(); | 4863 return Representation::External(); |
4934 } | 4864 } |
4935 | 4865 |
4936 DCHECK(!type->Is(Type::Untagged())); | 4866 DCHECK(!type->Is(Type::Untagged())); |
4937 return Representation::Tagged(); | 4867 return Representation::Tagged(); |
4938 } | 4868 } |
4939 | 4869 |
4940 } // namespace internal | 4870 } // namespace internal |
4941 } // namespace v8 | 4871 } // namespace v8 |
OLD | NEW |