| Index: src/hydrogen.cc
|
| diff --git a/src/hydrogen.cc b/src/hydrogen.cc
|
| index 40386aaaae26882cc865f7be039b93fbb627b552..e73198da3e9afcf75b003c40756ee5df1233baba 100644
|
| --- a/src/hydrogen.cc
|
| +++ b/src/hydrogen.cc
|
| @@ -157,8 +157,20 @@ HPhi* HBasicBlock::AddNewPhi(int merged_index) {
|
| }
|
|
|
|
|
| +HSimulate* HBasicBlock::AddNewSimulate(
|
| + BailoutId ast_id,
|
| + HSourcePosition position,
|
| + RemovableSimulate removable,
|
| + int arguments_offset) {
|
| + HSimulate* instr = CreateSimulate(ast_id, removable, arguments_offset);
|
| + AddInstruction(instr, position);
|
| + return instr;
|
| +}
|
| +
|
| +
|
| HSimulate* HBasicBlock::CreateSimulate(BailoutId ast_id,
|
| - RemovableSimulate removable) {
|
| + RemovableSimulate removable,
|
| + int arguments_offset) {
|
| ASSERT(HasEnvironment());
|
| HEnvironment* environment = last_environment();
|
| ASSERT(ast_id.IsNone() ||
|
| @@ -187,6 +199,10 @@ HSimulate* HBasicBlock::CreateSimulate(BailoutId ast_id,
|
| instr->AddAssignedValue(index, environment->Lookup(index));
|
| }
|
| environment->ClearHistory();
|
| +#if defined(COMPARE_OPT_STACK_HEIGHT)
|
| + environment->VerifyStackHeight(
|
| + ast_id, instr->id(), arguments_offset);
|
| +#endif
|
| return instr;
|
| }
|
|
|
| @@ -256,7 +272,7 @@ void HBasicBlock::UpdateEnvironment(HEnvironment* env) {
|
| }
|
|
|
|
|
| -void HBasicBlock::SetJoinId(BailoutId ast_id) {
|
| +void HBasicBlock::SetJoinId(BailoutId ast_id, int stack_check_offset) {
|
| int length = predecessors_.length();
|
| ASSERT(length > 0);
|
| for (int i = 0; i < length; i++) {
|
| @@ -268,6 +284,10 @@ void HBasicBlock::SetJoinId(BailoutId ast_id) {
|
| predecessor->last_environment()->closure()->shared()
|
| ->VerifyBailoutId(ast_id)));
|
| simulate->set_ast_id(ast_id);
|
| +#if defined(COMPARE_OPT_STACK_HEIGHT)
|
| + predecessor->last_environment()->VerifyStackHeight(
|
| + ast_id, simulate->id(), stack_check_offset);
|
| +#endif
|
| predecessor->last_environment()->set_ast_id(ast_id);
|
| }
|
| }
|
| @@ -1205,10 +1225,12 @@ void HGraphBuilder::AddIncrementCounter(StatsCounter* counter) {
|
|
|
|
|
| void HGraphBuilder::AddSimulate(BailoutId id,
|
| - RemovableSimulate removable) {
|
| + RemovableSimulate removable,
|
| + int arguments_offset) {
|
| ASSERT(current_block() != NULL);
|
| ASSERT(!graph()->IsInsideNoSideEffectsScope());
|
| - current_block()->AddNewSimulate(id, source_position(), removable);
|
| + current_block()->AddNewSimulate(
|
| + id, source_position(), removable, arguments_offset);
|
| }
|
|
|
|
|
| @@ -4410,7 +4432,8 @@ void HOptimizedGraphBuilder::VisitReturnStatement(ReturnStatement* stmt) {
|
| CHECK_ALIVE(VisitForEffect(stmt->expression()));
|
| Goto(test->if_true(), state);
|
| } else if (context->IsEffect()) {
|
| - CHECK_ALIVE(VisitForEffect(stmt->expression()));
|
| + CHECK_ALIVE(VisitForValue(stmt->expression()));
|
| + Drop(1);
|
| Goto(function_return(), state);
|
| } else {
|
| ASSERT(context->IsValue());
|
| @@ -7573,13 +7596,13 @@ bool HOptimizedGraphBuilder::TryInline(Handle<JSFunction> target,
|
| // Forward to the real test context.
|
| if (if_true->HasPredecessor()) {
|
| entry->RegisterReturnTarget(if_true, zone());
|
| - if_true->SetJoinId(ast_id);
|
| + if_true->SetJoinId(ast_id, -1);
|
| HBasicBlock* true_target = TestContext::cast(ast_context())->if_true();
|
| Goto(if_true, true_target, function_state());
|
| }
|
| if (if_false->HasPredecessor()) {
|
| entry->RegisterReturnTarget(if_false, zone());
|
| - if_false->SetJoinId(ast_id);
|
| + if_false->SetJoinId(ast_id, -1);
|
| HBasicBlock* false_target = TestContext::cast(ast_context())->if_false();
|
| Goto(if_false, false_target, function_state());
|
| }
|
| @@ -10854,7 +10877,13 @@ void HOptimizedGraphBuilder::GenerateOneByteSeqStringSetChar(
|
| HValue* index = Pop();
|
| Add<HSeqStringSetChar>(String::ONE_BYTE_ENCODING, string,
|
| index, value);
|
| - Add<HSimulate>(call->id(), FIXED_SIMULATE);
|
| + if (ast_context()->IsEffect()) {
|
| + Add<HSimulate>(call->id(), FIXED_SIMULATE);
|
| + } else {
|
| + Push(graph()->GetConstantUndefined());
|
| + Add<HSimulate>(call->id(), FIXED_SIMULATE);
|
| + Pop();
|
| + }
|
| return ast_context()->ReturnValue(graph()->GetConstantUndefined());
|
| }
|
|
|
| @@ -10871,7 +10900,13 @@ void HOptimizedGraphBuilder::GenerateTwoByteSeqStringSetChar(
|
| HValue* index = Pop();
|
| Add<HSeqStringSetChar>(String::TWO_BYTE_ENCODING, string,
|
| index, value);
|
| - Add<HSimulate>(call->id(), FIXED_SIMULATE);
|
| + if (ast_context()->IsEffect()) {
|
| + Add<HSimulate>(call->id(), FIXED_SIMULATE);
|
| + } else {
|
| + Push(graph()->GetConstantUndefined());
|
| + Add<HSimulate>(call->id(), FIXED_SIMULATE);
|
| + Pop();
|
| + }
|
| return ast_context()->ReturnValue(graph()->GetConstantUndefined());
|
| }
|
|
|
| @@ -11474,6 +11509,29 @@ void HEnvironment::PrintToStd() {
|
| }
|
|
|
|
|
| +void HEnvironment::VerifyStackHeight(
|
| + BailoutId ast_id,
|
| + int hydrogen_id,
|
| + int stack_height_offset) {
|
| +#if defined(COMPARE_OPT_STACK_HEIGHT)
|
| + if (!ast_id.IsNone() && ast_id != BailoutId::StubEntry()) {
|
| + int hydrogen_height = length() - specials_count() - parameter_count();
|
| + int expected_stack_height =
|
| + closure()->shared()->GetExpectedStackHeight(ast_id) +
|
| + stack_height_offset;
|
| +
|
| + if (expected_stack_height != hydrogen_height) {
|
| + V8_Fatal(__FILE__, __LINE__,
|
| + "Stack height mismatch.\n"
|
| + "Hydrogen height = %4i, "
|
| + "unoptimized height = %4i, AST id = %i\n",
|
| + hydrogen_height, expected_stack_height, ast_id.ToInt());
|
| + }
|
| + }
|
| +#endif
|
| +}
|
| +
|
| +
|
| void HTracer::TraceCompilation(CompilationInfo* info) {
|
| Tag tag(this, "compilation");
|
| if (info->IsOptimizing()) {
|
|
|