Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/interpreter/bytecode-generator.h" | 5 #include "src/interpreter/bytecode-generator.h" |
| 6 | 6 |
| 7 #include "src/ast/scopes.h" | 7 #include "src/ast/scopes.h" |
| 8 #include "src/compiler.h" | 8 #include "src/compiler.h" |
| 9 #include "src/interpreter/bytecode-register-allocator.h" | 9 #include "src/interpreter/bytecode-register-allocator.h" |
| 10 #include "src/interpreter/control-flow-builders.h" | 10 #include "src/interpreter/control-flow-builders.h" |
| (...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 448 : generator_(generator), | 448 : generator_(generator), |
| 449 kind_(kind), | 449 kind_(kind), |
| 450 outer_(generator->execution_result()), | 450 outer_(generator->execution_result()), |
| 451 allocator_(generator), | 451 allocator_(generator), |
| 452 result_identified_(false) { | 452 result_identified_(false) { |
| 453 generator_->set_execution_result(this); | 453 generator_->set_execution_result(this); |
| 454 } | 454 } |
| 455 | 455 |
| 456 virtual ~ExpressionResultScope() { | 456 virtual ~ExpressionResultScope() { |
| 457 generator_->set_execution_result(outer_); | 457 generator_->set_execution_result(outer_); |
| 458 DCHECK(result_identified()); | 458 if (!generator_->HasStackOverflow()) DCHECK(result_identified()); |
|
mythria
2016/02/24 11:49:39
when there is a stack overflow, we don't visit any
oth
2016/02/24 13:19:47
All the logic could go in the DCHECK(result_identi
mythria
2016/02/24 13:32:14
Done.
| |
| 459 } | 459 } |
| 460 | 460 |
| 461 bool IsEffect() const { return kind_ == Expression::kEffect; } | 461 bool IsEffect() const { return kind_ == Expression::kEffect; } |
| 462 bool IsValue() const { return kind_ == Expression::kValue; } | 462 bool IsValue() const { return kind_ == Expression::kValue; } |
| 463 | 463 |
| 464 virtual void SetResultInAccumulator() = 0; | 464 virtual void SetResultInAccumulator() = 0; |
| 465 virtual void SetResultInRegister(Register reg) = 0; | 465 virtual void SetResultInRegister(Register reg) = 0; |
| 466 | 466 |
| 467 protected: | 467 protected: |
| 468 ExpressionResultScope* outer() const { return outer_; } | 468 ExpressionResultScope* outer() const { return outer_; } |
| (...skipping 806 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1275 void BytecodeGenerator::VisitDebuggerStatement(DebuggerStatement* stmt) { | 1275 void BytecodeGenerator::VisitDebuggerStatement(DebuggerStatement* stmt) { |
| 1276 builder()->SetStatementPosition(stmt); | 1276 builder()->SetStatementPosition(stmt); |
| 1277 builder()->Debugger(); | 1277 builder()->Debugger(); |
| 1278 } | 1278 } |
| 1279 | 1279 |
| 1280 | 1280 |
| 1281 void BytecodeGenerator::VisitFunctionLiteral(FunctionLiteral* expr) { | 1281 void BytecodeGenerator::VisitFunctionLiteral(FunctionLiteral* expr) { |
| 1282 // Find or build a shared function info. | 1282 // Find or build a shared function info. |
| 1283 Handle<SharedFunctionInfo> shared_info = | 1283 Handle<SharedFunctionInfo> shared_info = |
| 1284 Compiler::GetSharedFunctionInfo(expr, info()->script(), info()); | 1284 Compiler::GetSharedFunctionInfo(expr, info()->script(), info()); |
| 1285 CHECK(!shared_info.is_null()); // TODO(rmcilroy): Set stack overflow? | 1285 if (shared_info.is_null()) { |
| 1286 execution_result()->SetResultInAccumulator(); | |
| 1287 return SetStackOverflow(); | |
| 1288 } | |
| 1286 builder()->CreateClosure(shared_info, | 1289 builder()->CreateClosure(shared_info, |
| 1287 expr->pretenure() ? TENURED : NOT_TENURED); | 1290 expr->pretenure() ? TENURED : NOT_TENURED); |
| 1288 execution_result()->SetResultInAccumulator(); | 1291 execution_result()->SetResultInAccumulator(); |
| 1289 } | 1292 } |
| 1290 | 1293 |
| 1291 | 1294 |
| 1292 void BytecodeGenerator::VisitClassLiteral(ClassLiteral* expr) { | 1295 void BytecodeGenerator::VisitClassLiteral(ClassLiteral* expr) { |
| 1293 if (expr->scope()->ContextLocalCount() > 0) { | 1296 if (expr->scope()->ContextLocalCount() > 0) { |
| 1294 VisitNewLocalBlockContext(expr->scope()); | 1297 VisitNewLocalBlockContext(expr->scope()); |
| 1295 ContextScope scope(this, expr->scope()); | 1298 ContextScope scope(this, expr->scope()); |
| (...skipping 1815 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3111 } | 3114 } |
| 3112 | 3115 |
| 3113 | 3116 |
| 3114 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { | 3117 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { |
| 3115 return info()->feedback_vector()->GetIndex(slot); | 3118 return info()->feedback_vector()->GetIndex(slot); |
| 3116 } | 3119 } |
| 3117 | 3120 |
| 3118 } // namespace interpreter | 3121 } // namespace interpreter |
| 3119 } // namespace internal | 3122 } // namespace internal |
| 3120 } // namespace v8 | 3123 } // namespace v8 |
| OLD | NEW |