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

Unified Diff: src/fast-accessor-assembler.cc

Issue 2569353004: [stubs] Enable machine graph verification for fast accessor assembler. (Closed)
Patch Set: Created 4 years 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
« no previous file with comments | « src/fast-accessor-assembler.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/fast-accessor-assembler.cc
diff --git a/src/fast-accessor-assembler.cc b/src/fast-accessor-assembler.cc
index dd4fe01520a623852bf82f9e69b03d14a545fb3b..fbec6d6fc33e69b47b217dbc4780d7b93b2e20e7 100644
--- a/src/fast-accessor-assembler.cc
+++ b/src/fast-accessor-assembler.cc
@@ -10,17 +10,20 @@
#include "src/handles-inl.h"
#include "src/objects.h" // For FAA::LoadInternalField impl.
-using v8::internal::compiler::Node;
-
namespace v8 {
namespace internal {
+using compiler::Node;
+using compiler::CodeAssemblerLabel;
+using compiler::CodeAssemblerVariable;
+
FastAccessorAssembler::FastAccessorAssembler(Isolate* isolate)
: zone_(isolate->allocator(), ZONE_NAME),
isolate_(isolate),
- assembler_state_(isolate, zone(), 1, Code::ComputeFlags(Code::STUB),
- "FastAccessorAssembler"),
- assembler_(new CodeStubAssembler(&assembler_state_)),
+ assembler_state_(new compiler::CodeAssemblerState(
+ isolate, zone(), 1, Code::ComputeFlags(Code::STUB),
+ "FastAccessorAssembler")),
+ assembler_(new CodeStubAssembler(assembler_state_.get())),
state_(kBuilding) {}
FastAccessorAssembler::~FastAccessorAssembler() { Clear(); }
@@ -39,19 +42,18 @@ FastAccessorAssembler::ValueId FastAccessorAssembler::GetReceiver() {
}
FastAccessorAssembler::ValueId FastAccessorAssembler::LoadInternalField(
- ValueId value, int field_no) {
+ ValueId value_id, int field_no) {
CHECK_EQ(kBuilding, state_);
- CodeStubAssembler::Variable result(assembler_.get(),
- MachineRepresentation::kTagged);
+ CodeAssemblerVariable result(assembler_.get(),
+ MachineRepresentation::kTagged);
LabelId is_not_jsobject = MakeLabel();
- CodeStubAssembler::Label merge(assembler_.get(), &result);
+ CodeAssemblerLabel merge(assembler_.get(), &result);
- CheckIsJSObjectOrJump(value, is_not_jsobject);
+ CheckIsJSObjectOrJump(value_id, is_not_jsobject);
Node* internal_field = assembler_->LoadObjectField(
- FromId(value), JSObject::kHeaderSize + kPointerSize * field_no,
- MachineType::Pointer());
+ FromId(value_id), JSObject::kHeaderSize + kPointerSize * field_no);
result.Bind(internal_field);
assembler_->Goto(&merge);
@@ -67,14 +69,15 @@ FastAccessorAssembler::ValueId FastAccessorAssembler::LoadInternalField(
}
FastAccessorAssembler::ValueId
-FastAccessorAssembler::LoadInternalFieldUnchecked(ValueId value, int field_no) {
+FastAccessorAssembler::LoadInternalFieldUnchecked(ValueId value_id,
+ int field_no) {
CHECK_EQ(kBuilding, state_);
// Defensive debug checks.
if (FLAG_debug_code) {
LabelId is_jsobject = MakeLabel();
LabelId is_not_jsobject = MakeLabel();
- CheckIsJSObjectOrJump(value, is_not_jsobject);
+ CheckIsJSObjectOrJump(value_id, is_not_jsobject);
assembler_->Goto(FromId(is_jsobject));
SetLabel(is_not_jsobject);
@@ -85,58 +88,56 @@ FastAccessorAssembler::LoadInternalFieldUnchecked(ValueId value, int field_no) {
}
Node* result = assembler_->LoadObjectField(
- FromId(value), JSObject::kHeaderSize + kPointerSize * field_no,
- MachineType::Pointer());
+ FromId(value_id), JSObject::kHeaderSize + kPointerSize * field_no);
return FromRaw(result);
}
-FastAccessorAssembler::ValueId FastAccessorAssembler::LoadValue(ValueId value,
- int offset) {
+FastAccessorAssembler::ValueId FastAccessorAssembler::LoadValue(
+ ValueId value_id, int offset) {
CHECK_EQ(kBuilding, state_);
- return FromRaw(assembler_->LoadBufferObject(FromId(value), offset,
+ return FromRaw(assembler_->LoadBufferObject(FromId(value_id), offset,
MachineType::IntPtr()));
}
-FastAccessorAssembler::ValueId FastAccessorAssembler::LoadObject(ValueId value,
- int offset) {
+FastAccessorAssembler::ValueId FastAccessorAssembler::LoadObject(
+ ValueId value_id, int offset) {
CHECK_EQ(kBuilding, state_);
return FromRaw(assembler_->LoadBufferObject(
- assembler_->LoadBufferObject(FromId(value), offset,
- MachineType::Pointer()),
- 0, MachineType::AnyTagged()));
+ assembler_->LoadBufferObject(FromId(value_id), offset), 0,
+ MachineType::AnyTagged()));
}
-FastAccessorAssembler::ValueId FastAccessorAssembler::ToSmi(ValueId value) {
+FastAccessorAssembler::ValueId FastAccessorAssembler::ToSmi(ValueId value_id) {
CHECK_EQ(kBuilding, state_);
- return FromRaw(assembler_->SmiTag(FromId(value)));
+ return FromRaw(assembler_->SmiTag(FromId(value_id)));
}
-void FastAccessorAssembler::ReturnValue(ValueId value) {
+void FastAccessorAssembler::ReturnValue(ValueId value_id) {
CHECK_EQ(kBuilding, state_);
- assembler_->Return(FromId(value));
+ assembler_->Return(FromId(value_id));
}
-void FastAccessorAssembler::CheckFlagSetOrReturnNull(ValueId value, int mask) {
+void FastAccessorAssembler::CheckFlagSetOrReturnNull(ValueId value_id,
+ int mask) {
CHECK_EQ(kBuilding, state_);
- CodeStubAssembler::Label pass(assembler_.get());
- CodeStubAssembler::Label fail(assembler_.get());
+ CodeAssemblerLabel pass(assembler_.get());
+ CodeAssemblerLabel fail(assembler_.get());
+ Node* value = FromId(value_id);
assembler_->Branch(
- assembler_->Word32Equal(
- assembler_->Word32And(FromId(value), assembler_->Int32Constant(mask)),
- assembler_->Int32Constant(0)),
- &fail, &pass);
+ assembler_->IsSetWord(assembler_->BitcastTaggedToWord(value), mask),
+ &pass, &fail);
assembler_->Bind(&fail);
assembler_->Return(assembler_->NullConstant());
assembler_->Bind(&pass);
}
-void FastAccessorAssembler::CheckNotZeroOrReturnNull(ValueId value) {
+void FastAccessorAssembler::CheckNotZeroOrReturnNull(ValueId value_id) {
CHECK_EQ(kBuilding, state_);
- CodeStubAssembler::Label is_null(assembler_.get());
- CodeStubAssembler::Label not_null(assembler_.get());
+ CodeAssemblerLabel is_null(assembler_.get());
+ CodeAssemblerLabel not_null(assembler_.get());
assembler_->Branch(
- assembler_->WordEqual(FromId(value), assembler_->IntPtrConstant(0)),
+ assembler_->WordEqual(FromId(value_id), assembler_->SmiConstant(0)),
&is_null, &not_null);
assembler_->Bind(&is_null);
assembler_->Return(assembler_->NullConstant());
@@ -145,7 +146,7 @@ void FastAccessorAssembler::CheckNotZeroOrReturnNull(ValueId value) {
FastAccessorAssembler::LabelId FastAccessorAssembler::MakeLabel() {
CHECK_EQ(kBuilding, state_);
- return FromRaw(new CodeStubAssembler::Label(assembler_.get()));
+ return FromRaw(new CodeAssemblerLabel(assembler_.get()));
}
void FastAccessorAssembler::SetLabel(LabelId label_id) {
@@ -161,9 +162,9 @@ void FastAccessorAssembler::Goto(LabelId label_id) {
void FastAccessorAssembler::CheckNotZeroOrJump(ValueId value_id,
LabelId label_id) {
CHECK_EQ(kBuilding, state_);
- CodeStubAssembler::Label pass(assembler_.get());
+ CodeAssemblerLabel pass(assembler_.get());
assembler_->Branch(
- assembler_->WordEqual(FromId(value_id), assembler_->IntPtrConstant(0)),
+ assembler_->WordEqual(FromId(value_id), assembler_->SmiConstant(0)),
FromId(label_id), &pass);
assembler_->Bind(&pass);
}
@@ -216,28 +217,20 @@ void FastAccessorAssembler::CheckIsJSObjectOrJump(ValueId value_id,
CHECK_EQ(kBuilding, state_);
// Determine the 'value' object's instance type.
- Node* object_map = assembler_->LoadObjectField(
- FromId(value_id), Internals::kHeapObjectMapOffset,
- MachineType::Pointer());
+ Node* instance_type = assembler_->LoadInstanceType(FromId(value_id));
- Node* instance_type = assembler_->WordAnd(
- assembler_->LoadObjectField(object_map,
- Internals::kMapInstanceTypeAndBitFieldOffset,
- MachineType::Uint16()),
- assembler_->IntPtrConstant(0xff));
-
- CodeStubAssembler::Label is_jsobject(assembler_.get());
+ CodeAssemblerLabel is_jsobject(assembler_.get());
// Check whether we have a proper JSObject.
assembler_->GotoIf(
- assembler_->WordEqual(
- instance_type, assembler_->IntPtrConstant(Internals::kJSObjectType)),
+ assembler_->Word32Equal(
+ instance_type, assembler_->Int32Constant(Internals::kJSObjectType)),
&is_jsobject);
// JSApiObject?.
assembler_->GotoUnless(
- assembler_->WordEqual(instance_type, assembler_->IntPtrConstant(
- Internals::kJSApiObjectType)),
+ assembler_->Word32Equal(instance_type, assembler_->Int32Constant(
+ Internals::kJSApiObjectType)),
FromId(label_id));
// Continue.
@@ -247,7 +240,8 @@ void FastAccessorAssembler::CheckIsJSObjectOrJump(ValueId value_id,
MaybeHandle<Code> FastAccessorAssembler::Build() {
CHECK_EQ(kBuilding, state_);
- Handle<Code> code = compiler::CodeAssembler::GenerateCode(&assembler_state_);
+ Handle<Code> code = compiler::CodeAssembler::GenerateCode(
+ assembler_state_.get(), FLAG_csa_verify);
state_ = !code.is_null() ? kBuilt : kError;
Clear();
return code;
@@ -255,12 +249,12 @@ MaybeHandle<Code> FastAccessorAssembler::Build() {
FastAccessorAssembler::ValueId FastAccessorAssembler::FromRaw(Node* node) {
nodes_.push_back(node);
- ValueId value = {nodes_.size() - 1};
- return value;
+ ValueId value_id = {nodes_.size() - 1};
+ return value_id;
}
FastAccessorAssembler::LabelId FastAccessorAssembler::FromRaw(
- CodeStubAssembler::Label* label) {
+ CodeAssemblerLabel* label) {
labels_.push_back(label);
LabelId label_id = {labels_.size() - 1};
return label_id;
@@ -272,7 +266,7 @@ Node* FastAccessorAssembler::FromId(ValueId value) const {
return nodes_.at(value.value_id);
}
-CodeStubAssembler::Label* FastAccessorAssembler::FromId(LabelId label) const {
+CodeAssemblerLabel* FastAccessorAssembler::FromId(LabelId label) const {
CHECK_LT(label.label_id, labels_.size());
CHECK_NOT_NULL(labels_.at(label.label_id));
return labels_.at(label.label_id);
« no previous file with comments | « src/fast-accessor-assembler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698