}
-HBoundsCheck* HGraphBuilder::AddBoundsCheck(HValue* index, HValue* length) {
- HBoundsCheck* result = new(graph()->zone()) HBoundsCheck(index, length);
- AddInstruction(result);
- return result;
-}
-
-
HReturn* HGraphBuilder::AddReturn(HValue* value) {
HValue* context = environment()->LookupContext();
int num_parameters = graph()->info()->num_parameters();
length_checker.Else();
- AddBoundsCheck(key, length);
+ Add<HBoundsCheck>(key, length);
environment()->Push(elements);
length_checker.End();
return result;
} else {
ASSERT(store_mode == STANDARD_STORE);
- checked_key = AddBoundsCheck(key, length);
+ checked_key = Add<HBoundsCheck>(key, length);
HLoadExternalArrayPointer* external_elements =
new(zone) HLoadExternalArrayPointer(elements);
AddInstruction(external_elements);
length, key, is_js_array);
checked_key = key;
} else {
- checked_key = AddBoundsCheck(key, length);
+ checked_key = Add<HBoundsCheck>(key, length);
if (is_store && (fast_elements || fast_smi_only_elements)) {
if (store_mode == STORE_NO_TRANSITION_HANDLE_COW) {
&& todo_external_array) {
HInstruction* length =
AddInstruction(new(zone()) HFixedArrayBaseLength(elements));
- checked_key = AddBoundsCheck(key, length);
+ checked_key = Add<HBoundsCheck>(key, length);
external_elements = new(zone()) HLoadExternalArrayPointer(elements);
AddInstruction(external_elements);
}
typecheck, Representation::Smi());
length->set_type(HType::Smi());
- checked_key = AddBoundsCheck(key, length);
+ checked_key = Add<HBoundsCheck>(key, length);
access = AddInstruction(BuildFastElementAccess(
elements, checked_key, val, elements_kind_branch,
elements_kind, is_store, NEVER_RETURN_HOLE, STANDARD_STORE));
set_current_block(if_fastobject);
length = AddInstruction(new(zone()) HFixedArrayBaseLength(elements));
- checked_key = AddBoundsCheck(key, length);
+ checked_key = Add<HBoundsCheck>(key, length);
access = AddInstruction(BuildFastElementAccess(
elements, checked_key, val, elements_kind_branch,
elements_kind, is_store, NEVER_RETURN_HOLE, STANDARD_STORE));
new(zone()) HArgumentsElements(false));
HInstruction* length = AddInstruction(
new(zone()) HArgumentsLength(elements));
- HInstruction* checked_key = AddBoundsCheck(key, length);
+ HInstruction* checked_key = Add<HBoundsCheck>(key, length);
result = new(zone()) HAccessArgumentsAt(elements, length, checked_key);
} else {
EnsureArgumentsArePushedForAccess();
arguments_environment()->parameter_count() - 1;
HInstruction* length = AddInstruction(new(zone()) HConstant(
argument_count));
- HInstruction* checked_key = AddBoundsCheck(key, length);
+ HInstruction* checked_key = Add<HBoundsCheck>(key, length);
result = new(zone()) HAccessArgumentsAt(elements, length, checked_key);
}
}
AddInstruction(HCheckInstanceType::NewIsString(string, zone()));
HInstruction* length = HStringLength::New(zone(), string);
AddInstruction(length);
- HInstruction* checked_index = AddBoundsCheck(index, length);
+ HInstruction* checked_index = Add<HBoundsCheck>(index, length);
return new(zone()) HStringCharCodeAt(context, string, checked_index);
}
HInstruction* elements = AddInstruction(
new(zone()) HArgumentsElements(false));
HInstruction* length = AddInstruction(new(zone()) HArgumentsLength(elements));
- HInstruction* checked_index = AddBoundsCheck(index, length);
+ HInstruction* checked_index = Add<HBoundsCheck>(index, length);
HAccessArgumentsAt* result =
new(zone()) HAccessArgumentsAt(elements, length, checked_index);
return ast_context()->ReturnInstruction(result, call->id());
// Adding instructions.
HInstruction* AddInstruction(HInstruction* instr);
+
+ template<class I>
+ I* Add() { return static_cast<I*>(AddInstruction(new(zone()) I())); }
+
+ template<class I, class P1>
+ I* Add(P1 p1) {
+ return static_cast<I*>(AddInstruction(new(zone()) I(p1)));
+ }
+
+ template<class I, class P1, class P2>
+ I* Add(P1 p1, P2 p2) {
+ return static_cast<I*>(AddInstruction(new(zone()) I(p1, p2)));
+ }
+
+ template<class I, class P1, class P2, class P3>
+ I* Add(P1 p1, P2 p2, P3 p3) {
+ return static_cast<I*>(AddInstruction(new(zone()) I(p1, p2, p3)));
+ }
+
void AddSimulate(BailoutId id,
RemovableSimulate removable = FIXED_SIMULATE);
- HBoundsCheck* AddBoundsCheck(HValue* index, HValue* length);
HReturn* AddReturn(HValue* value);