Commit 567dcad1 authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[wasm] Fix prototype property of exported functions

According to the spec, exported wasm functions should not have a
[[Construct]] method, hence they don't have a prototype.

R=bmeurer@chromium.org
CC=​titzer@chromium.org

Bug: v8:7503
Change-Id: I9e142d65a80c0ef6dbd743421771f194c2d50614
Reviewed-on: https://chromium-review.googlesource.com/939782Reviewed-by: 's avatarBenedikt Meurer <bmeurer@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#51622}
parent 03caf2c2
......@@ -853,8 +853,11 @@ Handle<WasmExportedFunction> WasmExportedFunction::New(
shared->set_length(arity);
shared->set_internal_formal_parameter_count(arity);
NewFunctionArgs args = NewFunctionArgs::ForWasm(
name, export_wrapper, isolate->sloppy_function_map());
name, export_wrapper, isolate->sloppy_function_without_prototype_map());
Handle<JSFunction> js_function = isolate->factory()->NewFunction(args);
// According to the spec, exported functions should not have a [[Construct]]
// method.
DCHECK(!js_function->IsConstructor());
js_function->set_shared(*shared);
Handle<Symbol> instance_symbol(isolate->factory()->wasm_instance_symbol());
......
......@@ -17,8 +17,9 @@ load("test/mjsunit/wasm/wasm-module-builder.js");
var func = builder.instantiate().exports.nine;
// Check type and existence of prototype
assertEquals("function", typeof func.apply);
assertTrue(func.prototype != undefined);
assertEquals('function', typeof func);
assertEquals('function', typeof func.apply);
assertEquals('prototype' in func, false);
assertEquals(String(f.index), func.name);
assertEquals(undefined, func.displayName);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment