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

Unified Diff: test/cctest/ffi/test-ffi.cc

Issue 2607993003: FFI Compiler based on code stub assembler (Closed)
Patch Set: Move FFIAssembler from .h to .cc 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/cctest/ffi/OWNERS ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/ffi/test-ffi.cc
diff --git a/test/cctest/ffi/test-ffi.cc b/test/cctest/ffi/test-ffi.cc
new file mode 100644
index 0000000000000000000000000000000000000000..8a82a21dec6e628199cad10a248f02d8983417a9
--- /dev/null
+++ b/test/cctest/ffi/test-ffi.cc
@@ -0,0 +1,39 @@
+// Copyright 2017 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "src/codegen.h"
+#include "src/ffi/ffi-compiler.h"
+#include "test/cctest/cctest.h"
+
+namespace v8 {
+namespace internal {
+namespace ffi {
+
+static void hello_world() { printf("hello world from native code\n"); }
+
+TEST(Run_FFI_Hello) {
+ Isolate* isolate = CcTest::InitIsolateOnce();
+ HandleScope scope(isolate);
+
+ Handle<String> name =
+ isolate->factory()->InternalizeUtf8String("hello_world");
+ Handle<Object> undefined = isolate->factory()->undefined_value();
+
+ AccountingAllocator allocator;
+ Zone zone(&allocator, ZONE_NAME);
+ FFISignature::Builder sig_builder(&zone, 0, 0);
+ NativeFunction func = {sig_builder.Build(),
+ reinterpret_cast<uint8_t*>(hello_world)};
+
+ Handle<JSFunction> jsfunc = CompileJSToNativeWrapper(isolate, name, func);
+
+ Handle<Object> result =
+ Execution::Call(isolate, jsfunc, undefined, 0, nullptr).ToHandleChecked();
+
+ CHECK(result->IsUndefined(isolate));
+}
+
+} // namespace ffi
+} // namespace internal
+} // namespace v8
« no previous file with comments | « test/cctest/ffi/OWNERS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698