Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(144)

Side by Side Diff: test/cctest/interpreter/test-bytecode-generator.cc

Issue 1613443002: [interpreter] Implement handling of try-finally constructs. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebased. Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/interpreter/control-flow-builders.cc ('k') | test/cctest/interpreter/test-interpreter.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/compiler.h" 7 #include "src/compiler.h"
8 #include "src/interpreter/bytecode-array-iterator.h" 8 #include "src/interpreter/bytecode-array-iterator.h"
9 #include "src/interpreter/bytecode-generator.h" 9 #include "src/interpreter/bytecode-generator.h"
10 #include "src/interpreter/interpreter.h" 10 #include "src/interpreter/interpreter.h"
(...skipping 4231 matching lines...) Expand 10 before | Expand all | Expand 10 after
4242 4242
4243 TEST(TryFinally) { 4243 TEST(TryFinally) {
4244 InitializedHandleScope handle_scope; 4244 InitializedHandleScope handle_scope;
4245 BytecodeGeneratorHelper helper; 4245 BytecodeGeneratorHelper helper;
4246 4246
4247 int closure = Register::function_closure().index(); 4247 int closure = Register::function_closure().index();
4248 int context = Register::function_context().index(); 4248 int context = Register::function_context().index();
4249 4249
4250 ExpectedSnippet<const char*> snippets[] = { 4250 ExpectedSnippet<const char*> snippets[] = {
4251 {"var a = 1; try { a = 2; } finally { a = 3; }", 4251 {"var a = 1; try { a = 2; } finally { a = 3; }",
4252 2 * kPointerSize, 4252 4 * kPointerSize,
4253 1, 4253 1,
4254 14, 4254 35,
4255 { 4255 {
4256 B(LdaSmi8), U8(1), // 4256 B(LdaSmi8), U8(1), //
4257 B(Star), R(0), // 4257 B(Star), R(0), //
4258 B(LdaSmi8), U8(2), // 4258 B(LdaSmi8), U8(2), //
4259 B(Star), R(0), // 4259 B(Star), R(0), //
4260 B(LdaSmi8), U8(3), // 4260 B(LdaSmi8), U8(-1), //
4261 B(Star), R(0), // 4261 B(Star), R(1), //
4262 B(LdaUndefined), // 4262 B(Jump), U8(7), //
4263 B(Return), // 4263 B(Star), R(2), //
4264 B(LdaZero), //
4265 B(Star), R(1), //
4266 B(LdaSmi8), U8(3), //
4267 B(Star), R(0), //
4268 B(LdaZero), //
4269 B(TestEqualStrict), R(1), //
4270 B(JumpIfTrue), U8(4), //
4271 B(Jump), U8(5), //
4272 B(Ldar), R(2), //
4273 B(Throw), //
4274 B(LdaUndefined), //
4275 B(Return), //
4264 }, 4276 },
4265 0, 4277 0,
4266 {}, 4278 {},
4267 1, 4279 1,
4268 {{4, 8, 8}}}, 4280 {{4, 8, 14}}},
4269 {"var a = 1; try { a = 2; } catch(e) { a = 20 } finally { a = 3; }", 4281 {"var a = 1; try { a = 2; } catch(e) { a = 20 } finally { a = 3; }",
4270 7 * kPointerSize, 4282 9 * kPointerSize,
4271 1, 4283 1,
4272 39, 4284 60,
4273 { 4285 {
4274 B(LdaSmi8), U8(1), // 4286 B(LdaSmi8), U8(1), //
4275 B(Star), R(0), // 4287 B(Star), R(0), //
4276 B(LdaSmi8), U8(2), // 4288 B(LdaSmi8), U8(2), //
4277 B(Star), R(0), // 4289 B(Star), R(0), //
4278 B(Jump), U8(25), // 4290 B(Jump), U8(25), //
4279 B(Star), R(5), // 4291 B(Star), R(7), //
4280 B(LdaConstant), U8(0), // 4292 B(LdaConstant), U8(0), //
4281 B(Star), R(4), // 4293 B(Star), R(6), //
4282 B(Ldar), R(closure), // 4294 B(Ldar), R(closure), //
4283 B(Star), R(6), // 4295 B(Star), R(8), //
4284 B(CallRuntime), U16(Runtime::kPushCatchContext), R(4), U8(3), // 4296 B(CallRuntime), U16(Runtime::kPushCatchContext), R(6), U8(3), //
4285 B(PushContext), R(1), // 4297 B(PushContext), R(1), //
4286 B(LdaSmi8), U8(20), // 4298 B(LdaSmi8), U8(20), //
4287 B(Star), R(0), // 4299 B(Star), R(0), //
4288 B(PopContext), R(context), // 4300 B(PopContext), R(context), //
4301 B(LdaSmi8), U8(-1), //
4302 B(Star), R(2), //
4303 B(Jump), U8(7), //
4304 B(Star), R(3), //
4305 B(LdaZero), //
4306 B(Star), R(2), //
4289 B(LdaSmi8), U8(3), // 4307 B(LdaSmi8), U8(3), //
4290 B(Star), R(0), // 4308 B(Star), R(0), //
4309 B(LdaZero), //
4310 B(TestEqualStrict), R(2), //
4311 B(JumpIfTrue), U8(4), //
4312 B(Jump), U8(5), //
4313 B(Ldar), R(3), //
4314 B(Throw), //
4291 B(LdaUndefined), // 4315 B(LdaUndefined), //
4292 B(Return), // 4316 B(Return), //
4293 }, 4317 },
4294 1, 4318 1,
4295 {"e"}, 4319 {"e"},
4296 2, 4320 2,
4297 {{4, 33, 33}, {4, 8, 10}}}, 4321 {{4, 33, 39}, {4, 8, 10}}},
4298 {"var a; try {" 4322 {"var a; try {"
4299 " try { a = 1 } catch(e) { a = 2 }" 4323 " try { a = 1 } catch(e) { a = 2 }"
4300 "} catch(e) { a = 20 } finally { a = 3; }", 4324 "} catch(e) { a = 20 } finally { a = 3; }",
4301 8 * kPointerSize, 4325 10 * kPointerSize,
4302 1, 4326 1,
4303 60, 4327 81,
4304 { 4328 {
4305 B(LdaSmi8), U8(1), // 4329 B(LdaSmi8), U8(1), //
4306 B(Star), R(0), // 4330 B(Star), R(0), //
4307 B(Jump), U8(25), // 4331 B(Jump), U8(25), //
4308 B(Star), R(6), // 4332 B(Star), R(8), //
4309 B(LdaConstant), U8(0), // 4333 B(LdaConstant), U8(0), //
4310 B(Star), R(5), // 4334 B(Star), R(7), //
4311 B(Ldar), R(closure), // 4335 B(Ldar), R(closure), //
4312 B(Star), R(7), // 4336 B(Star), R(9), //
4313 B(CallRuntime), U16(Runtime::kPushCatchContext), R(5), U8(3), // 4337 B(CallRuntime), U16(Runtime::kPushCatchContext), R(7), U8(3), //
4314 B(PushContext), R(1), // 4338 B(PushContext), R(1), //
4315 B(LdaSmi8), U8(2), // 4339 B(LdaSmi8), U8(2), //
4316 B(Star), R(0), // 4340 B(Star), R(0), //
4317 B(PopContext), R(context), // 4341 B(PopContext), R(context), //
4318 B(Jump), U8(25), // 4342 B(Jump), U8(25), //
4319 B(Star), R(5), // 4343 B(Star), R(7), //
4320 B(LdaConstant), U8(0), // 4344 B(LdaConstant), U8(0), //
4321 B(Star), R(4), // 4345 B(Star), R(6), //
4322 B(Ldar), R(closure), // 4346 B(Ldar), R(closure), //
4323 B(Star), R(6), // 4347 B(Star), R(8), //
4324 B(CallRuntime), U16(Runtime::kPushCatchContext), R(4), U8(3), // 4348 B(CallRuntime), U16(Runtime::kPushCatchContext), R(6), U8(3), //
4325 B(PushContext), R(1), // 4349 B(PushContext), R(1), //
4326 B(LdaSmi8), U8(20), // 4350 B(LdaSmi8), U8(20), //
4327 B(Star), R(0), // 4351 B(Star), R(0), //
4328 B(PopContext), R(context), // 4352 B(PopContext), R(context), //
4353 B(LdaSmi8), U8(-1), //
4354 B(Star), R(2), //
4355 B(Jump), U8(7), //
4356 B(Star), R(3), //
4357 B(LdaZero), //
4358 B(Star), R(2), //
4329 B(LdaSmi8), U8(3), // 4359 B(LdaSmi8), U8(3), //
4330 B(Star), R(0), // 4360 B(Star), R(0), //
4361 B(LdaZero), //
4362 B(TestEqualStrict), R(2), //
4363 B(JumpIfTrue), U8(4), //
4364 B(Jump), U8(5), //
4365 B(Ldar), R(3), //
4366 B(Throw), //
4331 B(LdaUndefined), // 4367 B(LdaUndefined), //
4332 B(Return), // 4368 B(Return), //
4333 }, 4369 },
4334 1, 4370 1,
4335 {"e"}, 4371 {"e"},
4336 3, 4372 3,
4337 {{0, 54, 54}, {0, 29, 31}, {0, 4, 6}}}, 4373 {{0, 54, 60}, {0, 29, 31}, {0, 4, 6}}},
4338 }; 4374 };
4339 4375
4340 for (size_t i = 0; i < arraysize(snippets); i++) { 4376 for (size_t i = 0; i < arraysize(snippets); i++) {
4341 Handle<BytecodeArray> bytecode_array = 4377 Handle<BytecodeArray> bytecode_array =
4342 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); 4378 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet);
4343 CheckBytecodeArrayEqual(snippets[i], bytecode_array); 4379 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
4344 } 4380 }
4345 } 4381 }
4346 4382
4347 4383
(...skipping 2548 matching lines...) Expand 10 before | Expand all | Expand 10 after
6896 std::string(function_epilogue); 6932 std::string(function_epilogue);
6897 Handle<BytecodeArray> bytecode_array = 6933 Handle<BytecodeArray> bytecode_array =
6898 helper.MakeBytecode(script.c_str(), "*", "f"); 6934 helper.MakeBytecode(script.c_str(), "*", "f");
6899 CheckBytecodeArrayEqual(snippets[i], bytecode_array); 6935 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
6900 } 6936 }
6901 } 6937 }
6902 6938
6903 } // namespace interpreter 6939 } // namespace interpreter
6904 } // namespace internal 6940 } // namespace internal
6905 } // namespace v8 6941 } // namespace v8
OLDNEW
« no previous file with comments | « src/interpreter/control-flow-builders.cc ('k') | test/cctest/interpreter/test-interpreter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698