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

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: 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 2014 the V8 project authors. All rights reserved.
oth 2015/07/30 09:49:01 s/2014/2015/
rmcilroy 2015/07/30 11:02:17 Done, thanks.
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/interpreter.h"
10 #include "test/cctest/cctest.h"
11
12 namespace v8 {
13 namespace internal {
14
15 class InterpreterTester {
16 public:
17 InterpreterTester(Isolate* isolate, Handle<BytecodeArray> bytecode)
18 : isolate_(isolate), function_(GetBytecodeFunction(isolate, bytecode)) {
19 i::FLAG_ignition = true;
20 // TODO(rmcilroy): don't regenerate if it's already generated.
21 isolate_->interpreter()->Initialize(isolate_);
22 }
23 virtual ~InterpreterTester() {}
24
25 MaybeHandle<Object> Call() {
26 Handle<Object> args[] = {};
27 return Execution::Call(isolate_, function_,
28 isolate_->factory()->undefined_value(), 0, args,
29 false);
30 }
31
32 private:
33 Isolate* isolate_;
34 Handle<JSFunction> function_;
35
36 static Handle<JSFunction> GetBytecodeFunction(
37 Isolate* isolate, Handle<BytecodeArray> bytecode_array) {
38 Handle<JSFunction> function = v8::Utils::OpenHandle(
39 *v8::Handle<v8::Function>::Cast(CompileRun("(function(){})")));
40 function->ReplaceCode(*isolate->builtins()->InterpreterEntryTrampoline());
41 function->shared()->set_function_data(*bytecode_array);
42 return function;
43 }
44 };
45
46 } // namespace internal
47 } // namespace v8
48
49 using namespace v8::internal;
50
51 TEST(TestInterpreterReturn) {
52 InitializedHandleScope handles;
53 Handle<Object> undefined_value =
54 handles.main_isolate()->factory()->undefined_value();
55 // TODO(rmcilroy): Use a proper bytecode builder for this.
56 uint8_t raw_bytecodes[1] = {1};
57 Handle<BytecodeArray> bytecode_array =
58 handles.main_isolate()->factory()->NewBytecodeArray(1, raw_bytecodes,
59 kPointerSize);
60 InterpreterTester tester(handles.main_isolate(), bytecode_array);
61 Handle<Object> return_val = tester.Call().ToHandleChecked();
62 CHECK(return_val.is_identical_to(undefined_value));
63 }
64
65
66 TEST(TestInterpreterLiteral0) {
67 InitializedHandleScope handles;
68 // TODO(rmcilroy): Use a proper bytecode builder for this.
69 uint8_t raw_bytecodes[3] = {0, 0, 1};
70 Handle<BytecodeArray> bytecode_array =
71 handles.main_isolate()->factory()->NewBytecodeArray(3, raw_bytecodes,
72 kPointerSize);
73 InterpreterTester tester(handles.main_isolate(), bytecode_array);
74 Handle<Object> return_val = tester.Call().ToHandleChecked();
75 CHECK_EQ(*return_val, i::Smi::FromInt(0));
76 }
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