| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 } | 186 } |
| 187 | 187 |
| 188 | 188 |
| 189 void BreakableStatementChecker::VisitDebuggerStatement( | 189 void BreakableStatementChecker::VisitDebuggerStatement( |
| 190 DebuggerStatement* stmt) { | 190 DebuggerStatement* stmt) { |
| 191 // The debugger statement is breakable. | 191 // The debugger statement is breakable. |
| 192 is_breakable_ = true; | 192 is_breakable_ = true; |
| 193 } | 193 } |
| 194 | 194 |
| 195 | 195 |
| 196 void BreakableStatementChecker::VisitCaseClause(CaseClause* clause) { |
| 197 } |
| 198 |
| 199 |
| 196 void BreakableStatementChecker::VisitFunctionLiteral(FunctionLiteral* expr) { | 200 void BreakableStatementChecker::VisitFunctionLiteral(FunctionLiteral* expr) { |
| 197 } | 201 } |
| 198 | 202 |
| 199 | 203 |
| 200 void BreakableStatementChecker::VisitNativeFunctionLiteral( | 204 void BreakableStatementChecker::VisitNativeFunctionLiteral( |
| 201 NativeFunctionLiteral* expr) { | 205 NativeFunctionLiteral* expr) { |
| 202 } | 206 } |
| 203 | 207 |
| 204 | 208 |
| 205 void BreakableStatementChecker::VisitConditional(Conditional* expr) { | 209 void BreakableStatementChecker::VisitConditional(Conditional* expr) { |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 Handle<Code> code = CodeGenerator::MakeCodeEpilogue(&masm, flags, info); | 338 Handle<Code> code = CodeGenerator::MakeCodeEpilogue(&masm, flags, info); |
| 335 code->set_optimizable(info->IsOptimizable() && | 339 code->set_optimizable(info->IsOptimizable() && |
| 336 !info->function()->dont_optimize() && | 340 !info->function()->dont_optimize() && |
| 337 info->function()->scope()->AllowsLazyCompilation()); | 341 info->function()->scope()->AllowsLazyCompilation()); |
| 338 cgen.PopulateDeoptimizationData(code); | 342 cgen.PopulateDeoptimizationData(code); |
| 339 cgen.PopulateTypeFeedbackInfo(code); | 343 cgen.PopulateTypeFeedbackInfo(code); |
| 340 cgen.PopulateTypeFeedbackCells(code); | 344 cgen.PopulateTypeFeedbackCells(code); |
| 341 code->set_has_deoptimization_support(info->HasDeoptimizationSupport()); | 345 code->set_has_deoptimization_support(info->HasDeoptimizationSupport()); |
| 342 code->set_handler_table(*cgen.handler_table()); | 346 code->set_handler_table(*cgen.handler_table()); |
| 343 #ifdef ENABLE_DEBUGGER_SUPPORT | 347 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 344 code->set_has_debug_break_slots( | |
| 345 info->isolate()->debugger()->IsDebuggerActive()); | |
| 346 code->set_compiled_optimizable(info->IsOptimizable()); | 348 code->set_compiled_optimizable(info->IsOptimizable()); |
| 347 #endif // ENABLE_DEBUGGER_SUPPORT | 349 #endif // ENABLE_DEBUGGER_SUPPORT |
| 348 code->set_allow_osr_at_loop_nesting_level(0); | 350 code->set_allow_osr_at_loop_nesting_level(0); |
| 349 code->set_profiler_ticks(0); | 351 code->set_profiler_ticks(0); |
| 350 code->set_back_edge_table_offset(table_offset); | 352 code->set_back_edge_table_offset(table_offset); |
| 351 code->set_back_edges_patched_for_osr(false); | 353 code->set_back_edges_patched_for_osr(false); |
| 352 CodeGenerator::PrintCode(code, info); | 354 CodeGenerator::PrintCode(code, info); |
| 353 info->SetCode(code); | 355 info->SetCode(code); |
| 354 #ifdef ENABLE_GDB_JIT_INTERFACE | 356 #ifdef ENABLE_GDB_JIT_INTERFACE |
| 355 if (FLAG_gdbjit) { | 357 if (FLAG_gdbjit) { |
| (...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 819 | 821 |
| 820 | 822 |
| 821 void FullCodeGenerator::SetReturnPosition(FunctionLiteral* fun) { | 823 void FullCodeGenerator::SetReturnPosition(FunctionLiteral* fun) { |
| 822 CodeGenerator::RecordPositions(masm_, fun->end_position() - 1); | 824 CodeGenerator::RecordPositions(masm_, fun->end_position() - 1); |
| 823 } | 825 } |
| 824 | 826 |
| 825 | 827 |
| 826 void FullCodeGenerator::SetStatementPosition(Statement* stmt) { | 828 void FullCodeGenerator::SetStatementPosition(Statement* stmt) { |
| 827 #ifdef ENABLE_DEBUGGER_SUPPORT | 829 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 828 if (!isolate()->debugger()->IsDebuggerActive()) { | 830 if (!isolate()->debugger()->IsDebuggerActive()) { |
| 829 CodeGenerator::RecordPositions(masm_, stmt->statement_pos()); | 831 CodeGenerator::RecordPositions(masm_, stmt->position()); |
| 830 } else { | 832 } else { |
| 831 // Check if the statement will be breakable without adding a debug break | 833 // Check if the statement will be breakable without adding a debug break |
| 832 // slot. | 834 // slot. |
| 833 BreakableStatementChecker checker(isolate()); | 835 BreakableStatementChecker checker(isolate()); |
| 834 checker.Check(stmt); | 836 checker.Check(stmt); |
| 835 // Record the statement position right here if the statement is not | 837 // Record the statement position right here if the statement is not |
| 836 // breakable. For breakable statements the actual recording of the | 838 // breakable. For breakable statements the actual recording of the |
| 837 // position will be postponed to the breakable code (typically an IC). | 839 // position will be postponed to the breakable code (typically an IC). |
| 838 bool position_recorded = CodeGenerator::RecordPositions( | 840 bool position_recorded = CodeGenerator::RecordPositions( |
| 839 masm_, stmt->statement_pos(), !checker.is_breakable()); | 841 masm_, stmt->position(), !checker.is_breakable()); |
| 840 // If the position recording did record a new position generate a debug | 842 // If the position recording did record a new position generate a debug |
| 841 // break slot to make the statement breakable. | 843 // break slot to make the statement breakable. |
| 842 if (position_recorded) { | 844 if (position_recorded) { |
| 843 Debug::GenerateSlot(masm_); | 845 Debug::GenerateSlot(masm_); |
| 844 } | 846 } |
| 845 } | 847 } |
| 846 #else | 848 #else |
| 847 CodeGenerator::RecordPositions(masm_, stmt->statement_pos()); | 849 CodeGenerator::RecordPositions(masm_, stmt->position()); |
| 848 #endif | 850 #endif |
| 849 } | 851 } |
| 850 | 852 |
| 851 | 853 |
| 852 void FullCodeGenerator::SetExpressionPosition(Expression* expr, int pos) { | 854 void FullCodeGenerator::SetExpressionPosition(Expression* expr) { |
| 853 #ifdef ENABLE_DEBUGGER_SUPPORT | 855 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 854 if (!isolate()->debugger()->IsDebuggerActive()) { | 856 if (!isolate()->debugger()->IsDebuggerActive()) { |
| 855 CodeGenerator::RecordPositions(masm_, pos); | 857 CodeGenerator::RecordPositions(masm_, expr->position()); |
| 856 } else { | 858 } else { |
| 857 // Check if the expression will be breakable without adding a debug break | 859 // Check if the expression will be breakable without adding a debug break |
| 858 // slot. | 860 // slot. |
| 859 BreakableStatementChecker checker(isolate()); | 861 BreakableStatementChecker checker(isolate()); |
| 860 checker.Check(expr); | 862 checker.Check(expr); |
| 861 // Record a statement position right here if the expression is not | 863 // Record a statement position right here if the expression is not |
| 862 // breakable. For breakable expressions the actual recording of the | 864 // breakable. For breakable expressions the actual recording of the |
| 863 // position will be postponed to the breakable code (typically an IC). | 865 // position will be postponed to the breakable code (typically an IC). |
| 864 // NOTE this will record a statement position for something which might | 866 // NOTE this will record a statement position for something which might |
| 865 // not be a statement. As stepping in the debugger will only stop at | 867 // not be a statement. As stepping in the debugger will only stop at |
| 866 // statement positions this is used for e.g. the condition expression of | 868 // statement positions this is used for e.g. the condition expression of |
| 867 // a do while loop. | 869 // a do while loop. |
| 868 bool position_recorded = CodeGenerator::RecordPositions( | 870 bool position_recorded = CodeGenerator::RecordPositions( |
| 869 masm_, pos, !checker.is_breakable()); | 871 masm_, expr->position(), !checker.is_breakable()); |
| 870 // If the position recording did record a new position generate a debug | 872 // If the position recording did record a new position generate a debug |
| 871 // break slot to make the statement breakable. | 873 // break slot to make the statement breakable. |
| 872 if (position_recorded) { | 874 if (position_recorded) { |
| 873 Debug::GenerateSlot(masm_); | 875 Debug::GenerateSlot(masm_); |
| 874 } | 876 } |
| 875 } | 877 } |
| 876 #else | 878 #else |
| 877 CodeGenerator::RecordPositions(masm_, pos); | 879 CodeGenerator::RecordPositions(masm_, pos); |
| 878 #endif | 880 #endif |
| 879 } | 881 } |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1286 Iteration loop_statement(this, stmt); | 1288 Iteration loop_statement(this, stmt); |
| 1287 increment_loop_depth(); | 1289 increment_loop_depth(); |
| 1288 | 1290 |
| 1289 __ bind(&body); | 1291 __ bind(&body); |
| 1290 Visit(stmt->body()); | 1292 Visit(stmt->body()); |
| 1291 | 1293 |
| 1292 // Record the position of the do while condition and make sure it is | 1294 // Record the position of the do while condition and make sure it is |
| 1293 // possible to break on the condition. | 1295 // possible to break on the condition. |
| 1294 __ bind(loop_statement.continue_label()); | 1296 __ bind(loop_statement.continue_label()); |
| 1295 PrepareForBailoutForId(stmt->ContinueId(), NO_REGISTERS); | 1297 PrepareForBailoutForId(stmt->ContinueId(), NO_REGISTERS); |
| 1296 SetExpressionPosition(stmt->cond(), stmt->condition_position()); | 1298 SetExpressionPosition(stmt->cond()); |
| 1297 VisitForControl(stmt->cond(), | 1299 VisitForControl(stmt->cond(), |
| 1298 &book_keeping, | 1300 &book_keeping, |
| 1299 loop_statement.break_label(), | 1301 loop_statement.break_label(), |
| 1300 &book_keeping); | 1302 &book_keeping); |
| 1301 | 1303 |
| 1302 // Check stack before looping. | 1304 // Check stack before looping. |
| 1303 PrepareForBailoutForId(stmt->BackEdgeId(), NO_REGISTERS); | 1305 PrepareForBailoutForId(stmt->BackEdgeId(), NO_REGISTERS); |
| 1304 __ bind(&book_keeping); | 1306 __ bind(&book_keeping); |
| 1305 EmitBackEdgeBookkeeping(stmt, &body); | 1307 EmitBackEdgeBookkeeping(stmt, &body); |
| 1306 __ jmp(&body); | 1308 __ jmp(&body); |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1508 #ifdef ENABLE_DEBUGGER_SUPPORT | 1510 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 1509 Comment cmnt(masm_, "[ DebuggerStatement"); | 1511 Comment cmnt(masm_, "[ DebuggerStatement"); |
| 1510 SetStatementPosition(stmt); | 1512 SetStatementPosition(stmt); |
| 1511 | 1513 |
| 1512 __ DebugBreak(); | 1514 __ DebugBreak(); |
| 1513 // Ignore the return value. | 1515 // Ignore the return value. |
| 1514 #endif | 1516 #endif |
| 1515 } | 1517 } |
| 1516 | 1518 |
| 1517 | 1519 |
| 1520 void FullCodeGenerator::VisitCaseClause(CaseClause* clause) { |
| 1521 UNREACHABLE(); |
| 1522 } |
| 1523 |
| 1524 |
| 1518 void FullCodeGenerator::VisitConditional(Conditional* expr) { | 1525 void FullCodeGenerator::VisitConditional(Conditional* expr) { |
| 1519 Comment cmnt(masm_, "[ Conditional"); | 1526 Comment cmnt(masm_, "[ Conditional"); |
| 1520 Label true_case, false_case, done; | 1527 Label true_case, false_case, done; |
| 1521 VisitForControl(expr->condition(), &true_case, &false_case, &true_case); | 1528 VisitForControl(expr->condition(), &true_case, &false_case, &true_case); |
| 1522 | 1529 |
| 1523 PrepareForBailoutForId(expr->ThenId(), NO_REGISTERS); | 1530 PrepareForBailoutForId(expr->ThenId(), NO_REGISTERS); |
| 1524 __ bind(&true_case); | 1531 __ bind(&true_case); |
| 1525 SetExpressionPosition(expr->then_expression(), | 1532 SetExpressionPosition(expr->then_expression()); |
| 1526 expr->then_expression_position()); | |
| 1527 if (context()->IsTest()) { | 1533 if (context()->IsTest()) { |
| 1528 const TestContext* for_test = TestContext::cast(context()); | 1534 const TestContext* for_test = TestContext::cast(context()); |
| 1529 VisitForControl(expr->then_expression(), | 1535 VisitForControl(expr->then_expression(), |
| 1530 for_test->true_label(), | 1536 for_test->true_label(), |
| 1531 for_test->false_label(), | 1537 for_test->false_label(), |
| 1532 NULL); | 1538 NULL); |
| 1533 } else { | 1539 } else { |
| 1534 VisitInDuplicateContext(expr->then_expression()); | 1540 VisitInDuplicateContext(expr->then_expression()); |
| 1535 __ jmp(&done); | 1541 __ jmp(&done); |
| 1536 } | 1542 } |
| 1537 | 1543 |
| 1538 PrepareForBailoutForId(expr->ElseId(), NO_REGISTERS); | 1544 PrepareForBailoutForId(expr->ElseId(), NO_REGISTERS); |
| 1539 __ bind(&false_case); | 1545 __ bind(&false_case); |
| 1540 SetExpressionPosition(expr->else_expression(), | 1546 SetExpressionPosition(expr->else_expression()); |
| 1541 expr->else_expression_position()); | |
| 1542 VisitInDuplicateContext(expr->else_expression()); | 1547 VisitInDuplicateContext(expr->else_expression()); |
| 1543 // If control flow falls through Visit, merge it with true case here. | 1548 // If control flow falls through Visit, merge it with true case here. |
| 1544 if (!context()->IsTest()) { | 1549 if (!context()->IsTest()) { |
| 1545 __ bind(&done); | 1550 __ bind(&done); |
| 1546 } | 1551 } |
| 1547 } | 1552 } |
| 1548 | 1553 |
| 1549 | 1554 |
| 1550 void FullCodeGenerator::VisitLiteral(Literal* expr) { | 1555 void FullCodeGenerator::VisitLiteral(Literal* expr) { |
| 1551 Comment cmnt(masm_, "[ Literal"); | 1556 Comment cmnt(masm_, "[ Literal"); |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1729 } | 1734 } |
| 1730 return true; | 1735 return true; |
| 1731 } | 1736 } |
| 1732 #endif // DEBUG | 1737 #endif // DEBUG |
| 1733 | 1738 |
| 1734 | 1739 |
| 1735 #undef __ | 1740 #undef __ |
| 1736 | 1741 |
| 1737 | 1742 |
| 1738 } } // namespace v8::internal | 1743 } } // namespace v8::internal |
| OLD | NEW |