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 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 protected: | 202 protected: |
203 bool Execute(Command command, Statement* statement) override { | 203 bool Execute(Command command, Statement* statement) override { |
204 switch (command) { | 204 switch (command) { |
205 case CMD_BREAK: | 205 case CMD_BREAK: |
206 case CMD_CONTINUE: | 206 case CMD_CONTINUE: |
207 break; | 207 break; |
208 case CMD_RETURN: | 208 case CMD_RETURN: |
209 generator()->builder()->Return(); | 209 generator()->builder()->Return(); |
210 return true; | 210 return true; |
211 case CMD_RETHROW: | 211 case CMD_RETHROW: |
212 // TODO(mstarzinger): Should be a ReThrow instead. | 212 generator()->builder()->ReThrow(); |
213 generator()->builder()->Throw(); | |
214 return true; | 213 return true; |
215 } | 214 } |
216 return false; | 215 return false; |
217 } | 216 } |
218 }; | 217 }; |
219 | 218 |
220 | 219 |
221 // Scoped class for enabling break inside blocks and switch blocks. | 220 // Scoped class for enabling break inside blocks and switch blocks. |
222 class BytecodeGenerator::ControlScopeForBreakable final | 221 class BytecodeGenerator::ControlScopeForBreakable final |
223 : public BytecodeGenerator::ControlScope { | 222 : public BytecodeGenerator::ControlScope { |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 LoopBuilder* loop_builder_; | 283 LoopBuilder* loop_builder_; |
285 }; | 284 }; |
286 | 285 |
287 | 286 |
288 // Scoped class for enabling 'throw' in try-catch constructs. | 287 // Scoped class for enabling 'throw' in try-catch constructs. |
289 class BytecodeGenerator::ControlScopeForTryCatch final | 288 class BytecodeGenerator::ControlScopeForTryCatch final |
290 : public BytecodeGenerator::ControlScope { | 289 : public BytecodeGenerator::ControlScope { |
291 public: | 290 public: |
292 ControlScopeForTryCatch(BytecodeGenerator* generator, | 291 ControlScopeForTryCatch(BytecodeGenerator* generator, |
293 TryCatchBuilder* try_catch_builder) | 292 TryCatchBuilder* try_catch_builder) |
294 : ControlScope(generator), try_catch_builder_(try_catch_builder) {} | 293 : ControlScope(generator) {} |
295 | 294 |
296 protected: | 295 protected: |
297 bool Execute(Command command, Statement* statement) override { | 296 bool Execute(Command command, Statement* statement) override { |
298 switch (command) { | 297 switch (command) { |
299 case CMD_BREAK: | 298 case CMD_BREAK: |
300 case CMD_CONTINUE: | 299 case CMD_CONTINUE: |
301 case CMD_RETURN: | 300 case CMD_RETURN: |
302 break; | 301 break; |
303 case CMD_RETHROW: | 302 case CMD_RETHROW: |
304 // TODO(mstarzinger): Test and implement this! | 303 generator()->builder()->ReThrow(); |
305 USE(try_catch_builder_); | |
306 UNIMPLEMENTED(); | |
307 return true; | 304 return true; |
308 } | 305 } |
309 return false; | 306 return false; |
310 } | 307 } |
311 | |
312 private: | |
313 TryCatchBuilder* try_catch_builder_; | |
314 }; | 308 }; |
315 | 309 |
316 | 310 |
317 // Scoped class for enabling control flow through try-finally constructs. | 311 // Scoped class for enabling control flow through try-finally constructs. |
318 class BytecodeGenerator::ControlScopeForTryFinally final | 312 class BytecodeGenerator::ControlScopeForTryFinally final |
319 : public BytecodeGenerator::ControlScope { | 313 : public BytecodeGenerator::ControlScope { |
320 public: | 314 public: |
321 ControlScopeForTryFinally(BytecodeGenerator* generator, | 315 ControlScopeForTryFinally(BytecodeGenerator* generator, |
322 TryFinallyBuilder* try_finally_builder, | 316 TryFinallyBuilder* try_finally_builder, |
323 DeferredCommands* commands) | 317 DeferredCommands* commands) |
(...skipping 2176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2500 } | 2494 } |
2501 | 2495 |
2502 | 2496 |
2503 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { | 2497 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { |
2504 return info()->feedback_vector()->GetIndex(slot); | 2498 return info()->feedback_vector()->GetIndex(slot); |
2505 } | 2499 } |
2506 | 2500 |
2507 } // namespace interpreter | 2501 } // namespace interpreter |
2508 } // namespace internal | 2502 } // namespace internal |
2509 } // namespace v8 | 2503 } // namespace v8 |
OLD | NEW |