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

Unified Diff: src/asmjs/asm-js.cc

Issue 2251433002: [wasm] asm.js - Check stdlib.NaN is valid, prepare for the rest. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix Created 4 years, 4 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
Index: src/asmjs/asm-js.cc
diff --git a/src/asmjs/asm-js.cc b/src/asmjs/asm-js.cc
index cb44ec237a2f3c48267d1d834fb3b6a2ee4b867f..8ea367e8006cea921ada41a6f6b37f580cf1d526 100644
--- a/src/asmjs/asm-js.cc
+++ b/src/asmjs/asm-js.cc
@@ -74,16 +74,56 @@ MaybeHandle<FixedArray> AsmJs::ConvertAsmToWasm(ParseInfo* info) {
internal::wasm::kAsmJsOrigin);
DCHECK(!compiled.is_null());
- Handle<FixedArray> result = info->isolate()->factory()->NewFixedArray(2);
+ wasm::AsmTyper::StdlibSet uses = typer.StdlibUses();
+ Handle<FixedArray> uses_array =
+ info->isolate()->factory()->NewFixedArray(static_cast<int>(uses.size()));
+ int count = 0;
+ for (auto i : uses) {
+ uses_array->set(count++, Smi::FromInt(i));
+ }
+
+ Handle<FixedArray> result = info->isolate()->factory()->NewFixedArray(3);
result->set(0, *compiled.ToHandleChecked());
result->set(1, *foreign_globals);
+ result->set(2, *uses_array);
return result;
}
+bool AsmJs::IsStdlibValid(i::Isolate* isolate, Handle<FixedArray> wasm_data,
+ Handle<JSReceiver> stdlib) {
+ i::Handle<i::FixedArray> uses(i::FixedArray::cast(wasm_data->get(2)));
+ for (int i = 0; i < uses->length(); ++i) {
+ int32_t kind;
+ if (!uses->get(i)->ToInt32(&kind)) {
+ continue;
+ }
+ switch (kind) {
+ case wasm::AsmTyper::StandardMember::kNaN: {
+ i::Handle<i::Name> name(isolate->factory()->InternalizeOneByteString(
+ STATIC_CHAR_VECTOR("NaN")));
+ i::MaybeHandle<i::Object> maybe_value =
+ i::Object::GetProperty(stdlib, name);
+ if (maybe_value.is_null()) {
+ return false;
+ }
+ i::Handle<i::Object> value = maybe_value.ToHandleChecked();
+ if (!value->IsNaN()) {
+ return false;
+ }
titzer 2016/08/19 10:00:28 Do you want to return true here and then false for
bradn 2016/08/19 17:29:08 Actually not, because this needs to loop to check
+ } break;
+
+ default: {
+ // TODO(bradnelson): Implement check for the others
+ }
+ }
+ }
+ return true;
+}
+
MaybeHandle<Object> AsmJs::InstantiateAsmWasm(i::Isolate* isolate,
Handle<FixedArray> wasm_data,
Handle<JSArrayBuffer> memory,
- Handle<JSObject> foreign) {
+ Handle<JSReceiver> foreign) {
i::Handle<i::FixedArray> compiled(i::FixedArray::cast(wasm_data->get(0)));
i::Handle<i::FixedArray> foreign_globals(
i::FixedArray::cast(wasm_data->get(1)));
« no previous file with comments | « src/asmjs/asm-js.h ('k') | src/asmjs/asm-typer.h » ('j') | src/runtime/runtime-compiler.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698