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

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

Issue 1651993002: [interpreter] Clear pending message object on handler entry. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebased. Created 4 years, 10 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 | « test/cctest/cctest.status ('k') | no next file » | 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 4248 matching lines...) Expand 10 before | Expand all | Expand 10 after
4259 TEST(TryCatch) { 4259 TEST(TryCatch) {
4260 InitializedHandleScope handle_scope; 4260 InitializedHandleScope handle_scope;
4261 BytecodeGeneratorHelper helper; 4261 BytecodeGeneratorHelper helper;
4262 4262
4263 int closure = Register::function_closure().index(); 4263 int closure = Register::function_closure().index();
4264 4264
4265 ExpectedSnippet<const char*> snippets[] = { 4265 ExpectedSnippet<const char*> snippets[] = {
4266 {"try { return 1; } catch(e) { return 2; }", 4266 {"try { return 1; } catch(e) { return 2; }",
4267 5 * kPointerSize, 4267 5 * kPointerSize,
4268 1, 4268 1,
4269 27, 4269 36,
4270 { 4270 {
4271 B(LdaSmi8), U8(1), // 4271 B(LdaSmi8), U8(1), //
4272 B(Return), // 4272 B(Return), //
4273 B(Star), R(3), // 4273 B(Star), R(3), //
4274 B(LdaConstant), U8(0), // 4274 B(LdaConstant), U8(0), //
4275 B(Star), R(2), // 4275 B(Star), R(2), //
4276 B(Ldar), R(closure), // 4276 B(Ldar), R(closure), //
4277 B(Star), R(4), // 4277 B(Star), R(4), //
4278 B(CallRuntime), U16(Runtime::kPushCatchContext), R(2), U8(3), // 4278 B(CallRuntime), U16(Runtime::kPushCatchContext), R(2), U8(3), //
4279 B(PushContext), R(0), // 4279 B(Star), R(1), //
4280 B(LdaSmi8), U8(2), // 4280 B(CallRuntime), U16(Runtime::kInterpreterClearPendingMessage), //
4281 B(PopContext), R(0), // 4281 /* */ R(0), U8(0), //
4282 B(Return), // 4282 B(Ldar), R(1), //
4283 B(PushContext), R(0), //
4284 B(LdaSmi8), U8(2), //
4285 B(PopContext), R(0), //
4286 B(Return), //
4283 // TODO(mstarzinger): Potential optimization, elide next bytes. 4287 // TODO(mstarzinger): Potential optimization, elide next bytes.
4284 B(LdaUndefined), // 4288 B(LdaUndefined), //
4285 B(Return), // 4289 B(Return), //
4286 }, 4290 },
4287 1, 4291 1,
4288 {"e"}, 4292 {"e"},
4289 1, 4293 1,
4290 {{0, 3, 3}}}, 4294 {{0, 3, 3}}},
4291 {"var a; try { a = 1 } catch(e1) {}; try { a = 2 } catch(e2) { a = 3 }", 4295 {"var a; try { a = 1 } catch(e1) {}; try { a = 2 } catch(e2) { a = 3 }",
4292 6 * kPointerSize, 4296 6 * kPointerSize,
4293 1, 4297 1,
4294 56, 4298 74,
4295 { 4299 {
4296 B(LdaSmi8), U8(1), // 4300 B(LdaSmi8), U8(1), //
4297 B(Star), R(0), // 4301 B(Star), R(0), //
4298 B(Jump), U8(21), // 4302 B(Jump), U8(30), //
4299 B(Star), R(4), // 4303 B(Star), R(4), //
4300 B(LdaConstant), U8(0), // 4304 B(LdaConstant), U8(0), //
4301 B(Star), R(3), // 4305 B(Star), R(3), //
4302 B(Ldar), R(closure), // 4306 B(Ldar), R(closure), //
4303 B(Star), R(5), // 4307 B(Star), R(5), //
4304 B(CallRuntime), U16(Runtime::kPushCatchContext), R(3), U8(3), // 4308 B(CallRuntime), U16(Runtime::kPushCatchContext), R(3), U8(3), //
4305 B(PushContext), R(1), // 4309 B(Star), R(2), //
4306 B(PopContext), R(1), // 4310 B(CallRuntime), U16(Runtime::kInterpreterClearPendingMessage), //
4307 B(LdaSmi8), U8(2), // 4311 /* */ R(0), U8(0), //
4308 B(Star), R(0), // 4312 B(Ldar), R(2), //
4309 B(Jump), U8(25), // 4313 B(PushContext), R(1), //
4310 B(Star), R(4), // 4314 B(PopContext), R(1), //
4311 B(LdaConstant), U8(1), // 4315 B(LdaSmi8), U8(2), //
4312 B(Star), R(3), // 4316 B(Star), R(0), //
4313 B(Ldar), R(closure), // 4317 B(Jump), U8(34), //
4314 B(Star), R(5), // 4318 B(Star), R(4), //
4315 B(CallRuntime), U16(Runtime::kPushCatchContext), R(3), U8(3), // 4319 B(LdaConstant), U8(1), //
4316 B(PushContext), R(1), // 4320 B(Star), R(3), //
4317 B(LdaSmi8), U8(3), // 4321 B(Ldar), R(closure), //
4318 B(Star), R(0), // 4322 B(Star), R(5), //
4319 B(PopContext), R(1), // 4323 B(CallRuntime), U16(Runtime::kPushCatchContext), R(3), U8(3), //
4320 B(LdaUndefined), // 4324 B(Star), R(2), //
4321 B(Return), // 4325 B(CallRuntime), U16(Runtime::kInterpreterClearPendingMessage), //
4326 /* */ R(0), U8(0), //
4327 B(Ldar), R(2), //
4328 B(PushContext), R(1), //
4329 B(LdaSmi8), U8(3), //
4330 B(Star), R(0), //
4331 B(PopContext), R(1), //
4332 B(LdaUndefined), //
4333 B(Return), //
4322 }, 4334 },
4323 2, 4335 2,
4324 {"e1", "e2"}, 4336 {"e1", "e2"},
4325 2, 4337 2,
4326 {{0, 4, 6}, {25, 29, 31}}}, 4338 {{0, 4, 6}, {34, 38, 40}}},
4327 }; 4339 };
4328 4340
4329 for (size_t i = 0; i < arraysize(snippets); i++) { 4341 for (size_t i = 0; i < arraysize(snippets); i++) {
4330 Handle<BytecodeArray> bytecode_array = 4342 Handle<BytecodeArray> bytecode_array =
4331 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); 4343 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet);
4332 CheckBytecodeArrayEqual(snippets[i], bytecode_array); 4344 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
4333 } 4345 }
4334 } 4346 }
4335 4347
4336 4348
4337 TEST(TryFinally) { 4349 TEST(TryFinally) {
4338 InitializedHandleScope handle_scope; 4350 InitializedHandleScope handle_scope;
4339 BytecodeGeneratorHelper helper; 4351 BytecodeGeneratorHelper helper;
4340 4352
4341 int closure = Register::function_closure().index(); 4353 int closure = Register::function_closure().index();
4342 4354
4343 ExpectedSnippet<const char*> snippets[] = { 4355 ExpectedSnippet<const char*> snippets[] = {
4344 {"var a = 1; try { a = 2; } finally { a = 3; }", 4356 {"var a = 1; try { a = 2; } finally { a = 3; }",
4345 4 * kPointerSize, 4357 4 * kPointerSize,
4346 1, 4358 1,
4347 35, 4359 47,
4348 { 4360 {
4349 B(LdaSmi8), U8(1), // 4361 B(LdaSmi8), U8(1), //
4350 B(Star), R(0), // 4362 B(Star), R(0), //
4351 B(LdaSmi8), U8(2), // 4363 B(LdaSmi8), U8(2), //
4352 B(Star), R(0), // 4364 B(Star), R(0), //
4353 B(LdaSmi8), U8(-1), // 4365 B(LdaSmi8), U8(-1), //
4354 B(Star), R(1), // 4366 B(Star), R(1), //
4355 B(Jump), U8(7), // 4367 B(Jump), U8(7), //
4356 B(Star), R(2), // 4368 B(Star), R(2), //
4357 B(LdaZero), // 4369 B(LdaZero), //
4358 B(Star), R(1), // 4370 B(Star), R(1), //
4359 B(LdaSmi8), U8(3), // 4371 B(CallRuntime), U16(Runtime::kInterpreterClearPendingMessage), //
4360 B(Star), R(0), // 4372 /* */ R(0), U8(0), //
4361 B(LdaZero), // 4373 B(Star), R(3), //
4362 B(TestEqualStrict), R(1), // 4374 B(LdaSmi8), U8(3), //
4363 B(JumpIfTrue), U8(4), // 4375 B(Star), R(0), //
4364 B(Jump), U8(5), // 4376 B(CallRuntime), U16(Runtime::kInterpreterSetPendingMessage), //
4365 B(Ldar), R(2), // 4377 /* */ R(3), U8(1), //
4366 B(ReThrow), // 4378 B(LdaZero), //
4367 B(LdaUndefined), // 4379 B(TestEqualStrict), R(1), //
4368 B(Return), // 4380 B(JumpIfTrue), U8(4), //
4381 B(Jump), U8(5), //
4382 B(Ldar), R(2), //
4383 B(ReThrow), //
4384 B(LdaUndefined), //
4385 B(Return), //
4369 }, 4386 },
4370 0, 4387 0,
4371 {}, 4388 {},
4372 1, 4389 1,
4373 {{4, 8, 14}}}, 4390 {{4, 8, 14}}},
4374 {"var a = 1; try { a = 2; } catch(e) { a = 20 } finally { a = 3; }", 4391 {"var a = 1; try { a = 2; } catch(e) { a = 20 } finally { a = 3; }",
4375 9 * kPointerSize, 4392 9 * kPointerSize,
4376 1, 4393 1,
4377 60, 4394 81,
4378 { 4395 {
4379 B(LdaSmi8), U8(1), // 4396 B(LdaSmi8), U8(1), //
4380 B(Star), R(0), // 4397 B(Star), R(0), //
4381 B(LdaSmi8), U8(2), // 4398 B(LdaSmi8), U8(2), //
4382 B(Star), R(0), // 4399 B(Star), R(0), //
4383 B(Jump), U8(25), // 4400 B(Jump), U8(34), //
4384 B(Star), R(7), // 4401 B(Star), R(7), //
4385 B(LdaConstant), U8(0), // 4402 B(LdaConstant), U8(0), //
4386 B(Star), R(6), // 4403 B(Star), R(6), //
4387 B(Ldar), R(closure), // 4404 B(Ldar), R(closure), //
4388 B(Star), R(8), // 4405 B(Star), R(8), //
4389 B(CallRuntime), U16(Runtime::kPushCatchContext), R(6), U8(3), // 4406 B(CallRuntime), U16(Runtime::kPushCatchContext), R(6), U8(3), //
4390 B(PushContext), R(1), // 4407 B(Star), R(5), //
4391 B(LdaSmi8), U8(20), // 4408 B(CallRuntime), U16(Runtime::kInterpreterClearPendingMessage), //
4392 B(Star), R(0), // 4409 /* */ R(0), U8(0), //
4393 B(PopContext), R(1), // 4410 B(Ldar), R(5), //
4394 B(LdaSmi8), U8(-1), // 4411 B(PushContext), R(1), //
4395 B(Star), R(2), // 4412 B(LdaSmi8), U8(20), //
4396 B(Jump), U8(7), // 4413 B(Star), R(0), //
4397 B(Star), R(3), // 4414 B(PopContext), R(1), //
4398 B(LdaZero), // 4415 B(LdaSmi8), U8(-1), //
4399 B(Star), R(2), // 4416 B(Star), R(2), //
4400 B(LdaSmi8), U8(3), // 4417 B(Jump), U8(7), //
4401 B(Star), R(0), // 4418 B(Star), R(3), //
4402 B(LdaZero), // 4419 B(LdaZero), //
4403 B(TestEqualStrict), R(2), // 4420 B(Star), R(2), //
4404 B(JumpIfTrue), U8(4), // 4421 B(CallRuntime), U16(Runtime::kInterpreterClearPendingMessage), //
4405 B(Jump), U8(5), // 4422 /* */ R(0), U8(0), //
4406 B(Ldar), R(3), // 4423 B(Star), R(4), //
4407 B(ReThrow), // 4424 B(LdaSmi8), U8(3), //
4408 B(LdaUndefined), // 4425 B(Star), R(0), //
4409 B(Return), // 4426 B(CallRuntime), U16(Runtime::kInterpreterSetPendingMessage), //
4427 /* */ R(4), U8(1), //
4428 B(LdaZero), //
4429 B(TestEqualStrict), R(2), //
4430 B(JumpIfTrue), U8(4), //
4431 B(Jump), U8(5), //
4432 B(Ldar), R(3), //
4433 B(ReThrow), //
4434 B(LdaUndefined), //
4435 B(Return), //
4410 }, 4436 },
4411 1, 4437 1,
4412 {"e"}, 4438 {"e"},
4413 2, 4439 2,
4414 {{4, 33, 39}, {4, 8, 10}}}, 4440 {{4, 42, 48}, {4, 8, 10}}},
4415 {"var a; try {" 4441 {"var a; try {"
4416 " try { a = 1 } catch(e) { a = 2 }" 4442 " try { a = 1 } catch(e) { a = 2 }"
4417 "} catch(e) { a = 20 } finally { a = 3; }", 4443 "} catch(e) { a = 20 } finally { a = 3; }",
4418 10 * kPointerSize, 4444 10 * kPointerSize,
4419 1, 4445 1,
4420 81, 4446 111,
4421 { 4447 {
4422 B(LdaSmi8), U8(1), // 4448 B(LdaSmi8), U8(1), //
4423 B(Star), R(0), // 4449 B(Star), R(0), //
4424 B(Jump), U8(25), // 4450 B(Jump), U8(34), //
4425 B(Star), R(8), // 4451 B(Star), R(8), //
4426 B(LdaConstant), U8(0), // 4452 B(LdaConstant), U8(0), //
4427 B(Star), R(7), // 4453 B(Star), R(7), //
4428 B(Ldar), R(closure), // 4454 B(Ldar), R(closure), //
4429 B(Star), R(9), // 4455 B(Star), R(9), //
4430 B(CallRuntime), U16(Runtime::kPushCatchContext), R(7), U8(3), // 4456 B(CallRuntime), U16(Runtime::kPushCatchContext), R(7), U8(3), //
4431 B(PushContext), R(1), // 4457 B(Star), R(6), //
4432 B(LdaSmi8), U8(2), // 4458 B(CallRuntime), U16(Runtime::kInterpreterClearPendingMessage), //
4433 B(Star), R(0), // 4459 /* */ R(0), U8(0), //
4434 B(PopContext), R(1), // 4460 B(Ldar), R(6), //
4435 B(Jump), U8(25), // 4461 B(PushContext), R(1), //
4436 B(Star), R(7), // 4462 B(LdaSmi8), U8(2), //
4437 B(LdaConstant), U8(0), // 4463 B(Star), R(0), //
4438 B(Star), R(6), // 4464 B(PopContext), R(1), //
4439 B(Ldar), R(closure), // 4465 B(Jump), U8(34), //
4440 B(Star), R(8), // 4466 B(Star), R(7), //
4441 B(CallRuntime), U16(Runtime::kPushCatchContext), R(6), U8(3), // 4467 B(LdaConstant), U8(0), //
4442 B(PushContext), R(1), // 4468 B(Star), R(6), //
4443 B(LdaSmi8), U8(20), // 4469 B(Ldar), R(closure), //
4444 B(Star), R(0), // 4470 B(Star), R(8), //
4445 B(PopContext), R(1), // 4471 B(CallRuntime), U16(Runtime::kPushCatchContext), R(6), U8(3), //
4446 B(LdaSmi8), U8(-1), // 4472 B(Star), R(5), //
4447 B(Star), R(2), // 4473 B(CallRuntime), U16(Runtime::kInterpreterClearPendingMessage), //
4448 B(Jump), U8(7), // 4474 /* */ R(0), U8(0), //
4449 B(Star), R(3), // 4475 B(Ldar), R(5), //
4450 B(LdaZero), // 4476 B(PushContext), R(1), //
4451 B(Star), R(2), // 4477 B(LdaSmi8), U8(20), //
4452 B(LdaSmi8), U8(3), // 4478 B(Star), R(0), //
4453 B(Star), R(0), // 4479 B(PopContext), R(1), //
4454 B(LdaZero), // 4480 B(LdaSmi8), U8(-1), //
4455 B(TestEqualStrict), R(2), // 4481 B(Star), R(2), //
4456 B(JumpIfTrue), U8(4), // 4482 B(Jump), U8(7), //
4457 B(Jump), U8(5), // 4483 B(Star), R(3), //
4458 B(Ldar), R(3), // 4484 B(LdaZero), //
4459 B(ReThrow), // 4485 B(Star), R(2), //
4460 B(LdaUndefined), // 4486 B(CallRuntime), U16(Runtime::kInterpreterClearPendingMessage), //
4461 B(Return), // 4487 /* */ R(0), U8(0), //
4488 B(Star), R(4), //
4489 B(LdaSmi8), U8(3), //
4490 B(Star), R(0), //
4491 B(CallRuntime), U16(Runtime::kInterpreterSetPendingMessage), //
4492 /* */ R(4), U8(1), //
4493 B(LdaZero), //
4494 B(TestEqualStrict), R(2), //
4495 B(JumpIfTrue), U8(4), //
4496 B(Jump), U8(5), //
4497 B(Ldar), R(3), //
4498 B(ReThrow), //
4499 B(LdaUndefined), //
4500 B(Return), //
4462 }, 4501 },
4463 1, 4502 1,
4464 {"e"}, 4503 {"e"},
4465 3, 4504 3,
4466 {{0, 54, 60}, {0, 29, 31}, {0, 4, 6}}}, 4505 {{0, 72, 78}, {0, 38, 40}, {0, 4, 6}}},
4467 }; 4506 };
4468 4507
4469 for (size_t i = 0; i < arraysize(snippets); i++) { 4508 for (size_t i = 0; i < arraysize(snippets); i++) {
4470 Handle<BytecodeArray> bytecode_array = 4509 Handle<BytecodeArray> bytecode_array =
4471 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); 4510 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet);
4472 CheckBytecodeArrayEqual(snippets[i], bytecode_array); 4511 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
4473 } 4512 }
4474 } 4513 }
4475 4514
4476 4515
(...skipping 3082 matching lines...) Expand 10 before | Expand all | Expand 10 after
7559 Handle<BytecodeArray> bytecode_array = 7598 Handle<BytecodeArray> bytecode_array =
7560 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); 7599 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet);
7561 CheckBytecodeArrayEqual(snippets[i], bytecode_array); 7600 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
7562 } 7601 }
7563 FLAG_harmony_do_expressions = old_flag; 7602 FLAG_harmony_do_expressions = old_flag;
7564 } 7603 }
7565 7604
7566 } // namespace interpreter 7605 } // namespace interpreter
7567 } // namespace internal 7606 } // namespace internal
7568 } // namespace v8 7607 } // namespace v8
OLDNEW
« no previous file with comments | « test/cctest/cctest.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698