Index: src/compiler/code-stub-assembler.cc |
diff --git a/src/compiler/code-stub-assembler.cc b/src/compiler/code-stub-assembler.cc |
index 702b12ad127776cfd0b59cd6ecaf2e5a1e74b580..08d86914dd4abba9a91116b83a1dfe2babf72922 100644 |
--- a/src/compiler/code-stub-assembler.cc |
+++ b/src/compiler/code-stub-assembler.cc |
@@ -24,7 +24,6 @@ namespace v8 { |
namespace internal { |
namespace compiler { |
- |
CodeStubAssembler::CodeStubAssembler(Isolate* isolate, Zone* zone, |
const CallInterfaceDescriptor& descriptor, |
Code::Flags flags, const char* name) |
@@ -34,10 +33,30 @@ CodeStubAssembler::CodeStubAssembler(Isolate* isolate, Zone* zone, |
CallDescriptor::kNoFlags))), |
flags_(flags), |
name_(name), |
- code_generated_(false) {} |
+ code_generated_(false), |
+ linkage_type_(LinkageDescriptorType::kStubCall), |
+ parameter_count_(descriptor.GetParameterCount()) {} |
-CodeStubAssembler::~CodeStubAssembler() {} |
+CodeStubAssembler::CodeStubAssembler(Isolate* isolate, Zone* zone, |
+ int parameter_count, Code::Flags flags, |
+ const char* name) |
+ : raw_assembler_(new RawMachineAssembler( |
+ isolate, new (zone) Graph(zone), |
+ Linkage::GetJSCallDescriptor(zone, false, parameter_count, |
+ CallDescriptor::kNoFlags))), |
+ flags_(flags), |
+ name_(name), |
+ code_generated_(false), |
+ linkage_type_(LinkageDescriptorType::kJSCall), |
+ parameter_count_(parameter_count) {} |
+ |
+ |
+CodeStubAssembler::~CodeStubAssembler() { |
+ for (auto label : labels_) { |
+ delete label; |
Jarin
2016/02/08 10:25:04
We don't normally do new/delete dances and use zon
|
+ } |
+} |
Handle<Code> CodeStubAssembler::GenerateCode() { |
@@ -73,18 +92,28 @@ Node* CodeStubAssembler::HeapConstant(Handle<HeapObject> object) { |
} |
+Node* CodeStubAssembler::UndefinedConstant() { |
+ return raw_assembler_->UndefinedConstant(); |
+} |
+ |
+ |
Node* CodeStubAssembler::BooleanConstant(bool value) { |
return raw_assembler_->BooleanConstant(value); |
} |
-Node* CodeStubAssembler::Parameter(int value) { |
- return raw_assembler_->Parameter(value); |
+Node* CodeStubAssembler::Load(MachineType type, Node* base) { |
+ return raw_assembler_->Load(type, base); |
} |
-void CodeStubAssembler::Return(Node* value) { |
- return raw_assembler_->Return(value); |
+Node* CodeStubAssembler::Load(MachineType type, Node* base, Node* index) { |
+ return raw_assembler_->Load(type, base, index); |
+} |
+ |
+ |
+Node* CodeStubAssembler::Parameter(int value) { |
+ return raw_assembler_->Parameter(value); |
} |
@@ -118,12 +147,72 @@ Node* CodeStubAssembler::WordShl(Node* value, int shift) { |
} |
+Node* CodeStubAssembler::WordEqual(Node* a, Node* b) { |
+ return raw_assembler_->WordEqual(a, b); |
+} |
+ |
+ |
+Node* CodeStubAssembler::WordOr(Node* a, Node* b) { |
+ return raw_assembler_->WordOr(a, b); |
+} |
+ |
+ |
+Node* CodeStubAssembler::WordAnd(Node* a, Node* b) { |
+ return raw_assembler_->WordAnd(a, b); |
+} |
+ |
+ |
+Node* CodeStubAssembler::Int32GreaterThanOrEqual(Node* a, Node* b) { |
+ return raw_assembler_->Int32GreaterThanOrEqual(a, b); |
+} |
+ |
+ |
+Node* CodeStubAssembler::Int32LessThan(Node* a, Node* b) { |
+ return raw_assembler_->Int32LessThan(a, b); |
+} |
+ |
+ |
Node* CodeStubAssembler::LoadObjectField(Node* object, int offset) { |
return raw_assembler_->Load(MachineType::AnyTagged(), object, |
IntPtrConstant(offset - kHeapObjectTag)); |
} |
+Node* CodeStubAssembler::IsHeapObject(Node* object) { |
+ RawMachineAssembler* rma = raw_assembler_.get(); |
+ return rma->WordEqual( |
+ rma->WordAnd(object, rma->IntPtrConstant(kHeapObjectTagMask)), |
+ rma->IntPtrConstant(kHeapObjectTag)); |
+} |
+ |
+ |
+Node* CodeStubAssembler::InstanceType(Node* object) { |
+ return raw_assembler_->WordAnd( |
+ LoadObjectField(LoadObjectField(object, HeapObject::kMapOffset), |
+ Map::kInstanceTypeOffset), |
+ raw_assembler_->Int32Constant(255)); |
+} |
+ |
+ |
+Node* CodeStubAssembler::BitFieldValue(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::Context() { |
+ switch (linkage_type_) { |
+ case LinkageDescriptorType::kStubCall: |
+ return Parameter(Linkage::GetStubCallContextParamIndex(parameter_count_)); |
+ |
+ case LinkageDescriptorType::kJSCall: |
+ return Parameter(Linkage::GetJSCallContextParamIndex(parameter_count_)); |
+ } |
+} |
+ |
+ |
Node* CodeStubAssembler::CallN(CallDescriptor* descriptor, Node* code_target, |
Node** args) { |
return raw_assembler_->CallN(descriptor, code_target, args); |
@@ -137,27 +226,64 @@ Node* CodeStubAssembler::TailCallN(CallDescriptor* descriptor, |
Node* CodeStubAssembler::CallRuntime(Runtime::FunctionId function_id, |
- Node* context, Node* arg1) { |
- return raw_assembler_->CallRuntime1(function_id, arg1, context); |
+ Node* arg1) { |
+ return raw_assembler_->CallRuntime1(function_id, arg1, Context()); |
} |
Node* CodeStubAssembler::CallRuntime(Runtime::FunctionId function_id, |
- Node* context, Node* arg1, Node* arg2) { |
- return raw_assembler_->CallRuntime2(function_id, arg1, arg2, context); |
+ Node* arg1, Node* arg2) { |
+ return raw_assembler_->CallRuntime2(function_id, arg1, arg2, Context()); |
} |
Node* CodeStubAssembler::TailCallRuntime(Runtime::FunctionId function_id, |
- Node* context, Node* arg1) { |
- return raw_assembler_->TailCallRuntime1(function_id, arg1, context); |
+ Node* arg1) { |
+ return raw_assembler_->TailCallRuntime1(function_id, arg1, Context()); |
} |
Node* CodeStubAssembler::TailCallRuntime(Runtime::FunctionId function_id, |
- Node* context, Node* arg1, |
- Node* arg2) { |
- return raw_assembler_->TailCallRuntime2(function_id, arg1, arg2, context); |
+ Node* arg1, Node* arg2) { |
+ return raw_assembler_->TailCallRuntime2(function_id, arg1, arg2, Context()); |
+} |
+ |
+ |
+RawMachineLabel* CodeStubAssembler::GetOrCreateRawMachineLabel(Label* label) { |
+ if (!label->raw_label_) { |
+ RawMachineLabel* result = new RawMachineLabel(); |
Jarin
2016/02/08 10:25:04
As noted above, we do not normally allocate on the
|
+ label->raw_label_ = result; |
+ labels_.push_back(result); |
+ return result; |
+ } |
+ |
+ return label->raw_label_; |
+} |
+ |
+ |
+void CodeStubAssembler::Goto(Label* label) { |
+ raw_assembler_->Goto(GetOrCreateRawMachineLabel(label)); |
+} |
+ |
+void CodeStubAssembler::Branch(Node* cond, Label* true_label, |
+ Label* false_label) { |
+ raw_assembler_->Branch(cond, GetOrCreateRawMachineLabel(true_label), |
+ GetOrCreateRawMachineLabel(false_label)); |
+} |
+ |
+ |
+void CodeStubAssembler::Bind(Label* label) { |
+ raw_assembler_->Bind(GetOrCreateRawMachineLabel(label)); |
+} |
+ |
+ |
+void CodeStubAssembler::Return(Node* value) { |
+ return raw_assembler_->Return(value); |
+} |
+ |
+ |
+Node* CodeStubAssembler::Phi(MachineRepresentation rep, Node* n1, Node* n2) { |
+ return raw_assembler_->Phi(rep, n1, n2); |
} |
@@ -170,7 +296,6 @@ Graph* CodeStubAssembler::graph() { return raw_assembler_->graph(); } |
Zone* CodeStubAssembler::zone() { return raw_assembler_->zone(); } |
- |
} // namespace compiler |
} // namespace internal |
} // namespace v8 |