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

Unified Diff: src/compiler/code-assembler.cc

Issue 1875583003: Separate CodeAssembler and CodeStubAssembler (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix gn build Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: src/compiler/code-assembler.cc
diff --git a/src/compiler/code-stub-assembler.cc b/src/compiler/code-assembler.cc
similarity index 53%
rename from src/compiler/code-stub-assembler.cc
rename to src/compiler/code-assembler.cc
index f50fa1a14ba028d63fd90f25ee302bbbe380a8eb..e09632779699c0733340923e83db78adf5c40cb9 100644
--- a/src/compiler/code-stub-assembler.cc
+++ b/src/compiler/code-assembler.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "src/compiler/code-stub-assembler.h"
+#include "src/compiler/code-assembler.h"
#include <ostream>
@@ -24,11 +24,11 @@ namespace v8 {
namespace internal {
namespace compiler {
-CodeStubAssembler::CodeStubAssembler(Isolate* isolate, Zone* zone,
- const CallInterfaceDescriptor& descriptor,
- Code::Flags flags, const char* name,
- size_t result_size)
- : CodeStubAssembler(
+CodeAssembler::CodeAssembler(Isolate* isolate, Zone* zone,
+ const CallInterfaceDescriptor& descriptor,
+ Code::Flags flags, const char* name,
+ size_t result_size)
+ : CodeAssembler(
isolate, zone,
Linkage::GetStubCallDescriptor(
isolate, zone, descriptor, descriptor.GetStackParameterCount(),
@@ -36,17 +36,16 @@ CodeStubAssembler::CodeStubAssembler(Isolate* isolate, Zone* zone,
MachineType::AnyTagged(), result_size),
flags, name) {}
-CodeStubAssembler::CodeStubAssembler(Isolate* isolate, Zone* zone,
- int parameter_count, Code::Flags flags,
- const char* name)
- : CodeStubAssembler(isolate, zone, Linkage::GetJSCallDescriptor(
- zone, false, parameter_count,
- CallDescriptor::kNoFlags),
- flags, name) {}
-
-CodeStubAssembler::CodeStubAssembler(Isolate* isolate, Zone* zone,
- CallDescriptor* call_descriptor,
- Code::Flags flags, const char* name)
+CodeAssembler::CodeAssembler(Isolate* isolate, Zone* zone, int parameter_count,
+ Code::Flags flags, const char* name)
+ : CodeAssembler(isolate, zone,
+ Linkage::GetJSCallDescriptor(zone, false, parameter_count,
+ CallDescriptor::kNoFlags),
+ flags, name) {}
+
+CodeAssembler::CodeAssembler(Isolate* isolate, Zone* zone,
+ CallDescriptor* call_descriptor, Code::Flags flags,
+ const char* name)
: raw_assembler_(new RawMachineAssembler(
isolate, new (zone) Graph(zone), call_descriptor,
MachineType::PointerRepresentation(),
@@ -56,13 +55,13 @@ CodeStubAssembler::CodeStubAssembler(Isolate* isolate, Zone* zone,
code_generated_(false),
variables_(zone) {}
-CodeStubAssembler::~CodeStubAssembler() {}
+CodeAssembler::~CodeAssembler() {}
-void CodeStubAssembler::CallPrologue() {}
+void CodeAssembler::CallPrologue() {}
-void CodeStubAssembler::CallEpilogue() {}
+void CodeAssembler::CallEpilogue() {}
-Handle<Code> CodeStubAssembler::GenerateCode() {
+Handle<Code> CodeAssembler::GenerateCode() {
DCHECK(!code_generated_);
Schedule* schedule = raw_assembler_->Export();
@@ -74,87 +73,83 @@ Handle<Code> CodeStubAssembler::GenerateCode() {
return code;
}
+bool CodeAssembler::Is64() { return raw_assembler_->machine()->Is64(); }
-Node* CodeStubAssembler::Int32Constant(int value) {
+Node* CodeAssembler::Int32Constant(int value) {
return raw_assembler_->Int32Constant(value);
}
-
-Node* CodeStubAssembler::IntPtrConstant(intptr_t value) {
+Node* CodeAssembler::IntPtrConstant(intptr_t value) {
return raw_assembler_->IntPtrConstant(value);
}
-
-Node* CodeStubAssembler::NumberConstant(double value) {
+Node* CodeAssembler::NumberConstant(double value) {
return raw_assembler_->NumberConstant(value);
}
-Node* CodeStubAssembler::SmiConstant(Smi* value) {
+Node* CodeAssembler::SmiConstant(Smi* value) {
return IntPtrConstant(bit_cast<intptr_t>(value));
}
-Node* CodeStubAssembler::HeapConstant(Handle<HeapObject> object) {
+Node* CodeAssembler::HeapConstant(Handle<HeapObject> object) {
return raw_assembler_->HeapConstant(object);
}
-
-Node* CodeStubAssembler::BooleanConstant(bool value) {
+Node* CodeAssembler::BooleanConstant(bool value) {
return raw_assembler_->BooleanConstant(value);
}
-Node* CodeStubAssembler::ExternalConstant(ExternalReference address) {
+Node* CodeAssembler::ExternalConstant(ExternalReference address) {
return raw_assembler_->ExternalConstant(address);
}
-Node* CodeStubAssembler::Float64Constant(double value) {
+Node* CodeAssembler::Float64Constant(double value) {
return raw_assembler_->Float64Constant(value);
}
-Node* CodeStubAssembler::BooleanMapConstant() {
+Node* CodeAssembler::BooleanMapConstant() {
return HeapConstant(isolate()->factory()->boolean_map());
}
-Node* CodeStubAssembler::HeapNumberMapConstant() {
+Node* CodeAssembler::HeapNumberMapConstant() {
return HeapConstant(isolate()->factory()->heap_number_map());
}
-Node* CodeStubAssembler::NullConstant() {
+Node* CodeAssembler::NullConstant() {
return LoadRoot(Heap::kNullValueRootIndex);
}
-Node* CodeStubAssembler::UndefinedConstant() {
+Node* CodeAssembler::UndefinedConstant() {
return LoadRoot(Heap::kUndefinedValueRootIndex);
}
-Node* CodeStubAssembler::Parameter(int value) {
+Node* CodeAssembler::Parameter(int value) {
return raw_assembler_->Parameter(value);
}
-void CodeStubAssembler::Return(Node* value) {
+void CodeAssembler::Return(Node* value) {
return raw_assembler_->Return(value);
}
-void CodeStubAssembler::Bind(CodeStubAssembler::Label* label) {
- return label->Bind();
-}
+void CodeAssembler::Bind(CodeAssembler::Label* label) { return label->Bind(); }
-Node* CodeStubAssembler::LoadFramePointer() {
+Node* CodeAssembler::LoadFramePointer() {
return raw_assembler_->LoadFramePointer();
}
-Node* CodeStubAssembler::LoadParentFramePointer() {
+Node* CodeAssembler::LoadParentFramePointer() {
return raw_assembler_->LoadParentFramePointer();
}
-Node* CodeStubAssembler::LoadStackPointer() {
+Node* CodeAssembler::LoadStackPointer() {
return raw_assembler_->LoadStackPointer();
}
-Node* CodeStubAssembler::SmiShiftBitsConstant() {
+Node* CodeAssembler::SmiShiftBitsConstant() {
return IntPtrConstant(kSmiShiftSize + kSmiTagSize);
}
-Node* CodeStubAssembler::Float64Round(Node* x) {
+Node* CodeAssembler::Float64Round(Node* x) {
Node* one = Float64Constant(1.0);
Node* one_half = Float64Constant(0.5);
@@ -173,7 +168,7 @@ Node* CodeStubAssembler::Float64Round(Node* x) {
return var_x.value();
}
-Node* CodeStubAssembler::Float64Ceil(Node* x) {
+Node* CodeAssembler::Float64Ceil(Node* x) {
if (raw_assembler_->machine()->Float64RoundUp().IsSupported()) {
return raw_assembler_->Float64RoundUp(x);
}
@@ -226,7 +221,7 @@ Node* CodeStubAssembler::Float64Ceil(Node* x) {
return var_x.value();
}
-Node* CodeStubAssembler::Float64Floor(Node* x) {
+Node* CodeAssembler::Float64Floor(Node* x) {
if (raw_assembler_->machine()->Float64RoundDown().IsSupported()) {
return raw_assembler_->Float64RoundDown(x);
}
@@ -279,7 +274,7 @@ Node* CodeStubAssembler::Float64Floor(Node* x) {
return var_x.value();
}
-Node* CodeStubAssembler::Float64Trunc(Node* x) {
+Node* CodeAssembler::Float64Trunc(Node* x) {
if (raw_assembler_->machine()->Float64RoundTruncate().IsSupported()) {
return raw_assembler_->Float64RoundTruncate(x);
}
@@ -341,189 +336,40 @@ Node* CodeStubAssembler::Float64Trunc(Node* x) {
return var_x.value();
}
-Node* CodeStubAssembler::SmiTag(Node* value) {
- return raw_assembler_->WordShl(value, SmiShiftBitsConstant());
-}
-
-Node* CodeStubAssembler::SmiUntag(Node* value) {
- return raw_assembler_->WordSar(value, SmiShiftBitsConstant());
-}
-
-Node* CodeStubAssembler::SmiToWord32(Node* value) {
- Node* result = raw_assembler_->WordSar(value, SmiShiftBitsConstant());
- if (raw_assembler_->machine()->Is64()) {
- result = raw_assembler_->TruncateInt64ToInt32(result);
- }
- return result;
-}
-
-Node* CodeStubAssembler::SmiToFloat64(Node* value) {
- return ChangeInt32ToFloat64(SmiUntag(value));
-}
-
-Node* CodeStubAssembler::SmiAdd(Node* a, Node* b) { return IntPtrAdd(a, b); }
-
-Node* CodeStubAssembler::SmiAddWithOverflow(Node* a, Node* b) {
- return IntPtrAddWithOverflow(a, b);
-}
-
-Node* CodeStubAssembler::SmiSub(Node* a, Node* b) { return IntPtrSub(a, b); }
-
-Node* CodeStubAssembler::SmiSubWithOverflow(Node* a, Node* b) {
- return IntPtrSubWithOverflow(a, b);
-}
-
-Node* CodeStubAssembler::SmiEqual(Node* a, Node* b) { return WordEqual(a, b); }
-
-Node* CodeStubAssembler::SmiLessThan(Node* a, Node* b) {
- return IntPtrLessThan(a, b);
-}
-
-Node* CodeStubAssembler::SmiLessThanOrEqual(Node* a, Node* b) {
- return IntPtrLessThanOrEqual(a, b);
-}
-
-Node* CodeStubAssembler::SmiMin(Node* a, Node* b) {
- // TODO(bmeurer): Consider using Select once available.
- Variable min(this, MachineRepresentation::kTagged);
- Label if_a(this), if_b(this), join(this);
- BranchIfSmiLessThan(a, b, &if_a, &if_b);
- Bind(&if_a);
- min.Bind(a);
- Goto(&join);
- Bind(&if_b);
- min.Bind(b);
- Goto(&join);
- Bind(&join);
- return min.value();
-}
-
-#define DEFINE_CODE_STUB_ASSEMBER_BINARY_OP(name) \
- Node* CodeStubAssembler::name(Node* a, Node* b) { \
- return raw_assembler_->name(a, b); \
+#define DEFINE_CODE_STUB_ASSEMBER_BINARY_OP(name) \
+ Node* CodeAssembler::name(Node* a, Node* b) { \
+ return raw_assembler_->name(a, b); \
}
CODE_STUB_ASSEMBLER_BINARY_OP_LIST(DEFINE_CODE_STUB_ASSEMBER_BINARY_OP)
#undef DEFINE_CODE_STUB_ASSEMBER_BINARY_OP
-Node* CodeStubAssembler::WordShl(Node* value, int shift) {
+Node* CodeAssembler::WordShl(Node* value, int shift) {
return raw_assembler_->WordShl(value, IntPtrConstant(shift));
}
-#define DEFINE_CODE_STUB_ASSEMBER_UNARY_OP(name) \
- Node* CodeStubAssembler::name(Node* a) { return raw_assembler_->name(a); }
-CODE_STUB_ASSEMBLER_UNARY_OP_LIST(DEFINE_CODE_STUB_ASSEMBER_UNARY_OP)
-#undef DEFINE_CODE_STUB_ASSEMBER_UNARY_OP
-
-Node* CodeStubAssembler::WordIsSmi(Node* a) {
- return WordEqual(raw_assembler_->WordAnd(a, IntPtrConstant(kSmiTagMask)),
- IntPtrConstant(0));
-}
-
-Node* CodeStubAssembler::WordIsPositiveSmi(Node* a) {
- return WordEqual(
- raw_assembler_->WordAnd(a, IntPtrConstant(kSmiTagMask | kSmiSignMask)),
- IntPtrConstant(0));
-}
-
-Node* CodeStubAssembler::LoadBufferObject(Node* buffer, int offset,
- MachineType rep) {
- return raw_assembler_->Load(rep, buffer, IntPtrConstant(offset));
-}
-
-Node* CodeStubAssembler::LoadObjectField(Node* object, int offset,
- MachineType rep) {
- return raw_assembler_->Load(rep, object,
- IntPtrConstant(offset - kHeapObjectTag));
+Node* CodeAssembler::TruncateFloat64ToInt32RoundToZero(Node* a) {
+ return raw_assembler_->TruncateFloat64ToInt32(TruncationMode::kRoundToZero,
+ a);
}
-Node* CodeStubAssembler::LoadHeapNumberValue(Node* object) {
- return Load(MachineType::Float64(), object,
- IntPtrConstant(HeapNumber::kValueOffset - kHeapObjectTag));
+Node* CodeAssembler::TruncateFloat64ToInt32JavaScript(Node* a) {
+ return raw_assembler_->TruncateFloat64ToInt32(TruncationMode::kJavaScript, a);
}
-Node* CodeStubAssembler::StoreHeapNumberValue(Node* object, Node* value) {
- return StoreNoWriteBarrier(
- MachineRepresentation::kFloat64, object,
- IntPtrConstant(HeapNumber::kValueOffset - kHeapObjectTag), value);
-}
-
-Node* CodeStubAssembler::TruncateHeapNumberValueToWord32(Node* object) {
- Node* value = LoadHeapNumberValue(object);
- return raw_assembler_->TruncateFloat64ToInt32(TruncationMode::kJavaScript,
- value);
-}
-
-Node* CodeStubAssembler::LoadMapBitField(Node* map) {
- return Load(MachineType::Uint8(), map,
- IntPtrConstant(Map::kBitFieldOffset - kHeapObjectTag));
-}
-
-Node* CodeStubAssembler::LoadMapBitField2(Node* map) {
- return Load(MachineType::Uint8(), map,
- IntPtrConstant(Map::kBitField2Offset - kHeapObjectTag));
-}
-
-Node* CodeStubAssembler::LoadMapBitField3(Node* map) {
- return Load(MachineType::Uint32(), map,
- IntPtrConstant(Map::kBitField3Offset - kHeapObjectTag));
-}
-
-Node* CodeStubAssembler::LoadMapInstanceType(Node* map) {
- return Load(MachineType::Uint8(), map,
- IntPtrConstant(Map::kInstanceTypeOffset - kHeapObjectTag));
-}
-
-Node* CodeStubAssembler::LoadMapDescriptors(Node* map) {
- return LoadObjectField(map, Map::kDescriptorsOffset);
-}
-
-Node* CodeStubAssembler::LoadNameHash(Node* name) {
- return Load(MachineType::Uint32(), name,
- IntPtrConstant(Name::kHashFieldOffset - kHeapObjectTag));
-}
-
-Node* CodeStubAssembler::LoadFixedArrayElementInt32Index(
- Node* object, Node* int32_index, int additional_offset) {
- Node* header_size = IntPtrConstant(additional_offset +
- FixedArray::kHeaderSize - kHeapObjectTag);
- Node* scaled_index = WordShl(int32_index, IntPtrConstant(kPointerSizeLog2));
- Node* offset = IntPtrAdd(scaled_index, header_size);
- return Load(MachineType::AnyTagged(), object, offset);
-}
-
-Node* CodeStubAssembler::LoadFixedArrayElementSmiIndex(Node* object,
- Node* smi_index,
- int additional_offset) {
- int const kSmiShiftBits = kSmiShiftSize + kSmiTagSize;
- Node* header_size = IntPtrConstant(additional_offset +
- FixedArray::kHeaderSize - kHeapObjectTag);
- Node* scaled_index =
- (kSmiShiftBits > kPointerSizeLog2)
- ? WordSar(smi_index, IntPtrConstant(kSmiShiftBits - kPointerSizeLog2))
- : WordShl(smi_index,
- IntPtrConstant(kPointerSizeLog2 - kSmiShiftBits));
- Node* offset = IntPtrAdd(scaled_index, header_size);
- return Load(MachineType::AnyTagged(), object, offset);
-}
+#define DEFINE_CODE_STUB_ASSEMBER_UNARY_OP(name) \
+ Node* CodeAssembler::name(Node* a) { return raw_assembler_->name(a); }
+CODE_STUB_ASSEMBLER_UNARY_OP_LIST(DEFINE_CODE_STUB_ASSEMBER_UNARY_OP)
+#undef DEFINE_CODE_STUB_ASSEMBER_UNARY_OP
-Node* CodeStubAssembler::LoadFixedArrayElementConstantIndex(Node* object,
- int index) {
- Node* offset = IntPtrConstant(FixedArray::kHeaderSize - kHeapObjectTag +
- index * kPointerSize);
- return raw_assembler_->Load(MachineType::AnyTagged(), object, offset);
+Node* CodeAssembler::SmiTag(Node* value) {
+ return WordShl(value, SmiShiftBitsConstant());
}
-Node* CodeStubAssembler::StoreFixedArrayElementNoWriteBarrier(Node* object,
- Node* index,
- Node* value) {
- Node* offset =
- IntPtrAdd(WordShl(index, IntPtrConstant(kPointerSizeLog2)),
- IntPtrConstant(FixedArray::kHeaderSize - kHeapObjectTag));
- return StoreNoWriteBarrier(MachineRepresentation::kTagged, object, offset,
- value);
+Node* CodeAssembler::SmiUntag(Node* value) {
+ return WordSar(value, SmiShiftBitsConstant());
}
-Node* CodeStubAssembler::LoadRoot(Heap::RootListIndex root_index) {
+Node* CodeAssembler::LoadRoot(Heap::RootListIndex root_index) {
if (isolate()->heap()->RootCanBeTreatedAsConstant(root_index)) {
Handle<Object> root = isolate()->heap()->root_handle(root_index);
if (root->IsSmi()) {
@@ -543,10 +389,10 @@ Node* CodeStubAssembler::LoadRoot(Heap::RootListIndex root_index) {
return nullptr;
}
-Node* CodeStubAssembler::AllocateRawUnaligned(Node* size_in_bytes,
- AllocationFlags flags,
- Node* top_address,
- Node* limit_address) {
+Node* CodeAssembler::AllocateRawUnaligned(Node* size_in_bytes,
+ AllocationFlags flags,
+ Node* top_address,
+ Node* limit_address) {
Node* top = Load(MachineType::Pointer(), top_address);
Node* limit = Load(MachineType::Pointer(), limit_address);
@@ -583,10 +429,10 @@ Node* CodeStubAssembler::AllocateRawUnaligned(Node* size_in_bytes,
runtime_result, no_runtime_result);
}
-Node* CodeStubAssembler::AllocateRawAligned(Node* size_in_bytes,
- AllocationFlags flags,
- Node* top_address,
- Node* limit_address) {
+Node* CodeAssembler::AllocateRawAligned(Node* size_in_bytes,
+ AllocationFlags flags,
+ Node* top_address,
+ Node* limit_address) {
Node* top = Load(MachineType::Pointer(), top_address);
Node* limit = Load(MachineType::Pointer(), limit_address);
Node* adjusted_size = size_in_bytes;
@@ -638,7 +484,7 @@ Node* CodeStubAssembler::AllocateRawAligned(Node* size_in_bytes,
return address;
}
-Node* CodeStubAssembler::Allocate(int size_in_bytes, AllocationFlags flags) {
+Node* CodeAssembler::Allocate(int size_in_bytes, AllocationFlags flags) {
bool const new_space = !(flags & kPretenured);
Node* top_address = ExternalConstant(
new_space
@@ -660,269 +506,34 @@ Node* CodeStubAssembler::Allocate(int size_in_bytes, AllocationFlags flags) {
limit_address);
}
-Node* CodeStubAssembler::AllocateHeapNumber() {
- Node* result = Allocate(HeapNumber::kSize, kNone);
- StoreMapNoWriteBarrier(result, HeapNumberMapConstant());
- return result;
-}
-
-Node* CodeStubAssembler::AllocateHeapNumberWithValue(Node* value) {
- Node* result = AllocateHeapNumber();
- StoreHeapNumberValue(result, value);
- return result;
-}
-
-Node* CodeStubAssembler::Load(MachineType rep, Node* base) {
+Node* CodeAssembler::Load(MachineType rep, Node* base) {
return raw_assembler_->Load(rep, base);
}
-Node* CodeStubAssembler::Load(MachineType rep, Node* base, Node* index) {
+Node* CodeAssembler::Load(MachineType rep, Node* base, Node* index) {
return raw_assembler_->Load(rep, base, index);
}
-Node* CodeStubAssembler::Store(MachineRepresentation rep, Node* base,
- Node* value) {
+Node* CodeAssembler::Store(MachineRepresentation rep, Node* base, Node* value) {
return raw_assembler_->Store(rep, base, value, kFullWriteBarrier);
}
-Node* CodeStubAssembler::Store(MachineRepresentation rep, Node* base,
- Node* index, Node* value) {
+Node* CodeAssembler::Store(MachineRepresentation rep, Node* base, Node* index,
+ Node* value) {
return raw_assembler_->Store(rep, base, index, value, kFullWriteBarrier);
}
-Node* CodeStubAssembler::StoreNoWriteBarrier(MachineRepresentation rep,
- Node* base, Node* value) {
+Node* CodeAssembler::StoreNoWriteBarrier(MachineRepresentation rep, Node* base,
+ Node* value) {
return raw_assembler_->Store(rep, base, value, kNoWriteBarrier);
}
-Node* CodeStubAssembler::StoreNoWriteBarrier(MachineRepresentation rep,
- Node* base, Node* index,
- Node* value) {
+Node* CodeAssembler::StoreNoWriteBarrier(MachineRepresentation rep, Node* base,
+ Node* index, Node* value) {
return raw_assembler_->Store(rep, base, index, value, kNoWriteBarrier);
}
-Node* CodeStubAssembler::Projection(int index, Node* value) {
- return raw_assembler_->Projection(index, value);
-}
-
-Node* CodeStubAssembler::LoadMap(Node* object) {
- return LoadObjectField(object, HeapObject::kMapOffset);
-}
-
-Node* CodeStubAssembler::StoreMapNoWriteBarrier(Node* object, Node* map) {
- return StoreNoWriteBarrier(
- MachineRepresentation::kTagged, object,
- IntPtrConstant(HeapNumber::kMapOffset - kHeapObjectTag), map);
-}
-
-Node* CodeStubAssembler::LoadInstanceType(Node* object) {
- return LoadMapInstanceType(LoadMap(object));
-}
-
-Node* CodeStubAssembler::LoadElements(Node* object) {
- return LoadObjectField(object, JSObject::kElementsOffset);
-}
-
-Node* CodeStubAssembler::LoadFixedArrayBaseLength(Node* array) {
- return LoadObjectField(array, FixedArrayBase::kLengthOffset);
-}
-
-Node* CodeStubAssembler::BitFieldDecode(Node* word32, uint32_t shift,
- uint32_t mask) {
- return raw_assembler_->Word32Shr(
- raw_assembler_->Word32And(word32, raw_assembler_->Int32Constant(mask)),
- raw_assembler_->Int32Constant(shift));
-}
-
-Node* CodeStubAssembler::ChangeFloat64ToTagged(Node* value) {
- Node* value32 = raw_assembler_->TruncateFloat64ToInt32(
- TruncationMode::kRoundToZero, value);
- Node* value64 = ChangeInt32ToFloat64(value32);
-
- Label if_valueisint32(this), if_valueisheapnumber(this), if_join(this);
-
- Label if_valueisequal(this), if_valueisnotequal(this);
- Branch(Float64Equal(value, value64), &if_valueisequal, &if_valueisnotequal);
- Bind(&if_valueisequal);
- {
- Label if_valueiszero(this), if_valueisnotzero(this);
- Branch(Float64Equal(value, Float64Constant(0.0)), &if_valueiszero,
- &if_valueisnotzero);
-
- Bind(&if_valueiszero);
- BranchIfInt32LessThan(raw_assembler_->Float64ExtractHighWord32(value),
- Int32Constant(0), &if_valueisheapnumber,
- &if_valueisint32);
-
- Bind(&if_valueisnotzero);
- Goto(&if_valueisint32);
- }
- Bind(&if_valueisnotequal);
- Goto(&if_valueisheapnumber);
-
- Variable var_result(this, MachineRepresentation::kTagged);
- Bind(&if_valueisint32);
- {
- if (raw_assembler_->machine()->Is64()) {
- Node* result = SmiTag(ChangeInt32ToInt64(value32));
- var_result.Bind(result);
- Goto(&if_join);
- } else {
- Node* pair = Int32AddWithOverflow(value32, value32);
- Node* overflow = Projection(1, pair);
- Label if_overflow(this, Label::kDeferred), if_notoverflow(this);
- Branch(overflow, &if_overflow, &if_notoverflow);
- Bind(&if_overflow);
- Goto(&if_valueisheapnumber);
- Bind(&if_notoverflow);
- {
- Node* result = Projection(0, pair);
- var_result.Bind(result);
- Goto(&if_join);
- }
- }
- }
- Bind(&if_valueisheapnumber);
- {
- Node* result = AllocateHeapNumberWithValue(value);
- var_result.Bind(result);
- Goto(&if_join);
- }
- Bind(&if_join);
- return var_result.value();
-}
-
-Node* CodeStubAssembler::ChangeInt32ToTagged(Node* value) {
- if (raw_assembler_->machine()->Is64()) {
- return SmiTag(ChangeInt32ToInt64(value));
- }
- Variable var_result(this, MachineRepresentation::kTagged);
- Node* pair = Int32AddWithOverflow(value, value);
- Node* overflow = Projection(1, pair);
- Label if_overflow(this, Label::kDeferred), if_notoverflow(this),
- if_join(this);
- Branch(overflow, &if_overflow, &if_notoverflow);
- Bind(&if_overflow);
- {
- Node* value64 = ChangeInt32ToFloat64(value);
- Node* result = AllocateHeapNumberWithValue(value64);
- var_result.Bind(result);
- }
- Goto(&if_join);
- Bind(&if_notoverflow);
- {
- Node* result = Projection(0, pair);
- var_result.Bind(result);
- }
- Goto(&if_join);
- Bind(&if_join);
- return var_result.value();
-}
-
-Node* CodeStubAssembler::TruncateTaggedToFloat64(Node* context, Node* value) {
- // We might need to loop once due to ToNumber conversion.
- Variable var_value(this, MachineRepresentation::kTagged),
- var_result(this, MachineRepresentation::kFloat64);
- Label loop(this, &var_value), done_loop(this, &var_result);
- var_value.Bind(value);
- Goto(&loop);
- Bind(&loop);
- {
- // Load the current {value}.
- value = var_value.value();
-
- // Check if the {value} is a Smi or a HeapObject.
- Label if_valueissmi(this), if_valueisnotsmi(this);
- Branch(WordIsSmi(value), &if_valueissmi, &if_valueisnotsmi);
-
- Bind(&if_valueissmi);
- {
- // Convert the Smi {value}.
- var_result.Bind(SmiToFloat64(value));
- Goto(&done_loop);
- }
-
- Bind(&if_valueisnotsmi);
- {
- // Check if {value} is a HeapNumber.
- Label if_valueisheapnumber(this),
- if_valueisnotheapnumber(this, Label::kDeferred);
- Branch(WordEqual(LoadMap(value), HeapNumberMapConstant()),
- &if_valueisheapnumber, &if_valueisnotheapnumber);
-
- Bind(&if_valueisheapnumber);
- {
- // Load the floating point value.
- var_result.Bind(LoadHeapNumberValue(value));
- Goto(&done_loop);
- }
-
- Bind(&if_valueisnotheapnumber);
- {
- // Convert the {value} to a Number first.
- Callable callable = CodeFactory::NonNumberToNumber(isolate());
- var_value.Bind(CallStub(callable, context, value));
- Goto(&loop);
- }
- }
- }
- Bind(&done_loop);
- return var_result.value();
-}
-
-Node* CodeStubAssembler::TruncateTaggedToWord32(Node* context, Node* value) {
- // We might need to loop once due to ToNumber conversion.
- Variable var_value(this, MachineRepresentation::kTagged),
- var_result(this, MachineRepresentation::kWord32);
- Label loop(this, &var_value), done_loop(this, &var_result);
- var_value.Bind(value);
- Goto(&loop);
- Bind(&loop);
- {
- // Load the current {value}.
- value = var_value.value();
-
- // Check if the {value} is a Smi or a HeapObject.
- Label if_valueissmi(this), if_valueisnotsmi(this);
- Branch(WordIsSmi(value), &if_valueissmi, &if_valueisnotsmi);
-
- Bind(&if_valueissmi);
- {
- // Convert the Smi {value}.
- var_result.Bind(SmiToWord32(value));
- Goto(&done_loop);
- }
-
- Bind(&if_valueisnotsmi);
- {
- // Check if {value} is a HeapNumber.
- Label if_valueisheapnumber(this),
- if_valueisnotheapnumber(this, Label::kDeferred);
- Branch(WordEqual(LoadMap(value), HeapNumberMapConstant()),
- &if_valueisheapnumber, &if_valueisnotheapnumber);
-
- Bind(&if_valueisheapnumber);
- {
- // Truncate the floating point value.
- var_result.Bind(TruncateHeapNumberValueToWord32(value));
- Goto(&done_loop);
- }
-
- Bind(&if_valueisnotheapnumber);
- {
- // Convert the {value} to a Number first.
- Callable callable = CodeFactory::NonNumberToNumber(isolate());
- var_value.Bind(CallStub(callable, context, value));
- Goto(&loop);
- }
- }
- }
- Bind(&done_loop);
- return var_result.value();
-}
-
-void CodeStubAssembler::BranchIf(Node* condition, Label* if_true,
- Label* if_false) {
+void CodeAssembler::BranchIf(Node* condition, Label* if_true, Label* if_false) {
Label if_condition_is_true(this), if_condition_is_false(this);
Branch(condition, &if_condition_is_true, &if_condition_is_false);
Bind(&if_condition_is_true);
@@ -931,38 +542,41 @@ void CodeStubAssembler::BranchIf(Node* condition, Label* if_true,
Goto(if_false);
}
-Node* CodeStubAssembler::CallN(CallDescriptor* descriptor, Node* code_target,
- Node** args) {
+Node* CodeAssembler::Projection(int index, Node* value) {
+ return raw_assembler_->Projection(index, value);
+}
+
+Node* CodeAssembler::CallN(CallDescriptor* descriptor, Node* code_target,
+ Node** args) {
CallPrologue();
Node* return_value = raw_assembler_->CallN(descriptor, code_target, args);
CallEpilogue();
return return_value;
}
-
-Node* CodeStubAssembler::TailCallN(CallDescriptor* descriptor,
- Node* code_target, Node** args) {
+Node* CodeAssembler::TailCallN(CallDescriptor* descriptor, Node* code_target,
+ Node** args) {
return raw_assembler_->TailCallN(descriptor, code_target, args);
}
-Node* CodeStubAssembler::CallRuntime(Runtime::FunctionId function_id,
- Node* context) {
+Node* CodeAssembler::CallRuntime(Runtime::FunctionId function_id,
+ Node* context) {
CallPrologue();
Node* return_value = raw_assembler_->CallRuntime0(function_id, context);
CallEpilogue();
return return_value;
}
-Node* CodeStubAssembler::CallRuntime(Runtime::FunctionId function_id,
- Node* context, Node* arg1) {
+Node* CodeAssembler::CallRuntime(Runtime::FunctionId function_id, Node* context,
+ Node* arg1) {
CallPrologue();
Node* return_value = raw_assembler_->CallRuntime1(function_id, arg1, context);
CallEpilogue();
return return_value;
}
-Node* CodeStubAssembler::CallRuntime(Runtime::FunctionId function_id,
- Node* context, Node* arg1, Node* arg2) {
+Node* CodeAssembler::CallRuntime(Runtime::FunctionId function_id, Node* context,
+ Node* arg1, Node* arg2) {
CallPrologue();
Node* return_value =
raw_assembler_->CallRuntime2(function_id, arg1, arg2, context);
@@ -970,9 +584,8 @@ Node* CodeStubAssembler::CallRuntime(Runtime::FunctionId function_id,
return return_value;
}
-Node* CodeStubAssembler::CallRuntime(Runtime::FunctionId function_id,
- Node* context, Node* arg1, Node* arg2,
- Node* arg3) {
+Node* CodeAssembler::CallRuntime(Runtime::FunctionId function_id, Node* context,
+ Node* arg1, Node* arg2, Node* arg3) {
CallPrologue();
Node* return_value =
raw_assembler_->CallRuntime3(function_id, arg1, arg2, arg3, context);
@@ -980,9 +593,9 @@ Node* CodeStubAssembler::CallRuntime(Runtime::FunctionId function_id,
return return_value;
}
-Node* CodeStubAssembler::CallRuntime(Runtime::FunctionId function_id,
- Node* context, Node* arg1, Node* arg2,
- Node* arg3, Node* arg4) {
+Node* CodeAssembler::CallRuntime(Runtime::FunctionId function_id, Node* context,
+ Node* arg1, Node* arg2, Node* arg3,
+ Node* arg4) {
CallPrologue();
Node* return_value = raw_assembler_->CallRuntime4(function_id, arg1, arg2,
arg3, arg4, context);
@@ -990,60 +603,59 @@ Node* CodeStubAssembler::CallRuntime(Runtime::FunctionId function_id,
return return_value;
}
-Node* CodeStubAssembler::TailCallRuntime(Runtime::FunctionId function_id,
- Node* context) {
+Node* CodeAssembler::TailCallRuntime(Runtime::FunctionId function_id,
+ Node* context) {
return raw_assembler_->TailCallRuntime0(function_id, context);
}
-Node* CodeStubAssembler::TailCallRuntime(Runtime::FunctionId function_id,
- Node* context, Node* arg1) {
+Node* CodeAssembler::TailCallRuntime(Runtime::FunctionId function_id,
+ Node* context, Node* arg1) {
return raw_assembler_->TailCallRuntime1(function_id, arg1, context);
}
-Node* CodeStubAssembler::TailCallRuntime(Runtime::FunctionId function_id,
- Node* context, Node* arg1,
- Node* arg2) {
+Node* CodeAssembler::TailCallRuntime(Runtime::FunctionId function_id,
+ Node* context, Node* arg1, Node* arg2) {
return raw_assembler_->TailCallRuntime2(function_id, arg1, arg2, context);
}
-Node* CodeStubAssembler::TailCallRuntime(Runtime::FunctionId function_id,
- Node* context, Node* arg1, Node* arg2,
- Node* arg3) {
+Node* CodeAssembler::TailCallRuntime(Runtime::FunctionId function_id,
+ Node* context, Node* arg1, Node* arg2,
+ Node* arg3) {
return raw_assembler_->TailCallRuntime3(function_id, arg1, arg2, arg3,
context);
}
-Node* CodeStubAssembler::TailCallRuntime(Runtime::FunctionId function_id,
- Node* context, Node* arg1, Node* arg2,
- Node* arg3, Node* arg4) {
+Node* CodeAssembler::TailCallRuntime(Runtime::FunctionId function_id,
+ Node* context, Node* arg1, Node* arg2,
+ Node* arg3, Node* arg4) {
return raw_assembler_->TailCallRuntime4(function_id, arg1, arg2, arg3, arg4,
context);
}
-Node* CodeStubAssembler::CallStub(Callable const& callable, Node* context,
- Node* arg1, size_t result_size) {
+Node* CodeAssembler::CallStub(Callable const& callable, Node* context,
+ Node* arg1, size_t result_size) {
Node* target = HeapConstant(callable.code());
return CallStub(callable.descriptor(), target, context, arg1, result_size);
}
-Node* CodeStubAssembler::CallStub(Callable const& callable, Node* context,
- Node* arg1, Node* arg2, size_t result_size) {
+Node* CodeAssembler::CallStub(Callable const& callable, Node* context,
+ Node* arg1, Node* arg2, size_t result_size) {
Node* target = HeapConstant(callable.code());
return CallStub(callable.descriptor(), target, context, arg1, arg2,
result_size);
}
-Node* CodeStubAssembler::CallStub(Callable const& callable, Node* context,
- Node* arg1, Node* arg2, Node* arg3,
- size_t result_size) {
+Node* CodeAssembler::CallStub(Callable const& callable, Node* context,
+ Node* arg1, Node* arg2, Node* arg3,
+ size_t result_size) {
Node* target = HeapConstant(callable.code());
return CallStub(callable.descriptor(), target, context, arg1, arg2, arg3,
result_size);
}
-Node* CodeStubAssembler::CallStub(const CallInterfaceDescriptor& descriptor,
- Node* target, Node* context, Node* arg1,
- size_t result_size) {
+Node* CodeAssembler::CallStub(const CallInterfaceDescriptor& descriptor,
+ Node* target, Node* context, Node* arg1,
+ size_t result_size) {
CallDescriptor* call_descriptor = Linkage::GetStubCallDescriptor(
isolate(), zone(), descriptor, descriptor.GetStackParameterCount(),
CallDescriptor::kNoFlags, Operator::kNoProperties,
@@ -1056,9 +668,9 @@ Node* CodeStubAssembler::CallStub(const CallInterfaceDescriptor& descriptor,
return CallN(call_descriptor, target, args);
}
-Node* CodeStubAssembler::CallStub(const CallInterfaceDescriptor& descriptor,
- Node* target, Node* context, Node* arg1,
- Node* arg2, size_t result_size) {
+Node* CodeAssembler::CallStub(const CallInterfaceDescriptor& descriptor,
+ Node* target, Node* context, Node* arg1,
+ Node* arg2, size_t result_size) {
CallDescriptor* call_descriptor = Linkage::GetStubCallDescriptor(
isolate(), zone(), descriptor, descriptor.GetStackParameterCount(),
CallDescriptor::kNoFlags, Operator::kNoProperties,
@@ -1072,9 +684,9 @@ Node* CodeStubAssembler::CallStub(const CallInterfaceDescriptor& descriptor,
return CallN(call_descriptor, target, args);
}
-Node* CodeStubAssembler::CallStub(const CallInterfaceDescriptor& descriptor,
- Node* target, Node* context, Node* arg1,
- Node* arg2, Node* arg3, size_t result_size) {
+Node* CodeAssembler::CallStub(const CallInterfaceDescriptor& descriptor,
+ Node* target, Node* context, Node* arg1,
+ Node* arg2, Node* arg3, size_t result_size) {
CallDescriptor* call_descriptor = Linkage::GetStubCallDescriptor(
isolate(), zone(), descriptor, descriptor.GetStackParameterCount(),
CallDescriptor::kNoFlags, Operator::kNoProperties,
@@ -1089,10 +701,10 @@ Node* CodeStubAssembler::CallStub(const CallInterfaceDescriptor& descriptor,
return CallN(call_descriptor, target, args);
}
-Node* CodeStubAssembler::CallStub(const CallInterfaceDescriptor& descriptor,
- Node* target, Node* context, Node* arg1,
- Node* arg2, Node* arg3, Node* arg4,
- size_t result_size) {
+Node* CodeAssembler::CallStub(const CallInterfaceDescriptor& descriptor,
+ Node* target, Node* context, Node* arg1,
+ Node* arg2, Node* arg3, Node* arg4,
+ size_t result_size) {
CallDescriptor* call_descriptor = Linkage::GetStubCallDescriptor(
isolate(), zone(), descriptor, descriptor.GetStackParameterCount(),
CallDescriptor::kNoFlags, Operator::kNoProperties,
@@ -1108,10 +720,10 @@ Node* CodeStubAssembler::CallStub(const CallInterfaceDescriptor& descriptor,
return CallN(call_descriptor, target, args);
}
-Node* CodeStubAssembler::CallStub(const CallInterfaceDescriptor& descriptor,
- Node* target, Node* context, Node* arg1,
- Node* arg2, Node* arg3, Node* arg4,
- Node* arg5, size_t result_size) {
+Node* CodeAssembler::CallStub(const CallInterfaceDescriptor& descriptor,
+ Node* target, Node* context, Node* arg1,
+ Node* arg2, Node* arg3, Node* arg4, Node* arg5,
+ size_t result_size) {
CallDescriptor* call_descriptor = Linkage::GetStubCallDescriptor(
isolate(), zone(), descriptor, descriptor.GetStackParameterCount(),
CallDescriptor::kNoFlags, Operator::kNoProperties,
@@ -1128,17 +740,16 @@ Node* CodeStubAssembler::CallStub(const CallInterfaceDescriptor& descriptor,
return CallN(call_descriptor, target, args);
}
-Node* CodeStubAssembler::TailCallStub(Callable const& callable, Node* context,
- Node* arg1, Node* arg2,
- size_t result_size) {
+Node* CodeAssembler::TailCallStub(Callable const& callable, Node* context,
+ Node* arg1, Node* arg2, size_t result_size) {
Node* target = HeapConstant(callable.code());
return TailCallStub(callable.descriptor(), target, context, arg1, arg2,
result_size);
}
-Node* CodeStubAssembler::TailCallStub(const CallInterfaceDescriptor& descriptor,
- Node* target, Node* context, Node* arg1,
- Node* arg2, size_t result_size) {
+Node* CodeAssembler::TailCallStub(const CallInterfaceDescriptor& descriptor,
+ Node* target, Node* context, Node* arg1,
+ Node* arg2, size_t result_size) {
CallDescriptor* call_descriptor = Linkage::GetStubCallDescriptor(
isolate(), zone(), descriptor, descriptor.GetStackParameterCount(),
CallDescriptor::kSupportsTailCalls, Operator::kNoProperties,
@@ -1152,7 +763,7 @@ Node* CodeStubAssembler::TailCallStub(const CallInterfaceDescriptor& descriptor,
return raw_assembler_->TailCallN(call_descriptor, target, args);
}
-Node* CodeStubAssembler::TailCall(
+Node* CodeAssembler::TailCall(
const CallInterfaceDescriptor& interface_descriptor, Node* code_target,
Node** args, size_t result_size) {
CallDescriptor* descriptor = Linkage::GetStubCallDescriptor(
@@ -1163,35 +774,34 @@ Node* CodeStubAssembler::TailCall(
return raw_assembler_->TailCallN(descriptor, code_target, args);
}
-void CodeStubAssembler::Goto(CodeStubAssembler::Label* label) {
+void CodeAssembler::Goto(CodeAssembler::Label* label) {
label->MergeVariables();
raw_assembler_->Goto(label->label_);
}
-void CodeStubAssembler::GotoIf(Node* condition, Label* true_label) {
+void CodeAssembler::GotoIf(Node* condition, Label* true_label) {
Label false_label(this);
Branch(condition, true_label, &false_label);
Bind(&false_label);
}
-void CodeStubAssembler::GotoUnless(Node* condition, Label* false_label) {
+void CodeAssembler::GotoUnless(Node* condition, Label* false_label) {
Label true_label(this);
Branch(condition, &true_label, false_label);
Bind(&true_label);
}
-void CodeStubAssembler::Branch(Node* condition,
- CodeStubAssembler::Label* true_label,
- CodeStubAssembler::Label* false_label) {
+void CodeAssembler::Branch(Node* condition, CodeAssembler::Label* true_label,
+ CodeAssembler::Label* false_label) {
true_label->MergeVariables();
false_label->MergeVariables();
return raw_assembler_->Branch(condition, true_label->label_,
false_label->label_);
}
-void CodeStubAssembler::Switch(Node* index, Label* default_label,
- int32_t* case_values, Label** case_labels,
- size_t case_count) {
+void CodeAssembler::Switch(Node* index, Label* default_label,
+ int32_t* case_values, Label** case_labels,
+ size_t case_count) {
RawMachineLabel** labels =
new (zone()->New(sizeof(RawMachineLabel*) * case_count))
RawMachineLabel*[case_count];
@@ -1205,52 +815,49 @@ void CodeStubAssembler::Switch(Node* index, Label* default_label,
}
// RawMachineAssembler delegate helpers:
-Isolate* CodeStubAssembler::isolate() const {
- return raw_assembler_->isolate();
-}
+Isolate* CodeAssembler::isolate() const { return raw_assembler_->isolate(); }
-Factory* CodeStubAssembler::factory() const { return isolate()->factory(); }
+Factory* CodeAssembler::factory() const { return isolate()->factory(); }
-Graph* CodeStubAssembler::graph() const { return raw_assembler_->graph(); }
+Graph* CodeAssembler::graph() const { return raw_assembler_->graph(); }
-Zone* CodeStubAssembler::zone() const { return raw_assembler_->zone(); }
+Zone* CodeAssembler::zone() const { return raw_assembler_->zone(); }
// The core implementation of Variable is stored through an indirection so
// that it can outlive the often block-scoped Variable declarations. This is
// needed to ensure that variable binding and merging through phis can
// properly be verified.
-class CodeStubAssembler::Variable::Impl : public ZoneObject {
+class CodeAssembler::Variable::Impl : public ZoneObject {
public:
explicit Impl(MachineRepresentation rep) : value_(nullptr), rep_(rep) {}
Node* value_;
MachineRepresentation rep_;
};
-CodeStubAssembler::Variable::Variable(CodeStubAssembler* assembler,
- MachineRepresentation rep)
+CodeAssembler::Variable::Variable(CodeAssembler* assembler,
+ MachineRepresentation rep)
: impl_(new (assembler->zone()) Impl(rep)) {
assembler->variables_.push_back(impl_);
}
-void CodeStubAssembler::Variable::Bind(Node* value) { impl_->value_ = value; }
+void CodeAssembler::Variable::Bind(Node* value) { impl_->value_ = value; }
-Node* CodeStubAssembler::Variable::value() const {
+Node* CodeAssembler::Variable::value() const {
DCHECK_NOT_NULL(impl_->value_);
return impl_->value_;
}
-MachineRepresentation CodeStubAssembler::Variable::rep() const {
+MachineRepresentation CodeAssembler::Variable::rep() const {
return impl_->rep_;
}
-bool CodeStubAssembler::Variable::IsBound() const {
+bool CodeAssembler::Variable::IsBound() const {
return impl_->value_ != nullptr;
}
-CodeStubAssembler::Label::Label(CodeStubAssembler* assembler,
- int merged_value_count,
- CodeStubAssembler::Variable** merged_variables,
- CodeStubAssembler::Label::Type type)
+CodeAssembler::Label::Label(CodeAssembler* assembler, int merged_value_count,
+ CodeAssembler::Variable** merged_variables,
+ CodeAssembler::Label::Type type)
: bound_(false), merge_count_(0), assembler_(assembler), label_(nullptr) {
void* buffer = assembler->zone()->New(sizeof(RawMachineLabel));
label_ = new (buffer)
@@ -1261,7 +868,7 @@ CodeStubAssembler::Label::Label(CodeStubAssembler* assembler,
}
}
-void CodeStubAssembler::Label::MergeVariables() {
+void CodeAssembler::Label::MergeVariables() {
++merge_count_;
for (auto var : assembler_->variables_) {
size_t count = 0;
@@ -1307,7 +914,7 @@ void CodeStubAssembler::Label::MergeVariables() {
}
}
-void CodeStubAssembler::Label::Bind() {
+void CodeAssembler::Label::Bind() {
DCHECK(!bound_);
assembler_->raw_assembler_->Bind(label_);
@@ -1331,7 +938,7 @@ void CodeStubAssembler::Label::Bind() {
}
for (auto var : variable_phis_) {
- CodeStubAssembler::Variable::Impl* var_impl = var.first;
+ CodeAssembler::Variable::Impl* var_impl = var.first;
auto i = variable_merges_.find(var_impl);
// If the following assert fires, then a variable that has been marked as
// being merged at the label--either by explicitly marking it so in the

Powered by Google App Engine
This is Rietveld 408576698