Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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-stub-assembler.h" | 5 #include "src/code-stub-assembler.h" |
| 6 #include "src/code-factory.h" | 6 #include "src/code-factory.h" |
| 7 #include "src/frames-inl.h" | 7 #include "src/frames-inl.h" |
| 8 #include "src/frames.h" | 8 #include "src/frames.h" |
| 9 #include "src/ic/stub-cache.h" | 9 #include "src/ic/stub-cache.h" |
| 10 | 10 |
| (...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 464 | 464 |
| 465 Node* CodeStubAssembler::WordIsSmi(Node* a) { | 465 Node* CodeStubAssembler::WordIsSmi(Node* a) { |
| 466 return WordEqual(WordAnd(a, IntPtrConstant(kSmiTagMask)), IntPtrConstant(0)); | 466 return WordEqual(WordAnd(a, IntPtrConstant(kSmiTagMask)), IntPtrConstant(0)); |
| 467 } | 467 } |
| 468 | 468 |
| 469 Node* CodeStubAssembler::WordIsPositiveSmi(Node* a) { | 469 Node* CodeStubAssembler::WordIsPositiveSmi(Node* a) { |
| 470 return WordEqual(WordAnd(a, IntPtrConstant(kSmiTagMask | kSmiSignMask)), | 470 return WordEqual(WordAnd(a, IntPtrConstant(kSmiTagMask | kSmiSignMask)), |
| 471 IntPtrConstant(0)); | 471 IntPtrConstant(0)); |
| 472 } | 472 } |
| 473 | 473 |
| 474 void CodeStubAssembler::BranchIfSameValueZero(Node* a, Node* b, Node* context, | |
|
Benedikt Meurer
2016/07/15 17:59:55
Nice, this looks pretty good already. You'll have
| |
| 475 Label* if_true, Label* if_false) { | |
| 476 Node* number_map = HeapNumberMapConstant(); | |
| 477 Label a_isnumber(this), a_isnotnumber(this), b_isnumber(this), a_isnan(this), | |
| 478 float_not_equal(this); | |
| 479 // If register A and register B are identical, goto `if_true` | |
| 480 GotoIf(WordEqual(a, b), if_true); | |
| 481 // If either register A or B are Smis, goto `if_false` | |
| 482 GotoIf(WordIsSmi(a), if_false); | |
| 483 GotoIf(WordIsSmi(b), if_false); | |
| 484 | |
| 485 Node* map_a = LoadMap(a); | |
| 486 Node* map_b = LoadMap(b); | |
| 487 Branch(WordEqual(map_a, number_map), &a_isnumber, &a_isnotnumber); | |
| 488 | |
| 489 // If both register A and B are HeapNumbers, return true if they are equal, | |
| 490 // or if both are NaN | |
| 491 Bind(&a_isnumber); | |
| 492 { | |
| 493 Branch(WordEqual(map_b, number_map), &b_isnumber, if_false); | |
| 494 | |
| 495 Bind(&b_isnumber); | |
| 496 Node* a_value = LoadHeapNumberValue(a); | |
| 497 Node* b_value = LoadHeapNumberValue(b); | |
| 498 BranchIfFloat64Equal(a_value, b_value, if_true, &float_not_equal); | |
| 499 | |
| 500 Bind(&float_not_equal); | |
| 501 BranchIfFloat64IsNaN(a_value, &a_isnan, if_false); | |
| 502 | |
| 503 Bind(&a_isnan); | |
| 504 BranchIfFloat64IsNaN(a_value, if_true, if_false); | |
| 505 } | |
| 506 | |
| 507 Bind(&a_isnotnumber); | |
| 508 { | |
| 509 Label a_isstring(this); | |
| 510 Node* a_instance_type = LoadMapInstanceType(map_a); | |
| 511 | |
| 512 Branch(Int32LessThan(a_instance_type, Int32Constant(FIRST_NONSTRING_TYPE)), | |
| 513 &a_isstring, if_false); | |
|
Benedikt Meurer
2016/07/15 17:59:55
Instead of going to if_false here, you can check i
| |
| 514 | |
| 515 Bind(&a_isstring); | |
| 516 { | |
| 517 Label b_isstring(this), b_isnotstring(this); | |
| 518 Node* b_instance_type = LoadInstanceType(map_b); | |
| 519 | |
| 520 Branch( | |
| 521 Int32LessThan(b_instance_type, Int32Constant(FIRST_NONSTRING_TYPE)), | |
| 522 &b_isstring, if_false); | |
| 523 | |
| 524 Bind(&b_isstring); | |
| 525 { | |
| 526 Callable callable = CodeFactory::StringEqual(isolate()); | |
| 527 Node* result = CallStub(callable, context, a, b); | |
| 528 Branch(WordEqual(BooleanConstant(true), result), if_true, if_false); | |
| 529 } | |
| 530 } | |
| 531 } | |
| 532 } | |
| 533 | |
| 474 Node* CodeStubAssembler::AllocateRawUnaligned(Node* size_in_bytes, | 534 Node* CodeStubAssembler::AllocateRawUnaligned(Node* size_in_bytes, |
| 475 AllocationFlags flags, | 535 AllocationFlags flags, |
| 476 Node* top_address, | 536 Node* top_address, |
| 477 Node* limit_address) { | 537 Node* limit_address) { |
| 478 Node* top = Load(MachineType::Pointer(), top_address); | 538 Node* top = Load(MachineType::Pointer(), top_address); |
| 479 Node* limit = Load(MachineType::Pointer(), limit_address); | 539 Node* limit = Load(MachineType::Pointer(), limit_address); |
| 480 | 540 |
| 481 // If there's not enough space, call the runtime. | 541 // If there's not enough space, call the runtime. |
| 482 Variable result(this, MachineRepresentation::kTagged); | 542 Variable result(this, MachineRepresentation::kTagged); |
| 483 Label runtime_call(this, Label::kDeferred), no_runtime_call(this); | 543 Label runtime_call(this, Label::kDeferred), no_runtime_call(this); |
| (...skipping 2506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2990 } | 3050 } |
| 2991 Bind(&miss); | 3051 Bind(&miss); |
| 2992 { | 3052 { |
| 2993 TailCallRuntime(Runtime::kLoadGlobalIC_Miss, p->context, p->slot, | 3053 TailCallRuntime(Runtime::kLoadGlobalIC_Miss, p->context, p->slot, |
| 2994 p->vector); | 3054 p->vector); |
| 2995 } | 3055 } |
| 2996 } | 3056 } |
| 2997 | 3057 |
| 2998 } // namespace internal | 3058 } // namespace internal |
| 2999 } // namespace v8 | 3059 } // namespace v8 |
| OLD | NEW |