OLD | NEW |
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 <utility> | 5 #include <utility> |
6 | 6 |
7 #include "src/v8.h" | 7 #include "src/v8.h" |
8 | 8 |
9 #include "src/compiler/pipeline.h" | 9 #include "src/compiler/pipeline.h" |
10 #include "src/execution.h" | 10 #include "src/execution.h" |
11 #include "src/handles.h" | 11 #include "src/handles.h" |
12 #include "src/interpreter/bytecode-array-builder.h" | 12 #include "src/interpreter/bytecode-array-builder.h" |
13 #include "src/interpreter/interpreter.h" | 13 #include "src/interpreter/interpreter.h" |
14 #include "src/parser.h" | 14 #include "src/parser.h" |
15 #include "test/cctest/cctest.h" | 15 #include "test/cctest/cctest.h" |
16 | 16 |
17 namespace v8 { | 17 namespace v8 { |
18 namespace internal { | 18 namespace internal { |
19 namespace compiler { | 19 namespace compiler { |
20 | 20 |
21 | 21 |
22 static const char kFunctionName[] = "f"; | 22 static const char kFunctionName[] = "f"; |
23 | 23 |
24 | 24 |
25 static MaybeHandle<Object> CallFunction(Isolate* isolate, | 25 static MaybeHandle<Object> CallFunction(Isolate* isolate, |
26 Handle<JSFunction> function) { | 26 Handle<JSFunction> function) { |
27 return Execution::Call(isolate, function, | 27 return Execution::Call(isolate, function, |
28 isolate->factory()->undefined_value(), 0, nullptr, | 28 isolate->factory()->undefined_value(), 0, nullptr); |
29 false); | |
30 } | 29 } |
31 | 30 |
32 | 31 |
33 template <class... A> | 32 template <class... A> |
34 static MaybeHandle<Object> CallFunction(Isolate* isolate, | 33 static MaybeHandle<Object> CallFunction(Isolate* isolate, |
35 Handle<JSFunction> function, | 34 Handle<JSFunction> function, |
36 A... args) { | 35 A... args) { |
37 Handle<Object> argv[] = {args...}; | 36 Handle<Object> argv[] = {args...}; |
38 return Execution::Call(isolate, function, | 37 return Execution::Call(isolate, function, |
39 isolate->factory()->undefined_value(), sizeof...(args), | 38 isolate->factory()->undefined_value(), sizeof...(args), |
40 argv, false); | 39 argv); |
41 } | 40 } |
42 | 41 |
43 | 42 |
44 template <class... A> | 43 template <class... A> |
45 class BytecodeGraphCallable { | 44 class BytecodeGraphCallable { |
46 public: | 45 public: |
47 BytecodeGraphCallable(Isolate* isolate, Handle<JSFunction> function) | 46 BytecodeGraphCallable(Isolate* isolate, Handle<JSFunction> function) |
48 : isolate_(isolate), function_(function) {} | 47 : isolate_(isolate), function_(function) {} |
49 virtual ~BytecodeGraphCallable() {} | 48 virtual ~BytecodeGraphCallable() {} |
50 | 49 |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 snippets[i].code_snippet, kFunctionName); | 249 snippets[i].code_snippet, kFunctionName); |
251 | 250 |
252 BytecodeGraphTester tester(isolate, zone, script.start()); | 251 BytecodeGraphTester tester(isolate, zone, script.start()); |
253 auto callable = tester.GetCallable<Handle<Object>, Handle<Object>>(); | 252 auto callable = tester.GetCallable<Handle<Object>, Handle<Object>>(); |
254 Handle<Object> return_value = | 253 Handle<Object> return_value = |
255 callable(snippets[i].parameter(0), snippets[i].parameter(1)) | 254 callable(snippets[i].parameter(0), snippets[i].parameter(1)) |
256 .ToHandleChecked(); | 255 .ToHandleChecked(); |
257 CHECK(return_value->SameValue(*snippets[i].return_value())); | 256 CHECK(return_value->SameValue(*snippets[i].return_value())); |
258 } | 257 } |
259 } | 258 } |
OLD | NEW |