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 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 // Build assignment to {new.target} variable if it is used. | 402 // Build assignment to {new.target} variable if it is used. |
403 VisitNewTargetVariable(scope()->new_target_var()); | 403 VisitNewTargetVariable(scope()->new_target_var()); |
404 | 404 |
405 // TODO(rmcilroy): Emit tracing call if requested to do so. | 405 // TODO(rmcilroy): Emit tracing call if requested to do so. |
406 if (FLAG_trace) { | 406 if (FLAG_trace) { |
407 UNIMPLEMENTED(); | 407 UNIMPLEMENTED(); |
408 } | 408 } |
409 | 409 |
410 // Visit illegal re-declaration and bail out if it exists. | 410 // Visit illegal re-declaration and bail out if it exists. |
411 if (scope()->HasIllegalRedeclaration()) { | 411 if (scope()->HasIllegalRedeclaration()) { |
412 Visit(scope()->GetIllegalRedeclaration()); | 412 VisitForEffect(scope()->GetIllegalRedeclaration()); |
413 return; | 413 return; |
414 } | 414 } |
415 | 415 |
416 // Visit declarations within the function scope. | 416 // Visit declarations within the function scope. |
417 VisitDeclarations(scope()->declarations()); | 417 VisitDeclarations(scope()->declarations()); |
418 | 418 |
419 // Visit statements in the function body. | 419 // Visit statements in the function body. |
420 VisitStatements(info()->literal()->body()); | 420 VisitStatements(info()->literal()->body()); |
421 } | 421 } |
422 | 422 |
(...skipping 1091 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1514 execution_result()->SetResultInAccumulator(); | 1514 execution_result()->SetResultInAccumulator(); |
1515 } | 1515 } |
1516 | 1516 |
1517 | 1517 |
1518 void BytecodeGenerator::VisitYield(Yield* expr) { UNIMPLEMENTED(); } | 1518 void BytecodeGenerator::VisitYield(Yield* expr) { UNIMPLEMENTED(); } |
1519 | 1519 |
1520 | 1520 |
1521 void BytecodeGenerator::VisitThrow(Throw* expr) { | 1521 void BytecodeGenerator::VisitThrow(Throw* expr) { |
1522 VisitForAccumulatorValue(expr->exception()); | 1522 VisitForAccumulatorValue(expr->exception()); |
1523 builder()->Throw(); | 1523 builder()->Throw(); |
| 1524 // Throw statments are modeled as expression instead of statments. These are |
| 1525 // converted from assignment statements in Rewriter::ReWrite pass. An |
| 1526 // assignment statement expects a value in the accumulator. This is a hack to |
| 1527 // avoid DCHECK fails assert accumulator has been set. |
| 1528 execution_result()->SetResultInAccumulator(); |
1524 } | 1529 } |
1525 | 1530 |
1526 | 1531 |
1527 void BytecodeGenerator::VisitPropertyLoad(Register obj, Property* expr) { | 1532 void BytecodeGenerator::VisitPropertyLoad(Register obj, Property* expr) { |
1528 LhsKind property_kind = Property::GetAssignType(expr); | 1533 LhsKind property_kind = Property::GetAssignType(expr); |
1529 FeedbackVectorSlot slot = expr->PropertyFeedbackSlot(); | 1534 FeedbackVectorSlot slot = expr->PropertyFeedbackSlot(); |
1530 switch (property_kind) { | 1535 switch (property_kind) { |
1531 case VARIABLE: | 1536 case VARIABLE: |
1532 UNREACHABLE(); | 1537 UNREACHABLE(); |
1533 case NAMED_PROPERTY: { | 1538 case NAMED_PROPERTY: { |
(...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2257 } | 2262 } |
2258 | 2263 |
2259 | 2264 |
2260 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { | 2265 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { |
2261 return info()->feedback_vector()->GetIndex(slot); | 2266 return info()->feedback_vector()->GetIndex(slot); |
2262 } | 2267 } |
2263 | 2268 |
2264 } // namespace interpreter | 2269 } // namespace interpreter |
2265 } // namespace internal | 2270 } // namespace internal |
2266 } // namespace v8 | 2271 } // namespace v8 |
OLD | NEW |