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

Side by Side Diff: test/cctest/compiler/test-ffi.cc

Issue 2607993003: FFI Compiler based on code stub assembler (Closed)
Patch Set: Rebase Created 3 years, 11 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
« src/compiler/ffi-compiler.cc ('K') | « 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 2016 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/codegen.h"
6 #include "src/compiler/ffi-compiler.h"
7
8 #include "test/cctest/cctest.h"
9
10 using namespace v8::internal;
11 using namespace v8::internal::compiler;
12 using namespace v8::internal::ffi;
13
14 static void hello_world() { printf("hello world from native code\n"); }
15
16 TEST(Run_FFI_Hello) {
17 Isolate* isolate = CcTest::InitIsolateOnce();
18 HandleScope scope(isolate);
19
20 Handle<String> name =
21 isolate->factory()->InternalizeUtf8String("hello_world");
22 Handle<Object> undefined = isolate->factory()->undefined_value();
23
24 AccountingAllocator allocator;
25 Zone zone(&allocator, ZONE_NAME);
26 FFISignature::Builder sig_builder(&zone, 0, 0);
27 NativeFunction func = {sig_builder.Build(),
28 reinterpret_cast<uint8_t*>(hello_world)};
29
30 Handle<JSFunction> jsfunc = CompileJSToNativeWrapper(isolate, name, func);
31
32 Handle<Object> result =
33 Execution::Call(isolate, jsfunc, undefined, 0, nullptr).ToHandleChecked();
34
35 CHECK(result->IsUndefined(isolate));
36 }
OLDNEW
« src/compiler/ffi-compiler.cc ('K') | « test/cctest/cctest.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698