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

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

Issue 1269683002: [interpreter] Adds interpreter cctests. (Closed) Base URL: ssh://rmcilroy.lon.corp.google.com///usr/local/google/code/v8_full/v8@interpreter_builtins
Patch Set: Use BytecodeArrayBuilder and drop all but Return test. Created 5 years, 4 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.gyp ('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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "src/v8.h"
6
7 #include "src/execution.h"
8 #include "src/handles.h"
9 #include "src/interpreter/bytecode-array-builder.h"
10 #include "src/interpreter/interpreter.h"
11 #include "test/cctest/cctest.h"
12
13 namespace v8 {
14 namespace internal {
15
16 class InterpreterTester {
17 public:
18 InterpreterTester(Isolate* isolate, Handle<BytecodeArray> bytecode)
19 : isolate_(isolate), function_(GetBytecodeFunction(isolate, bytecode)) {
20 i::FLAG_ignition = true;
21 Handle<FixedArray> empty_array = isolate->factory()->empty_fixed_array();
22 Handle<FixedArray> interpreter_table =
23 isolate->factory()->interpreter_table();
24 if (interpreter_table.is_identical_to(empty_array)) {
25 // Ensure handler table is generated.
26 isolate->interpreter()->Initialize(true);
27 }
28 }
29 virtual ~InterpreterTester() {}
30
31 MaybeHandle<Object> Call() {
titzer 2015/07/31 12:09:12 Can we factor the Call() out of the tester? This
rmcilroy 2015/07/31 17:52:59 Done.
32 Handle<Object> args[] = {};
33 return Execution::Call(isolate_, function_,
34 isolate_->factory()->undefined_value(), 0, args,
35 false);
36 }
37
38 private:
39 Isolate* isolate_;
40 Handle<JSFunction> function_;
41
42 static Handle<JSFunction> GetBytecodeFunction(
43 Isolate* isolate, Handle<BytecodeArray> bytecode_array) {
44 Handle<JSFunction> function = v8::Utils::OpenHandle(
45 *v8::Handle<v8::Function>::Cast(CompileRun("(function(){})")));
46 function->ReplaceCode(*isolate->builtins()->InterpreterEntryTrampoline());
47 function->shared()->set_function_data(*bytecode_array);
48 return function;
49 }
50 };
51
52 } // namespace internal
53 } // namespace v8
54
55 using namespace v8::internal;
56 using namespace v8::internal::interpreter;
57
58 TEST(TestInterpreterReturn) {
59 InitializedHandleScope handles;
60 Handle<Object> undefined_value =
61 handles.main_isolate()->factory()->undefined_value();
62
63 BytecodeArrayBuilder builder(handles.main_isolate());
64 // TODO(rmcilroy) set to 0 once BytecodeArray update to allow zero size
65 // register file.
66 builder.set_locals_count(1);
67 builder.Return();
68 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray();
69
70 InterpreterTester tester(handles.main_isolate(), bytecode_array);
71 Handle<Object> return_val = tester.Call().ToHandleChecked();
72 CHECK(return_val.is_identical_to(undefined_value));
73 }
OLDNEW
« no previous file with comments | « test/cctest/cctest.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698