Revision: 15379
Author: [email protected]
Date: Fri Jun 28 04:44:16 2013
Log: Make use of templatized convienience functions for adding
Hydrogen instructions.
Building on the previous changes from
https://codereview.chromium.org/18050004/
this patch makes even more use of the templatized functions for adding
Hydrogen instructions.
[email protected]
BUG=
Review URL: https://codereview.chromium.org/18051010
http://code.google.com/p/v8/source/detail?r=15379
Modified:
/branches/bleeding_edge/src/hydrogen.cc
/branches/bleeding_edge/src/hydrogen.h
=======================================
--- /branches/bleeding_edge/src/hydrogen.cc Fri Jun 28 00:40:35 2013
+++ /branches/bleeding_edge/src/hydrogen.cc Fri Jun 28 04:44:16 2013
@@ -993,8 +993,7 @@
HReturn* HGraphBuilder::AddReturn(HValue* value) {
HValue* context = environment()->LookupContext();
int num_parameters = graph()->info()->num_parameters();
- HValue* params = AddInstruction(new(graph()->zone())
- HConstant(num_parameters));
+ HValue* params = Add<HConstant>(num_parameters);
HReturn* return_instruction = new(graph()->zone())
HReturn(value, context, params);
current_block()->FinishExit(return_instruction);
@@ -1020,9 +1019,7 @@
HValue* HGraphBuilder::BuildCheckHeapObject(HValue* obj) {
if (obj->type().IsHeapObject()) return obj;
- HCheckHeapObject* check = new(zone()) HCheckHeapObject(obj);
- AddInstruction(check);
- return check;
+ return Add<HCheckHeapObject>(obj);
}
@@ -1046,7 +1043,7 @@
ASSERT(val != NULL);
switch (elements_kind) {
case EXTERNAL_PIXEL_ELEMENTS: {
- val = AddInstruction(new(zone) HClampToUint8(val));
+ val = Add<HClampToUint8>(val);
break;
}
case EXTERNAL_BYTE_ELEMENTS:
@@ -1133,8 +1130,7 @@
length_checker.IfCompare(length, key, Token::EQ);
length_checker.Then();
- HValue* current_capacity =
- AddInstruction(new(zone) HFixedArrayBaseLength(elements));
+ HValue* current_capacity = Add<HFixedArrayBaseLength>(elements);
IfBuilder capacity_checker(this);
@@ -1182,7 +1178,6 @@
HValue* elements,
ElementsKind kind,
HValue* length) {
- Zone* zone = this->zone();
Heap* heap = isolate()->heap();
IfBuilder cow_checker(this);
@@ -1191,8 +1186,7 @@
Handle<Map>(heap->fixed_cow_array_map()));
cow_checker.Then();
- HValue* capacity =
- AddInstruction(new(zone) HFixedArrayBaseLength(elements));
+ HValue* capacity = Add<HFixedArrayBaseLength>(elements);
HValue* new_elements = BuildGrowElementsCapacity(object, elements,
kind, length, capacity);
@@ -1249,15 +1243,14 @@
Representation::Smi());
length->set_type(HType::Smi());
} else {
- length = AddInstruction(new(zone) HFixedArrayBaseLength(elements));
+ length = Add<HFixedArrayBaseLength>(elements);
}
HValue* checked_key = NULL;
if (IsExternalArrayElementsKind(elements_kind)) {
if (store_mode == STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS) {
NoObservableSideEffectsScope no_effects(this);
HLoadExternalArrayPointer* external_elements =
- new(zone) HLoadExternalArrayPointer(elements);
- AddInstruction(external_elements);
+ Add<HLoadExternalArrayPointer>(elements);
IfBuilder length_checker(this);
length_checker.IfCompare(key, length, Token::LT);
length_checker.Then();
@@ -1276,8 +1269,7 @@
ASSERT(store_mode == STANDARD_STORE);
checked_key = Add<HBoundsCheck>(key, length);
HLoadExternalArrayPointer* external_elements =
- new(zone) HLoadExternalArrayPointer(elements);
- AddInstruction(external_elements);
+ Add<HLoadExternalArrayPointer>(elements);
return AddInstruction(BuildExternalArrayElementAccess(
external_elements, checked_key, val, mapcheck,
elements_kind, is_store));
@@ -1292,8 +1284,7 @@
// deopt, leaving the backing store in an invalid state.
if (is_store && IsFastSmiElementsKind(elements_kind) &&
!val->type().IsSmi()) {
- val = AddInstruction(new(zone) HForceRepresentation(
- val, Representation::Smi()));
+ val = Add<HForceRepresentation>(val, Representation::Smi());
}
if (IsGrowStoreMode(store_mode)) {
@@ -1331,14 +1322,12 @@
int elements_size = IsFastDoubleElementsKind(kind)
? kDoubleSize : kPointerSize;
- HConstant* elements_size_value = new(zone) HConstant(elements_size);
- AddInstruction(elements_size_value);
+ HConstant* elements_size_value = Add<HConstant>(elements_size);
HValue* mul = AddInstruction(
HMul::New(zone, context, capacity,
elements_size_value));
mul->ClearFlag(HValue::kCanOverflow);
- HConstant* header_size = new(zone) HConstant(FixedArray::kHeaderSize);
- AddInstruction(header_size);
+ HConstant* header_size = Add<HConstant>(FixedArray::kHeaderSize);
HValue* total_size = AddInstruction(
HAdd::New(zone, context, mul, header_size));
total_size->ClearFlag(HValue::kCanOverflow);
@@ -1356,10 +1345,7 @@
}
}
- HValue* elements =
- AddInstruction(new(zone) HAllocate(context, total_size,
- HType::JSArray(), flags));
- return elements;
+ return Add<HAllocate>(context, total_size, HType::JSArray(), flags);
}
@@ -1398,8 +1384,7 @@
AddStore(array, HObjectAccess::ForMap(), array_map);
HConstant* empty_fixed_array =
- new(zone()) HConstant(isolate()->factory()->empty_fixed_array());
- AddInstruction(empty_fixed_array);
+ Add<HConstant>(isolate()->factory()->empty_fixed_array());
HObjectAccess access = HObjectAccess::ForPropertiesPointer();
AddStore(array, access, empty_fixed_array);
@@ -1416,10 +1401,8 @@
elements_location += AllocationSiteInfo::kSize;
}
- HInnerAllocatedObject* elements = new(zone()) HInnerAllocatedObject(
- array, elements_location);
- AddInstruction(elements);
-
+ HInnerAllocatedObject* elements =
+ Add<HInnerAllocatedObject>(array, elements_location);
AddStore(array, HObjectAccess::ForElementsPointer(), elements);
return elements;
}
@@ -1443,7 +1426,7 @@
HAdd::New(zone, context, half_old_capacity, old_capacity));
new_capacity->ClearFlag(HValue::kCanOverflow);
- HValue* min_growth = AddInstruction(new(zone) HConstant(16));
+ HValue* min_growth = Add<HConstant>(16);
new_capacity = AddInstruction(
HAdd::New(zone, context, new_capacity, min_growth));
@@ -1454,17 +1437,15 @@
void HGraphBuilder::BuildNewSpaceArrayCheck(HValue* length, ElementsKind
kind) {
- Zone* zone = this->zone();
Heap* heap = isolate()->heap();
int element_size = IsFastDoubleElementsKind(kind) ? kDoubleSize
: kPointerSize;
int max_size = heap->MaxRegularSpaceAllocationSize() / element_size;
max_size -= JSArray::kSize / element_size;
- HConstant* max_size_constant = new(zone) HConstant(max_size);
- AddInstruction(max_size_constant);
+ HConstant* max_size_constant = Add<HConstant>(max_size);
// Since we're forcing Integer32 representation for this HBoundsCheck,
// there's no need to Smi-check the index.
- AddInstruction(new(zone) HBoundsCheck(length, max_size_constant));
+ Add<HBoundsCheck>(length, max_size_constant);
}
@@ -1500,10 +1481,9 @@
Factory* factory = isolate()->factory();
double nan_double = FixedDoubleArray::hole_nan_as_double();
- Zone* zone = this->zone();
HValue* hole = IsFastSmiOrObjectElementsKind(elements_kind)
- ? AddInstruction(new(zone) HConstant(factory->the_hole_value()))
- : AddInstruction(new(zone) HConstant(nan_double));
+ ? Add<HConstant>(factory->the_hole_value())
+ : Add<HConstant>(nan_double);
// Special loop unfolding case
static const int kLoopUnfoldLimit = 4;
@@ -1530,15 +1510,15 @@
if (unfold_loop) {
for (int i = 0; i < initial_capacity; i++) {
- HInstruction* key = AddInstruction(new(zone) HConstant(i));
- AddInstruction(new(zone) HStoreKeyed(elements, key, hole,
elements_kind));
+ HInstruction* key = Add<HConstant>(i);
+ Add<HStoreKeyed>(elements, key, hole, elements_kind);
}
} else {
LoopBuilder builder(this, context, LoopBuilder::kPostIncrement);
HValue* key = builder.BeginBody(from, to, Token::LT);
- AddInstruction(new(zone) HStoreKeyed(elements, key, hole,
elements_kind));
+ Add<HStoreKeyed>(elements, key, hole, elements_kind);
builder.EndBody();
}
@@ -1568,15 +1548,15 @@
HValue* key = builder.BeginBody(graph()->GetConstant0(), length,
Token::LT);
- HValue* element =
- AddInstruction(new(zone()) HLoadKeyed(from_elements, key, NULL,
- from_elements_kind,
- ALLOW_RETURN_HOLE));
+ HValue* element = Add<HLoadKeyed>(from_elements, key,
+ static_cast<HValue*>(NULL),
+ from_elements_kind,
+ ALLOW_RETURN_HOLE);
ElementsKind holey_kind = IsFastSmiElementsKind(to_elements_kind)
? FAST_HOLEY_ELEMENTS : to_elements_kind;
- HInstruction* holey_store = AddInstruction(
- new(zone()) HStoreKeyed(to_elements, key, element, holey_kind));
+ HInstruction* holey_store = Add<HStoreKeyed>(to_elements, key,
+ element, holey_kind);
// Allow NaN hole values to converted to their tagged counterparts.
if (IsFastHoleyElementsKind(to_elements_kind)) {
holey_store->SetFlag(HValue::kAllowUndefinedAsNaN);
@@ -1597,8 +1577,6 @@
AllocationSiteMode mode,
ElementsKind kind,
int length) {
- Zone* zone = this->zone();
-
NoObservableSideEffectsScope no_effects(this);
// All sizes here are multiples of kPointerSize.
@@ -1616,12 +1594,11 @@
HAllocate::Flags allocate_flags = HAllocate::DefaultFlags(kind);
// Allocate both the JS array and the elements array in one big
// allocation. This avoids multiple limit checks.
- HValue* size_in_bytes = AddInstruction(new(zone) HConstant(size));
- HInstruction* object =
- AddInstruction(new(zone) HAllocate(context,
- size_in_bytes,
- HType::JSObject(),
- allocate_flags));
+ HValue* size_in_bytes = Add<HConstant>(size);
+ HInstruction* object = Add<HAllocate>(context,
+ size_in_bytes,
+ HType::JSObject(),
+ allocate_flags);
// Copy the JS array part.
for (int i = 0; i < JSArray::kSize; i += kPointerSize) {
@@ -1640,8 +1617,7 @@
// Get hold of the elements array of the boilerplate and setup the
// elements pointer in the resulting object.
HValue* boilerplate_elements = AddLoadElements(boilerplate);
- HValue* object_elements =
- AddInstruction(new(zone) HInnerAllocatedObject(object,
elems_offset));
+ HValue* object_elements = Add<HInnerAllocatedObject>(object,
elems_offset);
AddStore(object, HObjectAccess::ForElementsPointer(), object_elements);
// Copy the elements array header.
@@ -1655,16 +1631,10 @@
// copying loops with constant length up to a given boundary and use
this
// helper here instead.
for (int i = 0; i < length; i++) {
- HValue* key_constant = AddInstruction(new(zone) HConstant(i));
- HInstruction* value =
- AddInstruction(new(zone) HLoadKeyed(boilerplate_elements,
- key_constant,
- NULL,
- kind));
- AddInstruction(new(zone) HStoreKeyed(object_elements,
- key_constant,
- value,
- kind));
+ HValue* key_constant = Add<HConstant>(i);
+ HInstruction* value = Add<HLoadKeyed>(boilerplate_elements,
key_constant,
+ static_cast<HValue*>(NULL),
kind);
+ Add<HStoreKeyed>(object_elements, key_constant, value, kind);
}
}
@@ -1715,9 +1685,8 @@
HValue* HGraphBuilder::BuildCreateAllocationSiteInfo(HValue*
previous_object,
int
previous_object_size,
HValue* payload) {
- HInnerAllocatedObject* alloc_site = new(zone())
- HInnerAllocatedObject(previous_object, previous_object_size);
- AddInstruction(alloc_site);
+ HInnerAllocatedObject* alloc_site = Add<HInnerAllocatedObject>(
+ previous_object, previous_object_size);
Handle<Map>
alloc_site_map(isolate()->heap()->allocation_site_info_map());
AddStoreMapConstant(alloc_site, alloc_site_map);
HObjectAccess access = HObjectAccess::ForAllocationSitePayload();
@@ -1728,8 +1697,7 @@
HInstruction* HGraphBuilder::BuildGetNativeContext(HValue* context) {
// Get the global context, then the native context
- HInstruction* global_object = AddInstruction(new(zone())
- HGlobalObject(context));
+ HInstruction* global_object = Add<HGlobalObject>(context);
HObjectAccess access = HObjectAccess::ForJSObjectOffset(
GlobalObject::kNativeContextOffset);
return AddLoad(global_object, access);
@@ -1738,11 +1706,9 @@
HInstruction* HGraphBuilder::BuildGetArrayFunction(HValue* context) {
HInstruction* native_context = BuildGetNativeContext(context);
- HInstruction* index = AddInstruction(new(zone())
- HConstant(Context::ARRAY_FUNCTION_INDEX));
-
- return AddInstruction(new (zone())
- HLoadKeyed(native_context, index, NULL, FAST_ELEMENTS));
+ HInstruction* index = Add<HConstant>(Context::ARRAY_FUNCTION_INDEX);
+ return Add<HLoadKeyed>(
+ native_context, index, static_cast<HValue*>(NULL), FAST_ELEMENTS);
}
@@ -1774,24 +1740,22 @@
HValue* HGraphBuilder::JSArrayBuilder::EmitMapCode(HValue* context) {
HInstruction* native_context = builder()->BuildGetNativeContext(context);
- HInstruction* index = builder()->AddInstruction(new(zone())
- HConstant(Context::JS_ARRAY_MAPS_INDEX));
+ HInstruction* index =
builder()->Add<HConstant>(Context::JS_ARRAY_MAPS_INDEX);
- HInstruction* map_array = builder()->AddInstruction(new(zone())
- HLoadKeyed(native_context, index, NULL, FAST_ELEMENTS));
+ HInstruction* map_array = builder()->Add<HLoadKeyed>(
+ native_context, index, static_cast<HValue*>(NULL), FAST_ELEMENTS);
- HInstruction* kind_index = builder()->AddInstruction(new(zone())
- HConstant(kind_));
+ HInstruction* kind_index = builder()->Add<HConstant>(kind_);
- return builder()->AddInstruction(new(zone())
- HLoadKeyed(map_array, kind_index, NULL, FAST_ELEMENTS));
+ return builder()->Add<HLoadKeyed>(
+ map_array, kind_index, static_cast<HValue*>(NULL), FAST_ELEMENTS);
}
HValue* HGraphBuilder::JSArrayBuilder::EmitInternalMapCode() {
// Find the map near the constructor function
HObjectAccess access = HObjectAccess::ForPrototypeOrInitialMap();
- return AddInstruction(
+ return builder()->AddInstruction(
builder()->BuildLoadNamedField(constructor_function_,
access,
Representation::Tagged()));
@@ -1814,18 +1778,17 @@
base_size += FixedArray::kHeaderSize;
}
- HInstruction* elements_size_value = new(zone())
HConstant(elements_size());
- AddInstruction(elements_size_value);
+ HInstruction* elements_size_value =
+ builder()->Add<HConstant>(elements_size());
HInstruction* mul = HMul::New(zone(), context, length_node,
elements_size_value);
mul->ClearFlag(HValue::kCanOverflow);
- AddInstruction(mul);
+ builder()->AddInstruction(mul);
- HInstruction* base = new(zone()) HConstant(base_size);
- AddInstruction(base);
+ HInstruction* base = builder()->Add<HConstant>(base_size);
HInstruction* total_size = HAdd::New(zone(), context, base, mul);
total_size->ClearFlag(HValue::kCanOverflow);
- AddInstruction(total_size);
+ builder()->AddInstruction(total_size);
return total_size;
}
@@ -1840,16 +1803,13 @@
? FixedDoubleArray::SizeFor(initial_capacity())
: FixedArray::SizeFor(initial_capacity());
- HConstant* array_size = new(zone()) HConstant(base_size);
- AddInstruction(array_size);
- return array_size;
+ return builder()->Add<HConstant>(base_size);
}
HValue* HGraphBuilder::JSArrayBuilder::AllocateEmptyArray() {
HValue* size_in_bytes = EstablishEmptyArrayAllocationSize();
- HConstant* capacity = new(zone()) HConstant(initial_capacity());
- AddInstruction(capacity);
+ HConstant* capacity = builder()->Add<HConstant>(initial_capacity());
return AllocateArray(size_in_bytes,
capacity,
builder()->graph()->GetConstant0(),
@@ -1873,9 +1833,8 @@
// Allocate (dealing with failure appropriately)
HAllocate::Flags flags = HAllocate::DefaultFlags(kind_);
- HAllocate* new_object = new(zone()) HAllocate(context, size_in_bytes,
- HType::JSArray(), flags);
- AddInstruction(new_object);
+ HAllocate* new_object = builder()->Add<HAllocate>(context, size_in_bytes,
+ HType::JSArray(),
flags);
// Fill in the fields: map, properties, length
HValue* map;
@@ -1906,10 +1865,7 @@
HObjectAccess access,
HValue *val,
Representation representation) {
- HStoreNamedField *instr = new(zone())
- HStoreNamedField(object, access, val, representation);
- AddInstruction(instr);
- return instr;
+ return Add<HStoreNamedField>(object, access, val, representation);
}
@@ -1917,20 +1873,14 @@
HObjectAccess access,
HValue *typecheck,
Representation representation) {
- HLoadNamedField *instr =
- new(zone()) HLoadNamedField(object, access, typecheck,
representation);
- AddInstruction(instr);
- return instr;
+ return Add<HLoadNamedField>(object, access, typecheck, representation);
}
HStoreNamedField* HGraphBuilder::AddStoreMapConstant(HValue *object,
Handle<Map> map) {
- HValue* constant = AddInstruction(new(zone()) HConstant(map));
- HStoreNamedField *instr =
- new(zone()) HStoreNamedField(object, HObjectAccess::ForMap(),
constant);
- AddInstruction(instr);
- return instr;
+ return Add<HStoreNamedField>(object, HObjectAccess::ForMap(),
+ Add<HConstant>(map));
}
@@ -3702,7 +3652,7 @@
void HOptimizedGraphBuilder::VisitArgument(Expression* expr) {
CHECK_ALIVE(VisitForValue(expr));
- Push(AddInstruction(new(zone()) HPushArgument(Pop())));
+ Push(Add<HPushArgument>(Pop()));
}
@@ -3768,8 +3718,7 @@
AddSimulate(BailoutId::Declarations());
HValue* context = environment()->LookupContext();
- AddInstruction(
- new(zone()) HStackCheck(context, HStackCheck::kFunctionEntry));
+ Add<HStackCheck>(context, HStackCheck::kFunctionEntry);
VisitStatements(current_info()->function()->body());
if (HasStackOverflow()) return false;
@@ -4495,7 +4444,7 @@
isolate()->counters()->soft_deopts_requested()->Increment();
if (FLAG_always_opt) return;
if (current_block()->IsDeoptimizing()) return;
- AddInstruction(new(zone()) HSoftDeoptimize());
+ Add<HSoftDeoptimize>();
isolate()->counters()->soft_deopts_inserted()->Increment();
current_block()->MarkAsDeoptimizing();
graph()->set_has_soft_deoptimize(true);
@@ -4511,16 +4460,15 @@
}
while (!arguments.is_empty()) {
- AddInstruction(new(zone()) HPushArgument(arguments.RemoveLast()));
+ Add<HPushArgument>(arguments.RemoveLast());
}
return call;
}
void HOptimizedGraphBuilder::SetUpScope(Scope* scope) {
- HConstant* undefined_constant = new(zone()) HConstant(
+ HConstant* undefined_constant = Add<HConstant>(
isolate()->factory()->undefined_value());
- AddInstruction(undefined_constant);
graph()->set_undefined_constant(undefined_constant);
// Create an arguments object containing the initial parameters. Set the
@@ -4529,7 +4477,7 @@
HArgumentsObject* arguments_object =
new(zone()) HArgumentsObject(environment()->parameter_count(),
zone());
for (int i = 0; i < environment()->parameter_count(); ++i) {
- HInstruction* parameter = AddInstruction(new(zone()) HParameter(i));
+ HInstruction* parameter = Add<HParameter>(i);
arguments_object->AddArgument(parameter, zone());
environment()->Bind(i, parameter);
}
@@ -4537,7 +4485,7 @@
graph()->SetArgumentsObject(arguments_object);
// First special is HContext.
- HInstruction* context = AddInstruction(new(zone()) HContext);
+ HInstruction* context = Add<HContext>();
environment()->BindContext(context);
// Initialize specials and locals to undefined.
@@ -4976,8 +4924,7 @@
new(zone()) ZoneList<HUnknownOSRValue*>(length, zone());
for (int i = 0; i < first_expression_index; ++i) {
- HUnknownOSRValue* osr_value = new(zone()) HUnknownOSRValue;
- AddInstruction(osr_value);
+ HUnknownOSRValue* osr_value = Add<HUnknownOSRValue>();
environment()->Bind(i, osr_value);
osr_values->Add(osr_value, zone());
}
@@ -4985,8 +4932,7 @@
if (first_expression_index != length) {
environment()->Drop(length - first_expression_index);
for (int i = first_expression_index; i < length; ++i) {
- HUnknownOSRValue* osr_value = new(zone()) HUnknownOSRValue;
- AddInstruction(osr_value);
+ HUnknownOSRValue* osr_value = Add<HUnknownOSRValue>();
environment()->Push(osr_value);
osr_values->Add(osr_value, zone());
}
@@ -4995,9 +4941,8 @@
graph()->set_osr_values(osr_values);
AddSimulate(osr_entry_id);
- AddInstruction(new(zone()) HOsrEntry(osr_entry_id));
- HContext* context = new(zone()) HContext;
- AddInstruction(context);
+ Add<HOsrEntry>(osr_entry_id);
+ HContext* context = Add<HContext>();
environment()->BindContext(context);
current_block()->Goto(loop_predecessor);
loop_predecessor->SetJoinId(statement->EntryId());
@@ -5012,9 +4957,8 @@
BreakAndContinueScope push(break_info, this);
AddSimulate(stmt->StackCheckId());
HValue* context = environment()->LookupContext();
- HStackCheck* stack_check =
- new(zone()) HStackCheck(context, HStackCheck::kBackwardsBranch);
- AddInstruction(stack_check);
+ HStackCheck* stack_check = Add<HStackCheck>(
+ context, HStackCheck::kBackwardsBranch);
ASSERT(loop_entry->IsLoopHeader());
loop_entry->loop_information()->set_stack_check(stack_check);
CHECK_BAILOUT(Visit(stmt->body()));
@@ -5183,30 +5127,24 @@
CHECK_ALIVE(VisitForValue(stmt->enumerable()));
HValue* enumerable = Top(); // Leave enumerable at the top.
- HInstruction* map = AddInstruction(new(zone()) HForInPrepareMap(
- environment()->LookupContext(), enumerable));
+ HInstruction* map = Add<HForInPrepareMap>(
+ environment()->LookupContext(), enumerable);
AddSimulate(stmt->PrepareId());
- HInstruction* array = AddInstruction(
- new(zone()) HForInCacheArray(
- enumerable,
- map,
- DescriptorArray::kEnumCacheBridgeCacheIndex));
+ HInstruction* array = Add<HForInCacheArray>(
+ enumerable, map, DescriptorArray::kEnumCacheBridgeCacheIndex);
- HInstruction* enum_length = AddInstruction(new(zone())
HMapEnumLength(map));
+ HInstruction* enum_length = Add<HMapEnumLength>(map);
- HInstruction* start_index = AddInstruction(new(zone()) HConstant(0));
+ HInstruction* start_index = Add<HConstant>(0);
Push(map);
Push(array);
Push(enum_length);
Push(start_index);
- HInstruction* index_cache = AddInstruction(
- new(zone()) HForInCacheArray(
- enumerable,
- map,
- DescriptorArray::kEnumCacheBridgeIndicesCacheIndex));
+ HInstruction* index_cache = Add<HForInCacheArray>(
+ enumerable, map, DescriptorArray::kEnumCacheBridgeIndicesCacheIndex);
HForInCacheArray::cast(array)->set_index_cache(
HForInCacheArray::cast(index_cache));
@@ -5237,18 +5175,16 @@
set_current_block(loop_body);
- HValue* key = AddInstruction(
- new(zone()) HLoadKeyed(
- environment()->ExpressionStackAt(2), // Enum cache.
- environment()->ExpressionStackAt(0), // Iteration index.
- environment()->ExpressionStackAt(0),
- FAST_ELEMENTS));
+ HValue* key = Add<HLoadKeyed>(
+ environment()->ExpressionStackAt(2), // Enum cache.
+ environment()->ExpressionStackAt(0), // Iteration index.
+ environment()->ExpressionStackAt(0),
+ FAST_ELEMENTS);
// Check if the expected map still matches that of the enumerable.
// If not just deoptimize.
- AddInstruction(new(zone()) HCheckMapValue(
- environment()->ExpressionStackAt(4),
- environment()->ExpressionStackAt(3)));
+ Add<HCheckMapValue>(environment()->ExpressionStackAt(4),
+ environment()->ExpressionStackAt(3));
Bind(each_var, key);
@@ -5421,9 +5357,7 @@
HValue* context = environment()->LookupContext();
int length = current_info()->scope()->ContextChainLength(var->scope());
while (length-- > 0) {
- HInstruction* context_instruction = new(zone()) HOuterContext(context);
- AddInstruction(context_instruction);
- context = context_instruction;
+ context = Add<HOuterContext>(context);
}
return context;
}
@@ -5729,23 +5663,18 @@
flags |= expr->has_function()
? ObjectLiteral::kHasFunction : ObjectLiteral::kNoFlags;
- AddInstruction(new(zone()) HPushArgument(AddInstruction(
- new(zone()) HConstant(closure_literals))));
- AddInstruction(new(zone()) HPushArgument(AddInstruction(
- new(zone()) HConstant(literal_index))));
- AddInstruction(new(zone()) HPushArgument(AddInstruction(
- new(zone()) HConstant(constant_properties))));
- AddInstruction(new(zone()) HPushArgument(AddInstruction(
- new(zone()) HConstant(flags))));
+ Add<HPushArgument>(Add<HConstant>(closure_literals));
+ Add<HPushArgument>(Add<HConstant>(literal_index));
+ Add<HPushArgument>(Add<HConstant>(constant_properties));
+ Add<HPushArgument>(Add<HConstant>(flags));
Runtime::FunctionId function_id =
(expr->depth() > 1 || expr->may_store_doubles())
? Runtime::kCreateObjectLiteral :
Runtime::kCreateObjectLiteralShallow;
- literal = AddInstruction(
- new(zone()) HCallRuntime(context,
- isolate()->factory()->empty_string(),
- Runtime::FunctionForId(function_id),
- 4));
+ literal = Add<HCallRuntime>(context,
+ isolate()->factory()->empty_string(),
+ Runtime::FunctionForId(function_id),
+ 4);
}
// The object is expected in the bailout environment during computation
@@ -5811,8 +5740,7 @@
// of the object. This makes sure that the original object won't
// be used by other optimized code before it is transformed
// (e.g. because of code motion).
- HToFastProperties* result = new(zone()) HToFastProperties(Pop());
- AddInstruction(result);
+ HToFastProperties* result = Add<HToFastProperties>(Pop());
return ast_context()->ReturnValue(result);
} else {
return ast_context()->ReturnValue(Pop());
@@ -5884,20 +5812,16 @@
Handle<FixedArray> constants =
isolate()->factory()->empty_fixed_array();
int literal_index = expr->literal_index();
- AddInstruction(new(zone()) HPushArgument(AddInstruction(
- new(zone()) HConstant(literals))));
- AddInstruction(new(zone()) HPushArgument(AddInstruction(
- new(zone()) HConstant(literal_index))));
- AddInstruction(new(zone()) HPushArgument(AddInstruction(
- new(zone()) HConstant(constants))));
+ Add<HPushArgument>(Add<HConstant>(literals));
+ Add<HPushArgument>(Add<HConstant>(literal_index));
+ Add<HPushArgument>(Add<HConstant>(constants));
Runtime::FunctionId function_id = (expr->depth() > 1)
? Runtime::kCreateArrayLiteral :
Runtime::kCreateArrayLiteralShallow;
- literal = AddInstruction(
- new(zone()) HCallRuntime(context,
- isolate()->factory()->empty_string(),
- Runtime::FunctionForId(function_id),
- 3));
+ literal = Add<HCallRuntime>(context,
+ isolate()->factory()->empty_string(),
+ Runtime::FunctionForId(function_id),
+ 3);
// De-opt if elements kind changed from boilerplate_elements_kind.
Handle<Map> map = Handle<Map>(original_boilerplate_object->map(),
@@ -5909,7 +5833,7 @@
// of the property values and is the value of the entire expression.
Push(literal);
// The literal index is on the stack, too.
- Push(AddInstruction(new(zone()) HConstant(expr->literal_index())));
+ Push(Add<HConstant>(expr->literal_index()));
HInstruction* elements = NULL;
@@ -5925,7 +5849,7 @@
elements = AddLoadElements(literal);
- HValue* key = AddInstruction(new(zone()) HConstant(i));
+ HValue* key = Add<HConstant>(i);
switch (boilerplate_elements_kind) {
case FAST_SMI_ELEMENTS:
@@ -5934,11 +5858,8 @@
case FAST_HOLEY_ELEMENTS:
case FAST_DOUBLE_ELEMENTS:
case FAST_HOLEY_DOUBLE_ELEMENTS:
- AddInstruction(new(zone()) HStoreKeyed(
- elements,
- key,
- value,
- boilerplate_elements_kind));
+ Add<HStoreKeyed>(elements, key, value,
+ boilerplate_elements_kind);
break;
default:
UNREACHABLE();
@@ -6035,11 +5956,9 @@
ASSERT(proto->GetPrototype(isolate())->IsNull());
}
ASSERT(proto->IsJSObject());
- AddInstruction(new(zone()) HCheckPrototypeMaps(
- Handle<JSObject>(JSObject::cast(map->prototype())),
- Handle<JSObject>(JSObject::cast(proto)),
- zone(),
- top_info()));
+
Add<HCheckPrototypeMaps>(Handle<JSObject>(JSObject::cast(map->prototype())),
+ Handle<JSObject>(JSObject::cast(proto)),
+ zone(), top_info());
}
HObjectAccess field_access = HObjectAccess::ForField(map, lookup, name);
@@ -6051,11 +5970,10 @@
if (transition_to_field) {
// The store requires a mutable HeapNumber to be allocated.
NoObservableSideEffectsScope no_side_effects(this);
- HInstruction* heap_number_size = AddInstruction(new(zone())
HConstant(
- HeapNumber::kSize));
- HInstruction* double_box = AddInstruction(new(zone()) HAllocate(
+ HInstruction* heap_number_size = Add<HConstant>(HeapNumber::kSize);
+ HInstruction* double_box = Add<HAllocate>(
environment()->LookupContext(), heap_number_size,
- HType::HeapNumber(), HAllocate::CAN_ALLOCATE_IN_NEW_SPACE));
+ HType::HeapNumber(), HAllocate::CAN_ALLOCATE_IN_NEW_SPACE);
AddStoreMapConstant(double_box,
isolate()->factory()->heap_number_map());
AddStore(double_box, HObjectAccess::ForHeapNumberValue(),
value, Representation::Double());
@@ -6105,8 +6023,8 @@
Handle<JSFunction> setter,
Handle<JSObject> holder) {
AddCheckConstantFunction(holder, object, map);
- AddInstruction(new(zone()) HPushArgument(object));
- AddInstruction(new(zone()) HPushArgument(value));
+ Add<HPushArgument>(object);
+ Add<HPushArgument>(value);
return new(zone()) HCallConstantFunction(setter, 2);
}
@@ -6386,25 +6304,19 @@
if (type == kUseCell) {
Handle<GlobalObject> global(current_info()->global_object());
Handle<PropertyCell> cell(global->GetPropertyCell(&lookup));
- HInstruction* instr =
- new(zone()) HStoreGlobalCell(value, cell,
lookup.GetPropertyDetails());
+ HInstruction* instr = Add<HStoreGlobalCell>(value, cell,
+
lookup.GetPropertyDetails());
instr->set_position(position);
- AddInstruction(instr);
if (instr->HasObservableSideEffects()) {
AddSimulate(ast_id, REMOVABLE_SIMULATE);
}
} else {
HValue* context = environment()->LookupContext();
- HGlobalObject* global_object = new(zone()) HGlobalObject(context);
- AddInstruction(global_object);
+ HGlobalObject* global_object = Add<HGlobalObject>(context);
HStoreGlobalGeneric* instr =
- new(zone()) HStoreGlobalGeneric(context,
- global_object,
- var->name(),
- value,
- function_strict_mode_flag());
+ Add<HStoreGlobalGeneric>(context, global_object, var->name(),
+ value, function_strict_mode_flag());
instr->set_position(position);
- AddInstruction(instr);
ASSERT(instr->HasObservableSideEffects());
AddSimulate(ast_id, REMOVABLE_SIMULATE);
}
@@ -6440,8 +6352,8 @@
return;
}
Drop(2);
- AddInstruction(new(zone()) HPushArgument(object));
- AddInstruction(new(zone()) HPushArgument(value));
+ Add<HPushArgument>(object);
+ Add<HPushArgument>(value);
instr = new(zone()) HCallConstantFunction(setter, 2);
} else {
Drop(2);
@@ -6538,9 +6450,8 @@
}
HValue* context = BuildContextChainWalk(var);
- HStoreContextSlot* instr =
- new(zone()) HStoreContextSlot(context, var->index(), mode,
Top());
- AddInstruction(instr);
+ HStoreContextSlot* instr = Add<HStoreContextSlot>(context,
var->index(),
+ mode, Top());
if (instr->HasObservableSideEffects()) {
AddSimulate(expr->AssignmentId(), REMOVABLE_SIMULATE);
}
@@ -6670,7 +6581,7 @@
// We insert a use of the old value to detect unsupported uses of
const
// variables (e.g. initialization inside a loop).
HValue* old_value = environment()->Lookup(var);
- AddInstruction(new(zone()) HUseConst(old_value));
+ Add<HUseConst>(old_value);
}
} else if (var->mode() == CONST_HARMONY) {
if (expr->op() != Token::INIT_CONST_HARMONY) {
@@ -6751,9 +6662,8 @@
}
HValue* context = BuildContextChainWalk(var);
- HStoreContextSlot* instr = new(zone()) HStoreContextSlot(
- context, var->index(), mode, Top());
- AddInstruction(instr);
+ HStoreContextSlot* instr = Add<HStoreContextSlot>(context,
var->index(),
+ mode, Top());
if (instr->HasObservableSideEffects()) {
AddSimulate(expr->AssignmentId(), REMOVABLE_SIMULATE);
}
@@ -6787,9 +6697,8 @@
HValue* context = environment()->LookupContext();
HValue* value = environment()->Pop();
- HThrow* instr = new(zone()) HThrow(context, value);
+ HThrow* instr = Add<HThrow>(context, value);
instr->set_position(expr->position());
- AddInstruction(instr);
AddSimulate(expr->id());
current_block()->FinishExit(new(zone()) HAbnormalExit);
set_current_block(NULL);
@@ -6835,7 +6744,7 @@
Handle<JSFunction> getter,
Handle<JSObject> holder) {
AddCheckConstantFunction(holder, object, map);
- AddInstruction(new(zone()) HPushArgument(object));
+ Add<HPushArgument>(object);
return new(zone()) HCallConstantFunction(getter, 1);
}
@@ -6880,9 +6789,8 @@
Handle<JSObject> holder(lookup.holder());
Handle<Map> holder_map(holder->map());
AddCheckMap(object, map);
- AddInstruction(new(zone()) HCheckPrototypeMaps(
- prototype, holder, zone(), top_info()));
- HValue* holder_value = AddInstruction(new(zone()) HConstant(holder));
+ Add<HCheckPrototypeMaps>(prototype, holder, zone(), top_info());
+ HValue* holder_value = Add<HConstant>(holder);
return BuildLoadNamedField(holder_value,
HObjectAccess::ForField(holder_map, &lookup, name),
ComputeLoadStoreRepresentation(map, &lookup));
@@ -6894,8 +6802,7 @@
Handle<JSObject> holder(lookup.holder());
Handle<Map> holder_map(holder->map());
AddCheckMap(object, map);
- AddInstruction(new(zone()) HCheckPrototypeMaps(
- prototype, holder, zone(), top_info()));
+ Add<HCheckPrototypeMaps>(prototype, holder, zone(), top_info());
Handle<JSFunction>
function(lookup.GetConstantFunctionFromMap(*holder_map));
return new(zone()) HConstant(function);
}
@@ -6932,8 +6839,7 @@
isolate()->IsFastArrayConstructorPrototypeChainIntact()) {
Handle<JSObject> prototype(JSObject::cast(map->prototype()),
isolate());
Handle<JSObject> object_prototype =
isolate()->initial_object_prototype();
- AddInstruction(new(zone()) HCheckPrototypeMaps(
- prototype, object_prototype, zone(), top_info()));
+ Add<HCheckPrototypeMaps>(prototype, object_prototype, zone(),
top_info());
load_mode = ALLOW_RETURN_HOLE;
graph()->MarkDependsOnEmptyArrayProtoElements();
}
@@ -7065,9 +6971,8 @@
map->elements_kind(),
transition_target.at(i)->elements_kind()));
HValue* context = environment()->LookupContext();
- transition = new(zone()) HTransitionElementsKind(
- context, object, map, transition_target.at(i));
- AddInstruction(transition);
+ transition = Add<HTransitionElementsKind>(context, object, map,
+ transition_target.at(i));
} else {
type_todo[map->elements_kind()] = true;
if (IsExternalArrayElementsKind(map->elements_kind())) {
@@ -7100,8 +7005,7 @@
AddInstruction(HCheckInstanceType::NewIsSpecObject(object, zone()));
HBasicBlock* join = graph()->CreateBasicBlock();
- HInstruction* elements_kind_instr =
- AddInstruction(new(zone()) HElementsKind(object));
+ HInstruction* elements_kind_instr = Add<HElementsKind>(object);
HInstruction* elements = AddLoadElements(object, checkspec);
HLoadExternalArrayPointer* external_elements = NULL;
HInstruction* checked_key = NULL;
@@ -7122,11 +7026,9 @@
LAST_ELEMENTS_KIND);
if (elements_kind == FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND
&& todo_external_array) {
- HInstruction* length =
- AddInstruction(new(zone()) HFixedArrayBaseLength(elements));
+ HInstruction* length = Add<HFixedArrayBaseLength>(elements);
checked_key = Add<HBoundsCheck>(key, length);
- external_elements = new(zone()) HLoadExternalArrayPointer(elements);
- AddInstruction(external_elements);
+ external_elements = Add<HLoadExternalArrayPointer>(elements);
}
if (type_todo[elements_kind]) {
HBasicBlock* if_true = graph()->CreateBasicBlock();
@@ -7317,8 +7219,7 @@
if (!name->IsOneByteEqualTo(STATIC_ASCII_VECTOR("length"))) return
false;
if (function_state()->outer() == NULL) {
- HInstruction* elements = AddInstruction(
- new(zone()) HArgumentsElements(false));
+ HInstruction* elements = Add<HArgumentsElements>(false);
result = new(zone()) HArgumentsLength(elements);
} else {
// Number of arguments without receiver.
@@ -7333,10 +7234,8 @@
HValue* key = Pop();
Drop(1); // Arguments object.
if (function_state()->outer() == NULL) {
- HInstruction* elements = AddInstruction(
- new(zone()) HArgumentsElements(false));
- HInstruction* length = AddInstruction(
- new(zone()) HArgumentsLength(elements));
+ HInstruction* elements = Add<HArgumentsElements>(false);
+ HInstruction* length = Add<HArgumentsLength>(elements);
HInstruction* checked_key = Add<HBoundsCheck>(key, length);
result = new(zone()) HAccessArgumentsAt(elements, length,
checked_key);
} else {
@@ -7346,8 +7245,7 @@
HInstruction* elements = function_state()->arguments_elements();
int argument_count = environment()->
arguments_environment()->parameter_count() - 1;
- HInstruction* length = AddInstruction(new(zone()) HConstant(
- argument_count));
+ HInstruction* length = Add<HConstant>(argument_count);
HInstruction* checked_key = Add<HBoundsCheck>(key, length);
result = new(zone()) HAccessArgumentsAt(elements, length,
checked_key);
}
@@ -7407,7 +7305,7 @@
if (LookupGetter(map, name, &getter, &holder)) {
AddCheckConstantFunction(holder, Top(), map);
if (FLAG_inline_accessors && TryInlineGetter(getter, expr)) return;
- AddInstruction(new(zone()) HPushArgument(Pop()));
+ Add<HPushArgument>(Pop());
instr = new(zone()) HCallConstantFunction(getter, 1);
} else {
instr = BuildLoadNamedMonomorphic(Pop(), name, expr, map);
@@ -7449,8 +7347,7 @@
Handle<Map>
receiver_map) {
if (!holder.is_null()) {
Handle<JSObject> prototype(JSObject::cast(receiver_map->prototype()));
- AddInstruction(new(zone()) HCheckPrototypeMaps(
- prototype, holder, zone(), top_info()));
+ Add<HCheckPrototypeMaps>(prototype, holder, zone(), top_info());
}
}
@@ -7877,9 +7774,7 @@
//
// TODO(kmillikin): implement the same inlining on other platforms so we
// can remove the unsightly ifdefs in this function.
- HConstant* context =
- new(zone()) HConstant(Handle<Context>(target->context()));
- AddInstruction(context);
***The diff for this file has been truncated for email.***
=======================================
--- /branches/bleeding_edge/src/hydrogen.h Fri Jun 28 00:40:35 2013
+++ /branches/bleeding_edge/src/hydrogen.h Fri Jun 28 04:44:16 2013
@@ -996,6 +996,36 @@
I* Add(P1 p1, P2 p2, P3 p3) {
return static_cast<I*>(AddInstruction(new(zone()) I(p1, p2, p3)));
}
+
+ template<class I, class P1, class P2, class P3, class P4>
+ I* Add(P1 p1, P2 p2, P3 p3, P4 p4) {
+ return static_cast<I*>(AddInstruction(new(zone()) I(p1, p2, p3, p4)));
+ }
+
+ template<class I, class P1, class P2, class P3, class P4, class P5>
+ I* Add(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5) {
+ return static_cast<I*>(AddInstruction(new(zone()) I(p1, p2, p3, p4,
p5)));
+ }
+
+ template<class I, class P1, class P2, class P3, class P4, class P5,
class P6>
+ I* Add(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6) {
+ return static_cast<I*>(AddInstruction(
+ new(zone()) I(p1, p2, p3, p4, p5, p6)));
+ }
+
+ template<class I, class P1, class P2, class P3,
+ class P4, class P5, class P6, class P7>
+ I* Add(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7) {
+ return static_cast<I*>(AddInstruction(
+ new(zone()) I(p1, p2, p3, p4, p5, p6, p7)));
+ }
+
+ template<class I, class P1, class P2, class P3, class P4,
+ class P5, class P6, class P7, class P8>
+ I* Add(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8) {
+ return static_cast<I*>(AddInstruction(
+ new(zone()) I(p1, p2, p3, p4, p5, p6, p7, p8)));
+ }
void AddSimulate(BailoutId id,
RemovableSimulate removable = FIXED_SIMULATE);
@@ -1291,9 +1321,6 @@
int elements_size() const {
return IsFastDoubleElementsKind(kind_) ? kDoubleSize : kPointerSize;
}
- HInstruction* AddInstruction(HInstruction* instr) {
- return builder_->AddInstruction(instr);
- }
HGraphBuilder* builder() { return builder_; }
HGraph* graph() { return builder_->graph(); }
int initial_capacity() {
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.