// Copyright 2012 the V8 project authors. All rights reserved. // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following // disclaimer in the documentation and/or other materials provided // with the distribution. // * Neither the name of Google Inc. nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "v8.h" #include "codegen.h" #include "compiler.h" #include "debug.h" #include "full-codegen.h" #include "liveedit.h" #include "macro-assembler.h" #include "prettyprinter.h" #include "scopes.h" #include "scopeinfo.h" #include "stub-cache.h" namespace v8 { namespace internal { void BreakableStatementChecker::Check(Statement* stmt) { Visit(stmt); } void BreakableStatementChecker::Check(Expression* expr) { Visit(expr); } void BreakableStatementChecker::VisitVariableDeclaration( VariableDeclaration* decl) { } void BreakableStatementChecker::VisitFunctionDeclaration( FunctionDeclaration* decl) { } void BreakableStatementChecker::VisitModuleDeclaration( ModuleDeclaration* decl) { } void BreakableStatementChecker::VisitImportDeclaration( ImportDeclaration* decl) { } void BreakableStatementChecker::VisitExportDeclaration( ExportDeclaration* decl) { } void BreakableStatementChecker::VisitModuleLiteral(ModuleLiteral* module) { } void BreakableStatementChecker::VisitModuleVariable(ModuleVariable* module) { } void BreakableStatementChecker::VisitModulePath(ModulePath* module) { } void BreakableStatementChecker::VisitModuleUrl(ModuleUrl* module) { } void BreakableStatementChecker::VisitBlock(Block* stmt) { } void BreakableStatementChecker::VisitExpressionStatement( ExpressionStatement* stmt) { // Check if expression is breakable. Visit(stmt->expression()); } void BreakableStatementChecker::VisitEmptyStatement(EmptyStatement* stmt) { } void BreakableStatementChecker::VisitIfStatement(IfStatement* stmt) { // If the condition is breakable the if statement is breakable. Visit(stmt->condition()); } void BreakableStatementChecker::VisitContinueStatement( ContinueStatement* stmt) { } void BreakableStatementChecker::VisitBreakStatement(BreakStatement* stmt) { } void BreakableStatementChecker::VisitReturnStatement(ReturnStatement* stmt) { // Return is breakable if the expression is. Visit(stmt->expression()); } void BreakableStatementChecker::VisitWithStatement(WithStatement* stmt) { Visit(stmt->expression()); } void BreakableStatementChecker::VisitSwitchStatement(SwitchStatement* stmt) { // Switch statements breakable if the tag expression is. Visit(stmt->tag()); } void BreakableStatementChecker::VisitDoWhileStatement(DoWhileStatement* stmt) { // Mark do while as breakable to avoid adding a break slot in front of it. is_breakable_ = true; } void BreakableStatementChecker::VisitWhileStatement(WhileStatement* stmt) { // Mark while statements breakable if the condition expression is. Visit(stmt->cond()); } void BreakableStatementChecker::VisitForStatement(ForStatement* stmt) { // Mark for statements breakable if the condition expression is. if (stmt->cond() != NULL) { Visit(stmt->cond()); } } void BreakableStatementChecker::VisitForInStatement(ForInStatement* stmt) { // Mark for in statements breakable if the enumerable expression is. Visit(stmt->enumerable()); } void BreakableStatementChecker::VisitTryCatchStatement( TryCatchStatement* stmt) { // Mark try catch as breakable to avoid adding a break slot in front of it. is_breakable_ = true; } void BreakableStatementChecker::VisitTryFinallyStatement( TryFinallyStatement* stmt) { // Mark try finally as breakable to avoid adding a break slot in front of it. is_breakable_ = true; } void BreakableStatementChecker::VisitDebuggerStatement( DebuggerStatement* stmt) { // The debugger statement is breakable. is_breakable_ = true; } void BreakableStatementChecker::VisitFunctionLiteral(FunctionLiteral* expr) { } void BreakableStatementChecker::VisitSharedFunctionInfoLiteral( SharedFunctionInfoLiteral* expr) { } void BreakableStatementChecker::VisitConditional(Conditional* expr) { } void BreakableStatementChecker::VisitVariableProxy(VariableProxy* expr) { } void BreakableStatementChecker::VisitLiteral(Literal* expr) { } void BreakableStatementChecker::VisitRegExpLiteral(RegExpLiteral* expr) { } void BreakableStatementChecker::VisitObjectLiteral(ObjectLiteral* expr) { } void BreakableStatementChecker::VisitArrayLiteral(ArrayLiteral* expr) { } void BreakableStatementChecker::VisitAssignment(Assignment* expr) { // If assigning to a property (including a global property) the assignment is // breakable. VariableProxy* proxy = expr->target()->AsVariableProxy(); Property* prop = expr->target()->AsProperty(); if (prop != NULL || (proxy != NULL && proxy->var()->IsUnallocated())) { is_breakable_ = true; return; } // Otherwise the assignment is breakable if the assigned value is. Visit(expr->value()); } void BreakableStatementChecker::VisitThrow(Throw* expr) { // Throw is breakable if the expression is. Visit(expr->exception()); } void BreakableStatementChecker::VisitProperty(Property* expr) { // Property load is breakable. is_breakable_ = true; } void BreakableStatementChecker::VisitCall(Call* expr) { // Function calls both through IC and call stub are breakable. is_breakable_ = true; } void BreakableStatementChecker::VisitCallNew(CallNew* expr) { // Function calls through new are breakable. is_breakable_ = true; } void BreakableStatementChecker::VisitCallRuntime(CallRuntime* expr) { } void BreakableStatementChecker::VisitUnaryOperation(UnaryOperation* expr) { Visit(expr->expression()); } void BreakableStatementChecker::VisitCountOperation(CountOperation* expr) { Visit(expr->expression()); } void BreakableStatementChecker::VisitBinaryOperation(BinaryOperation* expr) { Visit(expr->left()); if (expr->op() != Token::AND && expr->op() != Token::OR) { Visit(expr->right()); } } void BreakableStatementChecker::VisitCompareOperation(CompareOperation* expr) { Visit(expr->left()); Visit(expr->right()); } void BreakableStatementChecker::VisitThisFunction(ThisFunction* expr) { } #define __ ACCESS_MASM(masm()) bool FullCodeGenerator::MakeCode(CompilationInfo* info) { Isolate* isolate = info->isolate(); Handle