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

Unified Diff: src/code-stubs-hydrogen.cc

Issue 21356002: Improve instruction creating/adding shorthand in HGraphBuilder (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Review feedback Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/hydrogen.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/code-stubs-hydrogen.cc
diff --git a/src/code-stubs-hydrogen.cc b/src/code-stubs-hydrogen.cc
index b6a8a668bcf57cabc250e2a0407710b9f25d6394..d6ab1b59b91975dcd07cdeac93d8b7ee604543db 100644
--- a/src/code-stubs-hydrogen.cc
+++ b/src/code-stubs-hydrogen.cc
@@ -136,7 +136,6 @@ bool CodeStubGraphBuilderBase::BuildGraph() {
isolate()->GetHTracer()->TraceCompilation(&info_);
}
- Zone* zone = this->zone();
int param_count = descriptor_->register_param_count_;
HEnvironment* start_environment = graph()->start_environment();
HBasicBlock* next_block = CreateBasicBlock(start_environment);
@@ -144,15 +143,13 @@ bool CodeStubGraphBuilderBase::BuildGraph() {
next_block->SetJoinId(BailoutId::StubEntry());
set_current_block(next_block);
- HConstant* undefined_constant = new(zone) HConstant(
- isolate()->factory()->undefined_value());
- AddInstruction(undefined_constant);
+ HConstant* undefined_constant =
+ Add<HConstant>(isolate()->factory()->undefined_value());
graph()->set_undefined_constant(undefined_constant);
for (int i = 0; i < param_count; ++i) {
HParameter* param =
- new(zone) HParameter(i, HParameter::REGISTER_PARAMETER);
- AddInstruction(param);
+ Add<HParameter>(i, HParameter::REGISTER_PARAMETER);
start_environment->Bind(i, param);
parameters_[i] = param;
}
@@ -160,9 +157,9 @@ bool CodeStubGraphBuilderBase::BuildGraph() {
HInstruction* stack_parameter_count;
if (descriptor_->stack_parameter_count_ != NULL) {
ASSERT(descriptor_->environment_length() == (param_count + 1));
- stack_parameter_count = new(zone) HParameter(param_count,
- HParameter::REGISTER_PARAMETER,
- Representation::Integer32());
+ stack_parameter_count = New<HParameter>(param_count,
+ HParameter::REGISTER_PARAMETER,
+ Representation::Integer32());
stack_parameter_count->set_type(HType::Smi());
// It's essential to bind this value to the environment in case of deopt.
AddInstruction(stack_parameter_count);
@@ -174,7 +171,7 @@ bool CodeStubGraphBuilderBase::BuildGraph() {
arguments_length_ = graph()->GetConstant0();
}
- context_ = new(zone) HContext();
+ context_ = New<HContext>();
AddInstruction(context_);
start_environment->BindContext(context_);
@@ -191,20 +188,18 @@ bool CodeStubGraphBuilderBase::BuildGraph() {
if (!stack_parameter_count->IsConstant() &&
descriptor_->hint_stack_parameter_count_ < 0) {
HInstruction* amount = graph()->GetConstant1();
- stack_pop_count = AddInstruction(
- HAdd::New(zone, context_, stack_parameter_count, amount));
+ stack_pop_count = Add<HAdd>(stack_parameter_count, amount);
stack_pop_count->ChangeRepresentation(Representation::Integer32());
stack_pop_count->ClearFlag(HValue::kCanOverflow);
} else {
int count = descriptor_->hint_stack_parameter_count_;
- stack_pop_count = AddInstruction(new(zone) HConstant(count));
+ stack_pop_count = Add<HConstant>(count);
}
}
if (current_block() != NULL) {
- HReturn* hreturn_instruction = new(zone) HReturn(return_value,
- context_,
- stack_pop_count);
+ HReturn* hreturn_instruction = New<HReturn>(return_value,
+ stack_pop_count);
current_block()->Finish(hreturn_instruction);
set_current_block(NULL);
}
@@ -322,9 +317,9 @@ HValue* CodeStubGraphBuilder<ToNumberStub>::BuildCodeStub() {
if_number.Else();
// Convert the parameter to number using the builtin.
- HValue* function = AddLoadJSBuiltin(Builtins::TO_NUMBER, context());
+ HValue* function = AddLoadJSBuiltin(Builtins::TO_NUMBER);
Add<HPushArgument>(value);
- Push(Add<HInvokeFunction>(context(), function, 1));
+ Push(Add<HInvokeFunction>(function, 1));
if_number.End();
@@ -339,32 +334,30 @@ Handle<Code> ToNumberStub::GenerateCode() {
template <>
HValue* CodeStubGraphBuilder<FastCloneShallowArrayStub>::BuildCodeStub() {
- Zone* zone = this->zone();
Factory* factory = isolate()->factory();
HValue* undefined = graph()->GetConstantUndefined();
AllocationSiteMode alloc_site_mode = casted_stub()->allocation_site_mode();
FastCloneShallowArrayStub::Mode mode = casted_stub()->mode();
int length = casted_stub()->length();
- HInstruction* allocation_site =
- AddInstruction(new(zone) HLoadKeyed(GetParameter(0),
- GetParameter(1),
- NULL,
- FAST_ELEMENTS));
+ HInstruction* allocation_site = Add<HLoadKeyed>(GetParameter(0),
+ GetParameter(1),
+ static_cast<HValue*>(NULL),
+ FAST_ELEMENTS);
IfBuilder checker(this);
- checker.IfNot<HCompareObjectEqAndBranch, HValue*>(allocation_site, undefined);
+ checker.IfNot<HCompareObjectEqAndBranch, HValue*>(allocation_site,
+ undefined);
checker.Then();
HObjectAccess access = HObjectAccess::ForAllocationSiteTransitionInfo();
- HInstruction* boilerplate = AddLoad(allocation_site, access);
+ HInstruction* boilerplate = Add<HLoadNamedField>(allocation_site, access);
if (mode == FastCloneShallowArrayStub::CLONE_ANY_ELEMENTS) {
HValue* elements = AddLoadElements(boilerplate);
IfBuilder if_fixed_cow(this);
if_fixed_cow.If<HCompareMap>(elements, factory->fixed_cow_array_map());
if_fixed_cow.Then();
- environment()->Push(BuildCloneShallowArray(context(),
- boilerplate,
+ environment()->Push(BuildCloneShallowArray(boilerplate,
allocation_site,
alloc_site_mode,
FAST_ELEMENTS,
@@ -374,23 +367,20 @@ HValue* CodeStubGraphBuilder<FastCloneShallowArrayStub>::BuildCodeStub() {
IfBuilder if_fixed(this);
if_fixed.If<HCompareMap>(elements, factory->fixed_array_map());
if_fixed.Then();
- environment()->Push(BuildCloneShallowArray(context(),
- boilerplate,
+ environment()->Push(BuildCloneShallowArray(boilerplate,
allocation_site,
alloc_site_mode,
FAST_ELEMENTS,
length));
if_fixed.Else();
- environment()->Push(BuildCloneShallowArray(context(),
- boilerplate,
+ environment()->Push(BuildCloneShallowArray(boilerplate,
allocation_site,
alloc_site_mode,
FAST_DOUBLE_ELEMENTS,
length));
} else {
ElementsKind elements_kind = casted_stub()->ComputeElementsKind();
- environment()->Push(BuildCloneShallowArray(context(),
- boilerplate,
+ environment()->Push(BuildCloneShallowArray(boilerplate,
allocation_site,
alloc_site_mode,
elements_kind,
@@ -414,34 +404,33 @@ HValue* CodeStubGraphBuilder<FastCloneShallowObjectStub>::BuildCodeStub() {
Zone* zone = this->zone();
HValue* undefined = graph()->GetConstantUndefined();
- HInstruction* boilerplate =
- AddInstruction(new(zone) HLoadKeyed(GetParameter(0),
- GetParameter(1),
- NULL,
- FAST_ELEMENTS));
+ HInstruction* boilerplate = Add<HLoadKeyed>(GetParameter(0),
+ GetParameter(1),
+ static_cast<HValue*>(NULL),
+ FAST_ELEMENTS);
IfBuilder checker(this);
- checker.IfNot<HCompareObjectEqAndBranch, HValue*>(boilerplate, undefined);
+ checker.IfNot<HCompareObjectEqAndBranch, HValue*>(boilerplate,
+ undefined);
checker.And();
int size = JSObject::kHeaderSize + casted_stub()->length() * kPointerSize;
HValue* boilerplate_size =
AddInstruction(new(zone) HInstanceSize(boilerplate));
- HValue* size_in_words =
- AddInstruction(new(zone) HConstant(size >> kPointerSizeLog2));
+ HValue* size_in_words = Add<HConstant>(size >> kPointerSizeLog2);
checker.If<HCompareNumericAndBranch>(boilerplate_size,
size_in_words, Token::EQ);
checker.Then();
- HValue* size_in_bytes = AddInstruction(new(zone) HConstant(size));
+ HValue* size_in_bytes = Add<HConstant>(size);
- HInstruction* object = AddInstruction(new(zone)
- HAllocate(context(), size_in_bytes, HType::JSObject(),
- isolate()->heap()->ShouldGloballyPretenure()));
+ HInstruction* object = Add<HAllocate>(size_in_bytes, HType::JSObject(),
+ isolate()->heap()->ShouldGloballyPretenure());
for (int i = 0; i < size; i += kPointerSize) {
HObjectAccess access = HObjectAccess::ForJSObjectOffset(i);
- AddStore(object, access, AddLoad(boilerplate, access));
+ Add<HStoreNamedField>(object, access,
+ Add<HLoadNamedField>(boilerplate, access));
}
environment()->Push(object);
@@ -460,8 +449,7 @@ Handle<Code> FastCloneShallowObjectStub::GenerateCode() {
template <>
HValue* CodeStubGraphBuilder<CreateAllocationSiteStub>::BuildCodeStub() {
HValue* size = Add<HConstant>(AllocationSite::kSize);
- HInstruction* object = Add<HAllocate>(
- context(), size, HType::JSObject(), true);
+ HInstruction* object = Add<HAllocate>(size, HType::JSObject(), true);
// Store the map
Handle<Map> allocation_site_map(isolate()->heap()->allocation_site_map(),
@@ -477,11 +465,14 @@ HValue* CodeStubGraphBuilder<CreateAllocationSiteStub>::BuildCodeStub() {
// Link the object to the allocation site list
HValue* site_list = Add<HConstant>(
ExternalReference::allocation_sites_list_address(isolate()));
- HValue* site = AddLoad(site_list, HObjectAccess::ForAllocationSiteList());
+ HValue* site = Add<HLoadNamedField>(site_list,
+ HObjectAccess::ForAllocationSiteList());
HStoreNamedField* store =
- AddStore(object, HObjectAccess::ForAllocationSiteWeakNext(), site);
+ Add<HStoreNamedField>(object, HObjectAccess::ForAllocationSiteWeakNext(),
+ site);
store->SkipWriteBarrier();
- AddStore(site_list, HObjectAccess::ForAllocationSiteList(), object);
+ Add<HStoreNamedField>(site_list, HObjectAccess::ForAllocationSiteList(),
+ object);
// We use a hammer (SkipWriteBarrier()) to indicate that we know the input
// cell is really a Cell, and so no write barrier is needed.
@@ -489,7 +480,7 @@ HValue* CodeStubGraphBuilder<CreateAllocationSiteStub>::BuildCodeStub() {
// a cell. (perhaps with a new instruction, HAssert).
HInstruction* cell = GetParameter(0);
HObjectAccess access = HObjectAccess::ForCellValue();
- store = AddStore(cell, access, object);
+ store = Add<HStoreNamedField>(cell, access, object);
store->SkipWriteBarrier();
return cell;
}
@@ -586,14 +577,14 @@ HValue* CodeStubGraphBuilderBase::BuildArrayConstructor(
ArgumentClass argument_class) {
HValue* constructor = GetParameter(ArrayConstructorStubBase::kConstructor);
if (context_mode == CONTEXT_CHECK_REQUIRED) {
- HInstruction* array_function = BuildGetArrayFunction(context());
+ HInstruction* array_function = BuildGetArrayFunction();
ArrayContextChecker checker(this, constructor, array_function);
}
HValue* property_cell = GetParameter(ArrayConstructorStubBase::kPropertyCell);
// Walk through the property cell to the AllocationSite
- HValue* alloc_site = AddInstruction(new(zone()) HLoadNamedField(property_cell,
- HObjectAccess::ForCellValue()));
+ HValue* alloc_site = Add<HLoadNamedField>(property_cell,
+ HObjectAccess::ForCellValue());
JSArrayBuilder array_builder(this, kind, alloc_site, constructor,
override_mode);
HValue* result = NULL;
@@ -641,19 +632,17 @@ HValue* CodeStubGraphBuilderBase::BuildArraySingleArgumentConstructor(
HValue* constant_one = graph()->GetConstant1();
HValue* constant_zero = graph()->GetConstant0();
- HInstruction* elements = AddInstruction(
- new(zone()) HArgumentsElements(false));
+ HInstruction* elements = Add<HArgumentsElements>(false);
HInstruction* argument = AddInstruction(
new(zone()) HAccessArgumentsAt(elements, constant_one, constant_zero));
HConstant* max_alloc_length =
- new(zone()) HConstant(JSObject::kInitialMaxFastElementArray);
- AddInstruction(max_alloc_length);
+ Add<HConstant>(JSObject::kInitialMaxFastElementArray);
const int initial_capacity = JSArray::kPreallocatedArrayElements;
- HConstant* initial_capacity_node = new(zone()) HConstant(initial_capacity);
+ HConstant* initial_capacity_node = New<HConstant>(initial_capacity);
AddInstruction(initial_capacity_node);
- HBoundsCheck* checked_arg = Add<HBoundsCheck>(argument, max_alloc_length);
+ HInstruction* checked_arg = Add<HBoundsCheck>(argument, max_alloc_length);
IfBuilder if_builder(this);
if_builder.If<HCompareNumericAndBranch>(checked_arg, constant_zero,
Token::EQ);
@@ -693,12 +682,11 @@ HValue* CodeStubGraphBuilderBase::BuildArrayNArgumentsConstructor(
LoopBuilder::kPostIncrement);
HValue* start = graph()->GetConstant0();
HValue* key = builder.BeginBody(start, length, Token::LT);
- HInstruction* argument_elements = AddInstruction(
- new(zone()) HArgumentsElements(false));
+ HInstruction* argument_elements = Add<HArgumentsElements>(false);
HInstruction* argument = AddInstruction(new(zone()) HAccessArgumentsAt(
argument_elements, length, key));
- AddInstruction(new(zone()) HStoreKeyed(elements, key, argument, kind));
+ Add<HStoreKeyed>(elements, key, argument, kind);
builder.EndBody();
return new_object;
}
@@ -821,8 +809,7 @@ HValue* CodeStubGraphBuilder<UnaryOpStub>::BuildCodeInitializedStub() {
// Prevent unwanted HChange being inserted to ensure that the stub
// deopts on newly encountered types.
if (!type->Maybe(Type::Double())) {
- input = AddInstruction(new(zone())
- HForceRepresentation(input, Representation::Smi()));
+ input = Add<HForceRepresentation>(input, Representation::Smi());
}
if (!type->Is(Type::Number())) {
@@ -834,9 +821,9 @@ HValue* CodeStubGraphBuilder<UnaryOpStub>::BuildCodeInitializedStub() {
HInstruction* res = BuildUnaryMathOp(input, type, stub->operation());
if_number.Return(AddInstruction(res));
if_number.Else();
- HValue* function = AddLoadJSBuiltin(stub->ToJSBuiltin(), context());
+ HValue* function = AddLoadJSBuiltin(stub->ToJSBuiltin());
Add<HPushArgument>(GetParameter(0));
- HValue* result = Add<HInvokeFunction>(context(), function, 1);
+ HValue* result = Add<HInvokeFunction>(function, 1);
if_number.Return(result);
if_number.End();
return graph()->GetConstantUndefined();
@@ -884,10 +871,9 @@ HValue* CodeStubGraphBuilder<StoreGlobalStub>::BuildCodeInitializedStub() {
// Check that the map of the global has not changed: use a placeholder map
// that will be replaced later with the global object's map.
Handle<Map> placeholder_map = isolate()->factory()->meta_map();
- AddInstruction(HCheckMaps::New(
- receiver, placeholder_map, zone(), top_info()));
+ Add<HCheckMaps>(receiver, placeholder_map, top_info());
- HValue* cell = Add<HConstant>(placeholder_cell, Representation::Tagged());
+ HValue* cell = Add<HConstant>(placeholder_cell);
HObjectAccess access(HObjectAccess::ForCellPayload(isolate()));
HValue* cell_contents = Add<HLoadNamedField>(cell, access);
@@ -902,7 +888,7 @@ HValue* CodeStubGraphBuilder<StoreGlobalStub>::BuildCodeInitializedStub() {
// property has been deleted and that the store must be handled by the
// runtime.
IfBuilder builder(this);
- HValue* hole_value = Add<HConstant>(hole, Representation::Tagged());
+ HValue* hole_value = Add<HConstant>(hole);
builder.If<HCompareObjectEqAndBranch>(cell_contents, hole_value);
builder.Then();
builder.Deopt();
« no previous file with comments | « no previous file | src/hydrogen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698