Commit 32cdd4d4 authored by ishell@chromium.org's avatar ishell@chromium.org

More Hydrogen templatization.

Factories added to a set of Hydrogen classes.
Several old-style HXxx::New() replaced with New<HXxx>() and NewUncasted<HXxx>.
Several AddInstruction() calls following New::XXX() replaced with Add<XXX>().
AddLoadNamedField() method added to GraphBuilder.

R=bmeurer@chromium.org

Review URL: https://codereview.chromium.org/34523004

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@17318 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent dd74f5aa
...@@ -174,8 +174,7 @@ bool CodeStubGraphBuilderBase::BuildGraph() { ...@@ -174,8 +174,7 @@ bool CodeStubGraphBuilderBase::BuildGraph() {
arguments_length_ = graph()->GetConstant0(); arguments_length_ = graph()->GetConstant0();
} }
context_ = New<HContext>(); context_ = Add<HContext>();
AddInstruction(context_);
start_environment->BindContext(context_); start_environment->BindContext(context_);
Add<HSimulate>(BailoutId::StubEntry()); Add<HSimulate>(BailoutId::StubEntry());
...@@ -567,7 +566,7 @@ HValue* CodeStubGraphBuilder<LoadFieldStub>::BuildCodeStub() { ...@@ -567,7 +566,7 @@ HValue* CodeStubGraphBuilder<LoadFieldStub>::BuildCodeStub() {
HObjectAccess access = casted_stub()->is_inobject() ? HObjectAccess access = casted_stub()->is_inobject() ?
HObjectAccess::ForJSObjectOffset(casted_stub()->offset(), rep) : HObjectAccess::ForJSObjectOffset(casted_stub()->offset(), rep) :
HObjectAccess::ForBackingStoreOffset(casted_stub()->offset(), rep); HObjectAccess::ForBackingStoreOffset(casted_stub()->offset(), rep);
return AddInstruction(BuildLoadNamedField(GetParameter(0), access)); return AddLoadNamedField(GetParameter(0), access);
} }
...@@ -582,7 +581,7 @@ HValue* CodeStubGraphBuilder<KeyedLoadFieldStub>::BuildCodeStub() { ...@@ -582,7 +581,7 @@ HValue* CodeStubGraphBuilder<KeyedLoadFieldStub>::BuildCodeStub() {
HObjectAccess access = casted_stub()->is_inobject() ? HObjectAccess access = casted_stub()->is_inobject() ?
HObjectAccess::ForJSObjectOffset(casted_stub()->offset(), rep) : HObjectAccess::ForJSObjectOffset(casted_stub()->offset(), rep) :
HObjectAccess::ForBackingStoreOffset(casted_stub()->offset(), rep); HObjectAccess::ForBackingStoreOffset(casted_stub()->offset(), rep);
return AddInstruction(BuildLoadNamedField(GetParameter(0), access)); return AddLoadNamedField(GetParameter(0), access);
} }
...@@ -688,14 +687,13 @@ HValue* CodeStubGraphBuilderBase::BuildArraySingleArgumentConstructor( ...@@ -688,14 +687,13 @@ HValue* CodeStubGraphBuilderBase::BuildArraySingleArgumentConstructor(
HValue* constant_zero = graph()->GetConstant0(); HValue* constant_zero = graph()->GetConstant0();
HInstruction* elements = Add<HArgumentsElements>(false); HInstruction* elements = Add<HArgumentsElements>(false);
HInstruction* argument = AddInstruction( HInstruction* argument = Add<HAccessArgumentsAt>(
new(zone()) HAccessArgumentsAt(elements, constant_one, constant_zero)); elements, constant_one, constant_zero);
HConstant* max_alloc_length = HConstant* max_alloc_length =
Add<HConstant>(JSObject::kInitialMaxFastElementArray); Add<HConstant>(JSObject::kInitialMaxFastElementArray);
const int initial_capacity = JSArray::kPreallocatedArrayElements; const int initial_capacity = JSArray::kPreallocatedArrayElements;
HConstant* initial_capacity_node = New<HConstant>(initial_capacity); HConstant* initial_capacity_node = Add<HConstant>(initial_capacity);
AddInstruction(initial_capacity_node);
HInstruction* checked_arg = Add<HBoundsCheck>(argument, max_alloc_length); HInstruction* checked_arg = Add<HBoundsCheck>(argument, max_alloc_length);
IfBuilder if_builder(this); IfBuilder if_builder(this);
...@@ -738,8 +736,8 @@ HValue* CodeStubGraphBuilderBase::BuildArrayNArgumentsConstructor( ...@@ -738,8 +736,8 @@ HValue* CodeStubGraphBuilderBase::BuildArrayNArgumentsConstructor(
HValue* start = graph()->GetConstant0(); HValue* start = graph()->GetConstant0();
HValue* key = builder.BeginBody(start, length, Token::LT); HValue* key = builder.BeginBody(start, length, Token::LT);
HInstruction* argument_elements = Add<HArgumentsElements>(false); HInstruction* argument_elements = Add<HArgumentsElements>(false);
HInstruction* argument = AddInstruction(new(zone()) HAccessArgumentsAt( HInstruction* argument = Add<HAccessArgumentsAt>(
argument_elements, length, key)); argument_elements, length, key);
Add<HStoreKeyed>(elements, key, argument, kind); Add<HStoreKeyed>(elements, key, argument, kind);
builder.EndBody(); builder.EndBody();
...@@ -1168,8 +1166,8 @@ void CodeStubGraphBuilderBase::BuildInstallFromOptimizedCodeMap( ...@@ -1168,8 +1166,8 @@ void CodeStubGraphBuilderBase::BuildInstallFromOptimizedCodeMap(
} }
restore_check.Else(); restore_check.Else();
{ {
HValue* keyed_minus = AddInstruction(HSub::New(zone(), context(), key, HValue* keyed_minus = AddUncasted<HSub>(
shared_function_entry_length)); key, shared_function_entry_length);
HInstruction* keyed_lookup = Add<HLoadKeyed>(optimized_map, HInstruction* keyed_lookup = Add<HLoadKeyed>(optimized_map,
keyed_minus, static_cast<HValue*>(NULL), FAST_ELEMENTS); keyed_minus, static_cast<HValue*>(NULL), FAST_ELEMENTS);
IfBuilder done_check(this); IfBuilder done_check(this);
...@@ -1178,8 +1176,8 @@ void CodeStubGraphBuilderBase::BuildInstallFromOptimizedCodeMap( ...@@ -1178,8 +1176,8 @@ void CodeStubGraphBuilderBase::BuildInstallFromOptimizedCodeMap(
done_check.Then(); done_check.Then();
{ {
// Hit: fetch the optimized code. // Hit: fetch the optimized code.
HValue* keyed_plus = AddInstruction(HAdd::New(zone(), context(), HValue* keyed_plus = AddUncasted<HAdd>(
keyed_minus, graph()->GetConstant1())); keyed_minus, graph()->GetConstant1());
HValue* code_object = Add<HLoadKeyed>(optimized_map, HValue* code_object = Add<HLoadKeyed>(optimized_map,
keyed_plus, static_cast<HValue*>(NULL), FAST_ELEMENTS); keyed_plus, static_cast<HValue*>(NULL), FAST_ELEMENTS);
BuildInstallOptimizedCode(js_function, native_context, code_object); BuildInstallOptimizedCode(js_function, native_context, code_object);
......
This diff is collapsed.
This diff is collapsed.
...@@ -1283,6 +1283,7 @@ class HGraphBuilder { ...@@ -1283,6 +1283,7 @@ class HGraphBuilder {
LoadKeyedHoleMode load_mode = NEVER_RETURN_HOLE); LoadKeyedHoleMode load_mode = NEVER_RETURN_HOLE);
HLoadNamedField* BuildLoadNamedField(HValue* object, HObjectAccess access); HLoadNamedField* BuildLoadNamedField(HValue* object, HObjectAccess access);
HInstruction* AddLoadNamedField(HValue* object, HObjectAccess access);
HInstruction* BuildLoadStringLength(HValue* object, HValue* checked_value); HInstruction* BuildLoadStringLength(HValue* object, HValue* checked_value);
HStoreNamedField* AddStoreMapConstant(HValue* object, Handle<Map>); HStoreNamedField* AddStoreMapConstant(HValue* object, Handle<Map>);
HLoadNamedField* AddLoadElements(HValue* object); HLoadNamedField* AddLoadElements(HValue* object);
...@@ -1948,21 +1949,22 @@ class HOptimizedGraphBuilder : public HGraphBuilder, public AstVisitor { ...@@ -1948,21 +1949,22 @@ class HOptimizedGraphBuilder : public HGraphBuilder, public AstVisitor {
env->Bind(index, value); env->Bind(index, value);
if (IsEligibleForEnvironmentLivenessAnalysis(var, index, value, env)) { if (IsEligibleForEnvironmentLivenessAnalysis(var, index, value, env)) {
HEnvironmentMarker* bind = HEnvironmentMarker* bind =
New<HEnvironmentMarker>(HEnvironmentMarker::BIND, index); Add<HEnvironmentMarker>(HEnvironmentMarker::BIND, index);
AddInstruction(bind); USE(bind);
#ifdef DEBUG #ifdef DEBUG
bind->set_closure(env->closure()); bind->set_closure(env->closure());
#endif #endif
} }
} }
HValue* LookupAndMakeLive(Variable* var) { HValue* LookupAndMakeLive(Variable* var) {
HEnvironment* env = environment(); HEnvironment* env = environment();
int index = env->IndexFor(var); int index = env->IndexFor(var);
HValue* value = env->Lookup(index); HValue* value = env->Lookup(index);
if (IsEligibleForEnvironmentLivenessAnalysis(var, index, value, env)) { if (IsEligibleForEnvironmentLivenessAnalysis(var, index, value, env)) {
HEnvironmentMarker* lookup = HEnvironmentMarker* lookup =
New<HEnvironmentMarker>(HEnvironmentMarker::LOOKUP, index); Add<HEnvironmentMarker>(HEnvironmentMarker::LOOKUP, index);
AddInstruction(lookup); USE(lookup);
#ifdef DEBUG #ifdef DEBUG
lookup->set_closure(env->closure()); lookup->set_closure(env->closure());
#endif #endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment