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

Side by Side Diff: src/wasm/wasm-module.cc

Issue 2059173002: Reland of place all remaining Oddball checks with new function (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 6 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
« no previous file with comments | « src/string-stream.cc ('k') | test/cctest/compiler/test-js-context-specialization.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/base/atomic-utils.h" 5 #include "src/base/atomic-utils.h"
6 #include "src/macro-assembler.h" 6 #include "src/macro-assembler.h"
7 #include "src/objects.h" 7 #include "src/objects.h"
8 #include "src/property-descriptor.h" 8 #include "src/property-descriptor.h"
9 #include "src/v8.h" 9 #include "src/v8.h"
10 10
(...skipping 966 matching lines...) Expand 10 before | Expand all | Expand 10 after
977 } 977 }
978 if (result->IsHeapNumber()) { 978 if (result->IsHeapNumber()) {
979 return static_cast<int32_t>(HeapNumber::cast(*result)->value()); 979 return static_cast<int32_t>(HeapNumber::cast(*result)->value());
980 } 980 }
981 thrower.Error("WASM.compileRun() failed: Return value should be number"); 981 thrower.Error("WASM.compileRun() failed: Return value should be number");
982 return -1; 982 return -1;
983 } 983 }
984 984
985 Handle<Object> GetWasmFunctionNameOrNull(Isolate* isolate, Handle<Object> wasm, 985 Handle<Object> GetWasmFunctionNameOrNull(Isolate* isolate, Handle<Object> wasm,
986 uint32_t func_index) { 986 uint32_t func_index) {
987 if (!wasm->IsUndefined()) { 987 if (!wasm->IsUndefined(isolate)) {
988 Handle<ByteArray> func_names_arr_obj( 988 Handle<ByteArray> func_names_arr_obj(
989 ByteArray::cast(Handle<JSObject>::cast(wasm)->GetInternalField( 989 ByteArray::cast(Handle<JSObject>::cast(wasm)->GetInternalField(
990 kWasmFunctionNamesArray)), 990 kWasmFunctionNamesArray)),
991 isolate); 991 isolate);
992 // TODO(clemens): Extract this from the module bytes; skip whole function 992 // TODO(clemens): Extract this from the module bytes; skip whole function
993 // name table. 993 // name table.
994 Handle<Object> name; 994 Handle<Object> name;
995 if (GetWasmFunctionNameFromTable(func_names_arr_obj, func_index) 995 if (GetWasmFunctionNameFromTable(func_names_arr_obj, func_index)
996 .ToHandle(&name)) { 996 .ToHandle(&name)) {
997 return name; 997 return name;
998 } 998 }
999 } 999 }
1000 return isolate->factory()->null_value(); 1000 return isolate->factory()->null_value();
1001 } 1001 }
1002 1002
1003 Handle<String> GetWasmFunctionName(Isolate* isolate, Handle<Object> wasm, 1003 Handle<String> GetWasmFunctionName(Isolate* isolate, Handle<Object> wasm,
1004 uint32_t func_index) { 1004 uint32_t func_index) {
1005 Handle<Object> name_or_null = 1005 Handle<Object> name_or_null =
1006 GetWasmFunctionNameOrNull(isolate, wasm, func_index); 1006 GetWasmFunctionNameOrNull(isolate, wasm, func_index);
1007 if (!name_or_null->IsNull()) return Handle<String>::cast(name_or_null); 1007 if (!name_or_null->IsNull(isolate)) {
1008 return Handle<String>::cast(name_or_null);
1009 }
1008 return isolate->factory()->NewStringFromStaticChars("<WASM UNNAMED>"); 1010 return isolate->factory()->NewStringFromStaticChars("<WASM UNNAMED>");
1009 } 1011 }
1010 1012
1011 bool IsWasmObject(Handle<JSObject> object) { 1013 bool IsWasmObject(Handle<JSObject> object) {
1012 // TODO(clemensh): Check wasm byte header once we store a copy of the bytes. 1014 // TODO(clemensh): Check wasm byte header once we store a copy of the bytes.
1013 return object->GetInternalFieldCount() == kWasmModuleInternalFieldCount && 1015 return object->GetInternalFieldCount() == kWasmModuleInternalFieldCount &&
1014 object->GetInternalField(kWasmModuleCodeTable)->IsFixedArray() && 1016 object->GetInternalField(kWasmModuleCodeTable)->IsFixedArray() &&
1015 object->GetInternalField(kWasmMemArrayBuffer)->IsJSArrayBuffer() && 1017 object->GetInternalField(kWasmMemArrayBuffer)->IsJSArrayBuffer() &&
1016 object->GetInternalField(kWasmFunctionNamesArray)->IsByteArray(); 1018 object->GetInternalField(kWasmFunctionNamesArray)->IsByteArray();
1017 } 1019 }
1018 1020
1019 } // namespace wasm 1021 } // namespace wasm
1020 } // namespace internal 1022 } // namespace internal
1021 } // namespace v8 1023 } // namespace v8
OLDNEW
« no previous file with comments | « src/string-stream.cc ('k') | test/cctest/compiler/test-js-context-specialization.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698