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

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

Issue 1412953007: [Interpreter] Fill out function prologue support. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebased Created 5 years, 2 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/x87/builtins-x87.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 3344 matching lines...) Expand 10 before | Expand all | Expand 10 after
3355 {"unallocated"}}, 3355 {"unallocated"}},
3356 }; 3356 };
3357 3357
3358 for (size_t i = 0; i < arraysize(snippets); i++) { 3358 for (size_t i = 0; i < arraysize(snippets); i++) {
3359 Handle<BytecodeArray> bytecode_array = 3359 Handle<BytecodeArray> bytecode_array =
3360 helper.MakeBytecode(snippets[i].code_snippet, "f"); 3360 helper.MakeBytecode(snippets[i].code_snippet, "f");
3361 CheckBytecodeArrayEqual(snippets[i], bytecode_array); 3361 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
3362 } 3362 }
3363 } 3363 }
3364 3364
3365
3366 TEST(CreateArguments) {
3367 InitializedHandleScope handle_scope;
3368 BytecodeGeneratorHelper helper;
3369 Zone zone;
3370
3371 int closure = Register::function_closure().index();
3372 int first_context_slot = Context::MIN_CONTEXT_SLOTS;
3373
3374 FeedbackVectorSpec feedback_spec(&zone);
3375 FeedbackVectorSlot slot = feedback_spec.AddKeyedLoadICSlot();
3376
3377 Handle<i::TypeFeedbackVector> vector =
3378 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec);
3379
3380 ExpectedSnippet<const char*> snippets[] = {
3381 {"function f() { return arguments; }",
3382 1 * kPointerSize,
3383 1,
3384 6,
3385 {
3386 B(CreateMappedArguments), //
3387 B(Star), R(0), //
3388 B(Ldar), R(0), //
3389 B(Return), //
3390 }},
3391 {"function f() { return arguments[0]; }",
3392 1 * kPointerSize,
3393 1,
3394 8,
3395 {
3396 B(CreateMappedArguments), //
3397 B(Star), R(0), //
3398 B(LdaZero), //
3399 B(KeyedLoadICSloppy), R(0), U8(vector->GetIndex(slot)), //
3400 B(Return), //
3401 }},
3402 {"function f() { 'use strict'; return arguments; }",
3403 1 * kPointerSize,
3404 1,
3405 6,
3406 {
3407 B(CreateUnmappedArguments), //
3408 B(Star), R(0), //
3409 B(Ldar), R(0), //
3410 B(Return), //
3411 }},
3412 {"function f(a) { return arguments[0]; }",
3413 2 * kPointerSize,
3414 2,
3415 20,
3416 {
3417 B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), //
3418 U8(1), //
3419 B(PushContext), R(1), //
3420 B(Ldar), R(BytecodeGeneratorHelper::kLastParamIndex), //
3421 B(StaContextSlot), R(1), U8(first_context_slot), //
3422 B(CreateMappedArguments), //
3423 B(Star), R(0), //
3424 B(LdaZero), //
3425 B(KeyedLoadICSloppy), R(0), U8(vector->GetIndex(slot)), //
3426 B(Return), //
3427 }},
3428 {"function f(a, b, c) { return arguments; }",
3429 2 * kPointerSize,
3430 4,
3431 28,
3432 {
3433 B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), //
3434 U8(1), //
3435 B(PushContext), R(1), //
3436 B(Ldar), R(BytecodeGeneratorHelper::kLastParamIndex - 2), //
3437 B(StaContextSlot), R(1), U8(first_context_slot + 2), //
3438 B(Ldar), R(BytecodeGeneratorHelper::kLastParamIndex - 1), //
3439 B(StaContextSlot), R(1), U8(first_context_slot + 1), //
3440 B(Ldar), R(BytecodeGeneratorHelper::kLastParamIndex), //
3441 B(StaContextSlot), R(1), U8(first_context_slot), //
3442 B(CreateMappedArguments), //
3443 B(Star), R(0), //
3444 B(Ldar), R(0), //
3445 B(Return), //
3446 }},
3447 {"function f(a, b, c) { 'use strict'; return arguments; }",
3448 1 * kPointerSize,
3449 4,
3450 6,
3451 {
3452 B(CreateUnmappedArguments), //
3453 B(Star), R(0), //
3454 B(Ldar), R(0), //
3455 B(Return), //
3456 }},
3457 };
3458
3459 for (size_t i = 0; i < arraysize(snippets); i++) {
3460 Handle<BytecodeArray> bytecode_array =
3461 helper.MakeBytecodeForFunction(snippets[i].code_snippet);
3462 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
3463 }
3464 }
3465
3466
3467 TEST(IllegalRedeclaration) {
3468 InitializedHandleScope handle_scope;
3469 BytecodeGeneratorHelper helper;
3470
3471 ExpectedSnippet<const char*> snippets[] = {
3472 {"const a = 1; { var a = 2; }",
3473 3 * kPointerSize,
3474 1,
3475 14,
3476 {
3477 B(LdaSmi8), U8(MessageTemplate::kVarRedeclaration), //
3478 B(Star), R(1), //
3479 B(LdaConstant), U8(0), //
3480 B(Star), R(2), //
3481 B(CallRuntime), U16(Runtime::kNewSyntaxError), R(1), U8(2), //
3482 B(Throw), //
3483 },
3484 1,
3485 {"a"}},
3486 };
3487
3488 for (size_t i = 0; i < arraysize(snippets); i++) {
3489 Handle<BytecodeArray> bytecode_array =
3490 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet);
3491 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
3492 }
3493 }
3494
3365 } // namespace interpreter 3495 } // namespace interpreter
3366 } // namespace internal 3496 } // namespace internal
3367 } // namespace v8 3497 } // namespace v8
OLDNEW
« no previous file with comments | « src/x87/builtins-x87.cc ('k') | test/cctest/interpreter/test-interpreter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698