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

Unified Diff: src/hydrogen.cc

Issue 7132002: Remove RESTORE_CONTEXT flag from ia32 crankshaft codegen. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Completed - use HContext everywhere except for HChange to tagged allocation. Created 9 years, 6 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
Index: src/hydrogen.cc
diff --git a/src/hydrogen.cc b/src/hydrogen.cc
index 5e6b42ebd7c36ee9b0ad346ca2a77faf6750e924..f5955b937fb0399d302f021536ce568075f36a19 100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -2214,7 +2214,9 @@ HGraph* HGraphBuilder::CreateGraph() {
}
SetupScope(scope);
VisitDeclarations(scope->declarations());
- AddInstruction(new(zone()) HStackCheck(HStackCheck::kFunctionEntry));
+ HValue* context = environment()->LookupContext();
+ AddInstruction(
+ new(zone()) HStackCheck(context, HStackCheck::kFunctionEntry));
// Add an edge to the body entry. This is warty: the graph's start
// environment will be used by the Lithium translation as the initial
@@ -2621,8 +2623,9 @@ void HGraphBuilder::VisitSwitchStatement(SwitchStatement* stmt) {
// Otherwise generate a compare and branch.
CHECK_ALIVE(VisitForValue(clause->label()));
HValue* label_value = Pop();
+ HValue* context = environment()->LookupContext();
HCompare* compare =
- new(zone()) HCompare(tag_value, label_value, Token::EQ_STRICT);
+ new(zone()) HCompare(context, tag_value, label_value, Token::EQ_STRICT);
compare->SetInputRepresentation(Representation::Integer32());
ASSERT(!compare->HasSideEffects());
AddInstruction(compare);
@@ -2747,8 +2750,9 @@ void HGraphBuilder::VisitLoopBody(Statement* body,
HBasicBlock* loop_entry,
BreakAndContinueInfo* break_info) {
BreakAndContinueScope push(break_info, this);
+ HValue* context = environment()->LookupContext();
HStackCheck* stack_check =
- new(zone()) HStackCheck(HStackCheck::kBackwardsBranch);
+ new(zone()) HStackCheck(context, HStackCheck::kBackwardsBranch);
AddInstruction(stack_check);
ASSERT(loop_entry->IsLoopHeader());
loop_entry->loop_information()->set_stack_check(stack_check);
@@ -2957,8 +2961,9 @@ void HGraphBuilder::VisitFunctionLiteral(FunctionLiteral* expr) {
}
// We also have a stack overflow if the recursive compilation did.
if (HasStackOverflow()) return;
+ HValue* context = environment()->LookupContext();
HFunctionLiteral* instr =
- new(zone()) HFunctionLiteral(shared_info, expr->pretenure());
+ new(zone()) HFunctionLiteral(context, shared_info, expr->pretenure());
ast_context()->ReturnInstruction(instr, expr->id());
}
@@ -3111,7 +3116,10 @@ void HGraphBuilder::VisitRegExpLiteral(RegExpLiteral* expr) {
ASSERT(!HasStackOverflow());
ASSERT(current_block() != NULL);
ASSERT(current_block()->HasPredecessor());
- HRegExpLiteral* instr = new(zone()) HRegExpLiteral(expr->pattern(),
+ HValue* context = environment()->LookupContext();
+
+ HRegExpLiteral* instr = new(zone()) HRegExpLiteral(context,
+ expr->pattern(),
expr->flags(),
expr->literal_index());
ast_context()->ReturnInstruction(instr, expr->id());
@@ -3197,8 +3205,10 @@ void HGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) {
ASSERT(current_block()->HasPredecessor());
ZoneList<Expression*>* subexprs = expr->values();
int length = subexprs->length();
+ HValue* context = environment()->LookupContext();
- HArrayLiteral* literal = new(zone()) HArrayLiteral(expr->constant_elements(),
+ HArrayLiteral* literal = new(zone()) HArrayLiteral(context,
+ expr->constant_elements(),
length,
expr->literal_index(),
expr->depth());
@@ -3723,8 +3733,9 @@ void HGraphBuilder::VisitThrow(Throw* expr) {
ASSERT(ast_context()->IsEffect());
CHECK_ALIVE(VisitForValue(expr->exception()));
+ HValue* context = environment()->LookupContext();
HValue* value = environment()->Pop();
- HThrow* instr = new(zone()) HThrow(value);
+ HThrow* instr = new(zone()) HThrow(context, value);
instr->set_position(expr->position());
AddInstruction(instr);
AddSimulate(expr->id());
@@ -4132,9 +4143,11 @@ void HGraphBuilder::VisitProperty(Property* expr) {
CHECK_ALIVE(VisitForValue(expr->key()));
HValue* index = Pop();
HValue* string = Pop();
- HStringCharCodeAt* char_code = BuildStringCharCodeAt(string, index);
+ HValue* context = environment()->LookupContext();
+ HStringCharCodeAt* char_code =
+ BuildStringCharCodeAt(context, string, index);
AddInstruction(char_code);
- instr = new(zone()) HStringCharFromCode(char_code);
+ instr = new(zone()) HStringCharFromCode(context, char_code);
} else if (expr->IsFunctionPrototype()) {
HValue* function = Pop();
@@ -4150,7 +4163,8 @@ void HGraphBuilder::VisitProperty(Property* expr) {
instr = BuildLoadNamed(obj, expr, types->first(), name);
} else if (types != NULL && types->length() > 1) {
AddInstruction(new(zone()) HCheckNonSmi(obj));
- instr = new(zone()) HLoadNamedFieldPolymorphic(obj, types, name);
+ HValue* context = environment()->LookupContext();
+ instr = new(zone()) HLoadNamedFieldPolymorphic(context, obj, types, name);
} else {
instr = BuildLoadNamedGeneric(obj, expr);
}
@@ -4549,18 +4563,20 @@ bool HGraphBuilder::TryInlineBuiltinFunction(Call* expr,
if (argument_count == 2 && check_type == STRING_CHECK) {
HValue* index = Pop();
HValue* string = Pop();
+ HValue* context = environment()->LookupContext();
ASSERT(!expr->holder().is_null());
AddInstruction(new(zone()) HCheckPrototypeMaps(
oracle()->GetPrototypeForPrimitiveCheck(STRING_CHECK),
expr->holder()));
- HStringCharCodeAt* char_code = BuildStringCharCodeAt(string, index);
+ HStringCharCodeAt* char_code =
+ BuildStringCharCodeAt(context, string, index);
if (id == kStringCharCodeAt) {
ast_context()->ReturnInstruction(char_code, expr->id());
return true;
}
AddInstruction(char_code);
HStringCharFromCode* result =
- new(zone()) HStringCharFromCode(char_code);
+ new(zone()) HStringCharFromCode(context, char_code);
ast_context()->ReturnInstruction(result, expr->id());
return true;
}
@@ -4575,8 +4591,10 @@ bool HGraphBuilder::TryInlineBuiltinFunction(Call* expr,
if (argument_count == 2 && check_type == RECEIVER_MAP_CHECK) {
AddCheckConstantFunction(expr, receiver, receiver_map, true);
HValue* argument = Pop();
+ HValue* context = environment()->LookupContext();
Drop(1); // Receiver.
- HUnaryMathOperation* op = new(zone()) HUnaryMathOperation(argument, id);
+ HUnaryMathOperation* op =
+ new(zone()) HUnaryMathOperation(context, argument, id);
op->set_position(expr->position());
ast_context()->ReturnInstruction(op, expr->id());
return true;
@@ -4588,31 +4606,33 @@ bool HGraphBuilder::TryInlineBuiltinFunction(Call* expr,
HValue* right = Pop();
HValue* left = Pop();
Pop(); // Pop receiver.
+ HValue* context = environment()->LookupContext();
HInstruction* result = NULL;
// Use sqrt() if exponent is 0.5 or -0.5.
if (right->IsConstant() && HConstant::cast(right)->HasDoubleValue()) {
double exponent = HConstant::cast(right)->DoubleValue();
if (exponent == 0.5) {
- result = new(zone()) HUnaryMathOperation(left, kMathPowHalf);
+ result =
+ new(zone()) HUnaryMathOperation(context, left, kMathPowHalf);
} else if (exponent == -0.5) {
HConstant* double_one =
new(zone()) HConstant(Handle<Object>(Smi::FromInt(1)),
Representation::Double());
AddInstruction(double_one);
HUnaryMathOperation* square_root =
- new(zone()) HUnaryMathOperation(left, kMathPowHalf);
+ new(zone()) HUnaryMathOperation(context, left, kMathPowHalf);
AddInstruction(square_root);
// MathPowHalf doesn't have side effects so there's no need for
// an environment simulation here.
ASSERT(!square_root->HasSideEffects());
- result = new(zone()) HDiv(double_one, square_root);
+ result = new(zone()) HDiv(context, double_one, square_root);
} else if (exponent == 2.0) {
- result = new(zone()) HMul(left, left);
+ result = new(zone()) HMul(context, left, left);
}
} else if (right->IsConstant() &&
HConstant::cast(right)->HasInteger32Value() &&
HConstant::cast(right)->Integer32Value() == 2) {
- result = new(zone()) HMul(left, left);
+ result = new(zone()) HMul(context, left, left);
}
if (result == NULL) {
@@ -4898,10 +4918,11 @@ void HGraphBuilder::VisitCallRuntime(CallRuntime* expr) {
ASSERT(function->intrinsic_type == Runtime::RUNTIME);
CHECK_ALIVE(VisitArgumentList(expr->arguments()));
+ HValue* context = environment()->LookupContext();
Handle<String> name = expr->name();
int argument_count = expr->arguments()->length();
HCallRuntime* call =
- new(zone()) HCallRuntime(name, function, argument_count);
+ new(zone()) HCallRuntime(context, name, function, argument_count);
call->set_position(RelocInfo::kNoPosition);
Drop(argument_count);
ast_context()->ReturnInstruction(call, expr->id());
@@ -4950,7 +4971,8 @@ void HGraphBuilder::VisitDelete(UnaryOperation* expr) {
CHECK_ALIVE(VisitForValue(prop->key()));
HValue* key = Pop();
HValue* obj = Pop();
- HDeleteProperty* instr = new(zone()) HDeleteProperty(obj, key);
+ HValue* context = environment()->LookupContext();
+ HDeleteProperty* instr = new(zone()) HDeleteProperty(context, obj, key);
ast_context()->ReturnInstruction(instr, expr->id());
}
} else if (var->is_global()) {
@@ -4970,14 +4992,18 @@ void HGraphBuilder::VisitVoid(UnaryOperation* expr) {
void HGraphBuilder::VisitTypeof(UnaryOperation* expr) {
CHECK_ALIVE(VisitForTypeOf(expr->expression()));
HValue* value = Pop();
- ast_context()->ReturnInstruction(new(zone()) HTypeof(value), expr->id());
+ HValue* context = environment()->LookupContext();
+ HInstruction* instr = new(zone()) HTypeof(context, value);
+ ast_context()->ReturnInstruction(instr, expr->id());
}
void HGraphBuilder::VisitAdd(UnaryOperation* expr) {
CHECK_ALIVE(VisitForValue(expr->expression()));
HValue* value = Pop();
- HInstruction* instr = new(zone()) HMul(value, graph_->GetConstant1());
+ HValue* context = environment()->LookupContext();
+ HInstruction* instr =
+ new(zone()) HMul(context, value, graph_->GetConstant1());
ast_context()->ReturnInstruction(instr, expr->id());
}
@@ -4985,7 +5011,9 @@ void HGraphBuilder::VisitAdd(UnaryOperation* expr) {
void HGraphBuilder::VisitSub(UnaryOperation* expr) {
CHECK_ALIVE(VisitForValue(expr->expression()));
HValue* value = Pop();
- HInstruction* instr = new(zone()) HMul(value, graph_->GetConstantMinus1());
+ HValue* context = environment()->LookupContext();
+ HInstruction* instr =
+ new(zone()) HMul(context, value, graph_->GetConstantMinus1());
TypeInfo info = oracle()->UnaryType(expr);
if (info.IsUninitialized()) {
AddInstruction(new(zone()) HSoftDeoptimize);
@@ -5082,7 +5110,8 @@ HInstruction* HGraphBuilder::BuildIncrement(bool returns_original_input,
HConstant* delta = (expr->op() == Token::INC)
? graph_->GetConstant1()
: graph_->GetConstantMinus1();
- HInstruction* instr = new(zone()) HAdd(Top(), delta);
+ HValue* context = environment()->LookupContext();
+ HInstruction* instr = new(zone()) HAdd(context, Top(), delta);
TraceRepresentation(expr->op(), info, instr, rep);
instr->AssumeRepresentation(rep);
AddInstruction(instr);
@@ -5232,7 +5261,8 @@ void HGraphBuilder::VisitCountOperation(CountOperation* expr) {
}
-HStringCharCodeAt* HGraphBuilder::BuildStringCharCodeAt(HValue* string,
+HStringCharCodeAt* HGraphBuilder::BuildStringCharCodeAt(HValue* context,
+ HValue* string,
HValue* index) {
AddInstruction(new(zone()) HCheckNonSmi(string));
AddInstruction(HCheckInstanceType::NewIsString(string));
@@ -5240,13 +5270,14 @@ HStringCharCodeAt* HGraphBuilder::BuildStringCharCodeAt(HValue* string,
AddInstruction(length);
HInstruction* checked_index =
AddInstruction(new(zone()) HBoundsCheck(index, length));
- return new(zone()) HStringCharCodeAt(string, checked_index);
+ return new(zone()) HStringCharCodeAt(context, string, checked_index);
}
HInstruction* HGraphBuilder::BuildBinaryOperation(BinaryOperation* expr,
HValue* left,
HValue* right) {
+ HValue* context = environment()->LookupContext();
TypeInfo info = oracle()->BinaryType(expr);
if (info.IsUninitialized()) {
AddInstruction(new(zone()) HSoftDeoptimize);
@@ -5261,40 +5292,40 @@ HInstruction* HGraphBuilder::BuildBinaryOperation(BinaryOperation* expr,
AddInstruction(HCheckInstanceType::NewIsString(left));
AddInstruction(new(zone()) HCheckNonSmi(right));
AddInstruction(HCheckInstanceType::NewIsString(right));
- instr = new(zone()) HStringAdd(left, right);
+ instr = new(zone()) HStringAdd(context, left, right);
} else {
- instr = new(zone()) HAdd(left, right);
+ instr = new(zone()) HAdd(context, left, right);
}
break;
case Token::SUB:
- instr = new(zone()) HSub(left, right);
+ instr = new(zone()) HSub(context, left, right);
break;
case Token::MUL:
- instr = new(zone()) HMul(left, right);
+ instr = new(zone()) HMul(context, left, right);
break;
case Token::MOD:
- instr = new(zone()) HMod(left, right);
+ instr = new(zone()) HMod(context, left, right);
break;
case Token::DIV:
- instr = new(zone()) HDiv(left, right);
+ instr = new(zone()) HDiv(context, left, right);
break;
case Token::BIT_XOR:
- instr = new(zone()) HBitXor(left, right);
+ instr = new(zone()) HBitXor(context, left, right);
break;
case Token::BIT_AND:
- instr = new(zone()) HBitAnd(left, right);
+ instr = new(zone()) HBitAnd(context, left, right);
break;
case Token::BIT_OR:
- instr = new(zone()) HBitOr(left, right);
+ instr = new(zone()) HBitOr(context, left, right);
break;
case Token::SAR:
- instr = new(zone()) HSar(left, right);
+ instr = new(zone()) HSar(context, left, right);
break;
case Token::SHR:
- instr = new(zone()) HShr(left, right);
+ instr = new(zone()) HShr(context, left, right);
break;
case Token::SHL:
- instr = new(zone()) HShl(left, right);
+ instr = new(zone()) HShl(context, left, right);
break;
default:
UNREACHABLE();
@@ -5581,12 +5612,12 @@ void HGraphBuilder::VisitCompareOperation(CompareOperation* expr) {
// If the target is not null we have found a known global function that is
// assumed to stay the same for this instanceof.
+ HValue* context = environment()->LookupContext();
if (target.is_null()) {
- HValue* context = environment()->LookupContext();
instr = new(zone()) HInstanceOf(context, left, right);
} else {
AddInstruction(new(zone()) HCheckFunction(right, target));
- instr = new(zone()) HInstanceOfKnownGlobal(left, target);
+ instr = new(zone()) HInstanceOfKnownGlobal(context, left, target);
}
} else if (op == Token::IN) {
instr = new(zone()) HIn(left, right);
@@ -5613,7 +5644,8 @@ void HGraphBuilder::VisitCompareOperation(CompareOperation* expr) {
AddInstruction(HCheckInstanceType::NewIsSymbol(right));
instr = new(zone()) HCompareObjectEq(left, right);
} else {
- HCompare* compare = new(zone()) HCompare(left, right, op);
+ HValue* context = environment()->LookupContext();
+ HCompare* compare = new(zone()) HCompare(context, left, right, op);
Representation r = ToRepresentation(type_info);
compare->SetInputRepresentation(r);
instr = compare;
@@ -5821,7 +5853,8 @@ void HGraphBuilder::GenerateStringCharCodeAt(CallRuntime* call) {
CHECK_ALIVE(VisitForValue(call->arguments()->at(1)));
HValue* index = Pop();
HValue* string = Pop();
- HStringCharCodeAt* result = BuildStringCharCodeAt(string, index);
+ HValue* context = environment()->LookupContext();
+ HStringCharCodeAt* result = BuildStringCharCodeAt(context, string, index);
ast_context()->ReturnInstruction(result, call->id());
}
@@ -5831,7 +5864,9 @@ void HGraphBuilder::GenerateStringCharFromCode(CallRuntime* call) {
ASSERT(call->arguments()->length() == 1);
CHECK_ALIVE(VisitForValue(call->arguments()->at(0)));
HValue* char_code = Pop();
- HStringCharFromCode* result = new(zone()) HStringCharFromCode(char_code);
+ HValue* context = environment()->LookupContext();
+ HStringCharFromCode* result =
+ new(zone()) HStringCharFromCode(context, char_code);
ast_context()->ReturnInstruction(result, call->id());
}
@@ -5843,9 +5878,11 @@ void HGraphBuilder::GenerateStringCharAt(CallRuntime* call) {
CHECK_ALIVE(VisitForValue(call->arguments()->at(1)));
HValue* index = Pop();
HValue* string = Pop();
- HStringCharCodeAt* char_code = BuildStringCharCodeAt(string, index);
+ HValue* context = environment()->LookupContext();
+ HStringCharCodeAt* char_code = BuildStringCharCodeAt(context, string, index);
AddInstruction(char_code);
- HStringCharFromCode* result = new(zone()) HStringCharFromCode(char_code);
+ HStringCharFromCode* result =
+ new(zone()) HStringCharFromCode(context, char_code);
ast_context()->ReturnInstruction(result, call->id());
}
« no previous file with comments | « src/hydrogen.h ('k') | src/hydrogen-instructions.h » ('j') | src/hydrogen-instructions.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698