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 943 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
954 } | 954 } |
955 if (result->IsHeapNumber()) { | 955 if (result->IsHeapNumber()) { |
956 return static_cast<int32_t>(HeapNumber::cast(*result)->value()); | 956 return static_cast<int32_t>(HeapNumber::cast(*result)->value()); |
957 } | 957 } |
958 thrower.Error("WASM.compileRun() failed: Return value should be number"); | 958 thrower.Error("WASM.compileRun() failed: Return value should be number"); |
959 return -1; | 959 return -1; |
960 } | 960 } |
961 | 961 |
962 MaybeHandle<String> GetWasmFunctionName(Handle<JSObject> wasm, | 962 MaybeHandle<String> GetWasmFunctionName(Handle<JSObject> wasm, |
963 uint32_t func_index) { | 963 uint32_t func_index) { |
| 964 DCHECK(IsWasmObject(wasm)); |
964 Object* func_names_arr_obj = wasm->GetInternalField(kWasmFunctionNamesArray); | 965 Object* func_names_arr_obj = wasm->GetInternalField(kWasmFunctionNamesArray); |
965 if (func_names_arr_obj->IsUndefined()) return Handle<String>::null(); | 966 if (func_names_arr_obj->IsUndefined()) return Handle<String>::null(); |
966 return GetWasmFunctionNameFromTable( | 967 return GetWasmFunctionNameFromTable( |
967 handle(ByteArray::cast(func_names_arr_obj)), func_index); | 968 handle(ByteArray::cast(func_names_arr_obj)), func_index); |
968 } | 969 } |
969 | 970 |
| 971 bool IsWasmObject(Handle<JSObject> object) { |
| 972 // TODO(clemensh): Check wasm byte header once we store a copy of the bytes. |
| 973 return object->GetInternalFieldCount() == kWasmModuleInternalFieldCount && |
| 974 object->GetInternalField(kWasmModuleCodeTable)->IsFixedArray() && |
| 975 object->GetInternalField(kWasmMemArrayBuffer)->IsJSArrayBuffer() && |
| 976 (object->GetInternalField(kWasmFunctionNamesArray)->IsByteArray() || |
| 977 object->GetInternalField(kWasmFunctionNamesArray)->IsUndefined()); |
| 978 } |
| 979 |
970 } // namespace wasm | 980 } // namespace wasm |
971 } // namespace internal | 981 } // namespace internal |
972 } // namespace v8 | 982 } // namespace v8 |
OLD | NEW |