Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: src/code-stub-assembler.cc

Issue 2151163002: [stubs] Improve code generation for ToBoolean. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: REBASE. Fix redness. Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/code-stub-assembler.h ('k') | src/code-stubs.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 587 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 } 598 }
599 599
600 Node* CodeStubAssembler::InnerAllocate(Node* previous, Node* offset) { 600 Node* CodeStubAssembler::InnerAllocate(Node* previous, Node* offset) {
601 return BitcastWordToTagged(IntPtrAdd(previous, offset)); 601 return BitcastWordToTagged(IntPtrAdd(previous, offset));
602 } 602 }
603 603
604 Node* CodeStubAssembler::InnerAllocate(Node* previous, int offset) { 604 Node* CodeStubAssembler::InnerAllocate(Node* previous, int offset) {
605 return InnerAllocate(previous, IntPtrConstant(offset)); 605 return InnerAllocate(previous, IntPtrConstant(offset));
606 } 606 }
607 607
608 void CodeStubAssembler::BranchIfToBooleanIsTrue(Node* value, Label* if_true,
609 Label* if_false) {
610 Label if_valueissmi(this), if_valueisnotsmi(this), if_valueisstring(this),
611 if_valueisheapnumber(this), if_valueisother(this);
612
613 // Fast check for Boolean {value}s (common case).
614 GotoIf(WordEqual(value, BooleanConstant(true)), if_true);
615 GotoIf(WordEqual(value, BooleanConstant(false)), if_false);
616
617 // Check if {value} is a Smi or a HeapObject.
618 Branch(WordIsSmi(value), &if_valueissmi, &if_valueisnotsmi);
619
620 Bind(&if_valueissmi);
621 {
622 // The {value} is a Smi, only need to check against zero.
623 BranchIfSmiEqual(value, SmiConstant(0), if_false, if_true);
624 }
625
626 Bind(&if_valueisnotsmi);
627 {
628 // The {value} is a HeapObject, load its map.
629 Node* value_map = LoadMap(value);
630
631 // Load the {value}s instance type.
632 Node* value_instance_type = LoadMapInstanceType(value_map);
633
634 // Dispatch based on the instance type; we distinguish all String instance
635 // types, the HeapNumber type and everything else.
636 GotoIf(Word32Equal(value_instance_type, Int32Constant(HEAP_NUMBER_TYPE)),
637 &if_valueisheapnumber);
638 Branch(
639 Int32LessThan(value_instance_type, Int32Constant(FIRST_NONSTRING_TYPE)),
640 &if_valueisstring, &if_valueisother);
641
642 Bind(&if_valueisstring);
643 {
644 // Load the string length field of the {value}.
645 Node* value_length = LoadObjectField(value, String::kLengthOffset);
646
647 // Check if the {value} is the empty string.
648 BranchIfSmiEqual(value_length, SmiConstant(0), if_false, if_true);
649 }
650
651 Bind(&if_valueisheapnumber);
652 {
653 // Load the floating point value of {value}.
654 Node* value_value = LoadObjectField(value, HeapNumber::kValueOffset,
655 MachineType::Float64());
656
657 // Check if the floating point {value} is neither 0.0, -0.0 nor NaN.
658 Node* zero = Float64Constant(0.0);
659 GotoIf(Float64LessThan(zero, value_value), if_true);
660 BranchIfFloat64LessThan(value_value, zero, if_true, if_false);
661 }
662
663 Bind(&if_valueisother);
664 {
665 // Load the bit field from the {value}s map. The {value} is now either
666 // Null or Undefined, which have the undetectable bit set (so we always
667 // return false for those), or a Symbol or Simd128Value, whose maps never
668 // have the undetectable bit set (so we always return true for those), or
669 // a JSReceiver, which may or may not have the undetectable bit set.
670 Node* value_map_bitfield = LoadMapBitField(value_map);
671 Node* value_map_undetectable = Word32And(
672 value_map_bitfield, Int32Constant(1 << Map::kIsUndetectable));
673
674 // Check if the {value} is undetectable.
675 BranchIfWord32Equal(value_map_undetectable, Int32Constant(0), if_true,
676 if_false);
677 }
678 }
679 }
680
608 compiler::Node* CodeStubAssembler::LoadFromFrame(int offset, MachineType rep) { 681 compiler::Node* CodeStubAssembler::LoadFromFrame(int offset, MachineType rep) {
609 Node* frame_pointer = LoadFramePointer(); 682 Node* frame_pointer = LoadFramePointer();
610 return Load(rep, frame_pointer, IntPtrConstant(offset)); 683 return Load(rep, frame_pointer, IntPtrConstant(offset));
611 } 684 }
612 685
613 compiler::Node* CodeStubAssembler::LoadFromParentFrame(int offset, 686 compiler::Node* CodeStubAssembler::LoadFromParentFrame(int offset,
614 MachineType rep) { 687 MachineType rep) {
615 Node* frame_pointer = LoadParentFramePointer(); 688 Node* frame_pointer = LoadParentFramePointer();
616 return Load(rep, frame_pointer, IntPtrConstant(offset)); 689 return Load(rep, frame_pointer, IntPtrConstant(offset));
617 } 690 }
(...skipping 2441 matching lines...) Expand 10 before | Expand all | Expand 10 after
3059 } 3132 }
3060 Bind(&miss); 3133 Bind(&miss);
3061 { 3134 {
3062 TailCallRuntime(Runtime::kLoadGlobalIC_Miss, p->context, p->slot, 3135 TailCallRuntime(Runtime::kLoadGlobalIC_Miss, p->context, p->slot,
3063 p->vector); 3136 p->vector);
3064 } 3137 }
3065 } 3138 }
3066 3139
3067 } // namespace internal 3140 } // namespace internal
3068 } // namespace v8 3141 } // namespace v8
OLDNEW
« no previous file with comments | « src/code-stub-assembler.h ('k') | src/code-stubs.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698