| OLD | NEW |
| 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 960 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 971 } | 971 } |
| 972 if (result->IsHeapNumber()) { | 972 if (result->IsHeapNumber()) { |
| 973 return static_cast<int32_t>(HeapNumber::cast(*result)->value()); | 973 return static_cast<int32_t>(HeapNumber::cast(*result)->value()); |
| 974 } | 974 } |
| 975 thrower.Error("WASM.compileRun() failed: Return value should be number"); | 975 thrower.Error("WASM.compileRun() failed: Return value should be number"); |
| 976 return -1; | 976 return -1; |
| 977 } | 977 } |
| 978 | 978 |
| 979 MaybeHandle<String> GetWasmFunctionName(Handle<JSObject> wasm, | 979 MaybeHandle<String> GetWasmFunctionName(Handle<JSObject> wasm, |
| 980 uint32_t func_index) { | 980 uint32_t func_index) { |
| 981 DCHECK(IsWasmObject(wasm)); |
| 981 Object* func_names_arr_obj = wasm->GetInternalField(kWasmFunctionNamesArray); | 982 Object* func_names_arr_obj = wasm->GetInternalField(kWasmFunctionNamesArray); |
| 982 if (func_names_arr_obj->IsUndefined()) return Handle<String>::null(); | 983 if (func_names_arr_obj->IsUndefined()) return Handle<String>::null(); |
| 983 return GetWasmFunctionNameFromTable( | 984 return GetWasmFunctionNameFromTable( |
| 984 handle(ByteArray::cast(func_names_arr_obj)), func_index); | 985 handle(ByteArray::cast(func_names_arr_obj)), func_index); |
| 985 } | 986 } |
| 986 | 987 |
| 988 bool IsWasmObject(Handle<JSObject> object) { |
| 989 // TODO(clemensh): Check wasm byte header once we store a copy of the bytes. |
| 990 return object->GetInternalFieldCount() == kWasmModuleInternalFieldCount && |
| 991 object->GetInternalField(kWasmModuleCodeTable)->IsFixedArray() && |
| 992 object->GetInternalField(kWasmMemArrayBuffer)->IsJSArrayBuffer() && |
| 993 (object->GetInternalField(kWasmFunctionNamesArray)->IsByteArray() || |
| 994 object->GetInternalField(kWasmFunctionNamesArray)->IsUndefined()); |
| 995 } |
| 996 |
| 987 } // namespace wasm | 997 } // namespace wasm |
| 988 } // namespace internal | 998 } // namespace internal |
| 989 } // namespace v8 | 999 } // namespace v8 |
| OLD | NEW |