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

Unified Diff: src/d8.cc

Issue 2433273002: [wasm] Avoid double-serializing the wire bytes (Closed)
Patch Set: externalize/internalize buffer Created 4 years, 2 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 | « src/d8.h ('k') | src/runtime/runtime.h » ('j') | src/runtime/runtime-test.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/d8.cc
diff --git a/src/d8.cc b/src/d8.cc
index 28ebfc05b9839327fb596ac491514e1b341fe1a9..39d09d42194f1c25142fdf70e45abc5ca8319997 100644
--- a/src/d8.cc
+++ b/src/d8.cc
@@ -1393,6 +1393,15 @@ Local<ObjectTemplate> Shell::CreateGlobalTemplate(Isolate* isolate) {
String::NewFromUtf8(isolate, "readbuffer", NewStringType::kNormal)
.ToLocalChecked(),
FunctionTemplate::New(isolate, ReadBuffer));
+ Local<FunctionTemplate> experimental =
+ FunctionTemplate::New(isolate, ExperimentalDoubleAdder);
+ experimental->Set(isolate, "native_variant",
+ External::New(isolate, reinterpret_cast<void*>(
+ ExperimentalNativeDoubleAdder)));
+ global_template->Set(String::NewFromUtf8(isolate, "experimentalDoubleAdder",
+ NewStringType::kNormal)
+ .ToLocalChecked(),
+ experimental);
global_template->Set(
String::NewFromUtf8(isolate, "readline", NewStringType::kNormal)
.ToLocalChecked(),
@@ -1725,6 +1734,18 @@ void Shell::ReadBuffer(const v8::FunctionCallbackInfo<v8::Value>& args) {
args.GetReturnValue().Set(buffer);
}
+void Shell::ExperimentalDoubleAdder(
+ const v8::FunctionCallbackInfo<v8::Value>& args) {
+ DCHECK(sizeof(char) == sizeof(uint8_t)); // NOLINT
+ Local<Number> a = Local<Number>::Cast(args[0]);
+ Local<Number> b = Local<Number>::Cast(args[1]);
+ Local<Number> ret = Number::New(args.GetIsolate(), a->Value() + b->Value());
+ args.GetReturnValue().Set(ret);
+}
+
+double Shell::ExperimentalNativeDoubleAdder(double a, double b) {
+ return a + b;
+}
// Reads a file into a v8 string.
Local<String> Shell::ReadFile(Isolate* isolate, const char* name) {
« no previous file with comments | « src/d8.h ('k') | src/runtime/runtime.h » ('j') | src/runtime/runtime-test.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698