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/api-natives.h" | 5 #include "src/api-natives.h" |
6 #include "src/api.h" | 6 #include "src/api.h" |
7 #include "src/asmjs/asm-js.h" | 7 #include "src/asmjs/asm-js.h" |
8 #include "src/asmjs/asm-typer.h" | 8 #include "src/asmjs/asm-typer.h" |
9 #include "src/asmjs/asm-wasm-builder.h" | 9 #include "src/asmjs/asm-wasm-builder.h" |
10 #include "src/assert-scope.h" | 10 #include "src/assert-scope.h" |
(...skipping 938 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
949 } | 949 } |
950 | 950 |
951 Handle<JSArrayBuffer> WasmJs::GetWasmMemoryArrayBuffer(Isolate* isolate, | 951 Handle<JSArrayBuffer> WasmJs::GetWasmMemoryArrayBuffer(Isolate* isolate, |
952 Handle<Object> value) { | 952 Handle<Object> value) { |
953 DCHECK(IsWasmMemoryObject(isolate, value)); | 953 DCHECK(IsWasmMemoryObject(isolate, value)); |
954 Handle<Object> buf( | 954 Handle<Object> buf( |
955 JSObject::cast(*value)->GetInternalField(kWasmMemoryBuffer), isolate); | 955 JSObject::cast(*value)->GetInternalField(kWasmMemoryBuffer), isolate); |
956 return Handle<JSArrayBuffer>::cast(buf); | 956 return Handle<JSArrayBuffer>::cast(buf); |
957 } | 957 } |
958 | 958 |
| 959 void WasmJs::SetWasmMemoryArrayBuffer(Isolate* isolate, Handle<Object> value, |
| 960 Handle<JSArrayBuffer> buffer) { |
| 961 DCHECK(IsWasmMemoryObject(isolate, value)); |
| 962 JSObject::cast(*value)->SetInternalField(kWasmMemoryBuffer, *buffer); |
| 963 } |
| 964 |
959 uint32_t WasmJs::GetWasmMemoryMaximumSize(Isolate* isolate, | 965 uint32_t WasmJs::GetWasmMemoryMaximumSize(Isolate* isolate, |
960 Handle<Object> value) { | 966 Handle<Object> value) { |
961 DCHECK(IsWasmMemoryObject(isolate, value)); | 967 DCHECK(IsWasmMemoryObject(isolate, value)); |
962 Object* max_mem = | 968 Object* max_mem = |
963 JSObject::cast(*value)->GetInternalField(kWasmMemoryMaximum); | 969 JSObject::cast(*value)->GetInternalField(kWasmMemoryMaximum); |
964 if (max_mem->IsUndefined(isolate)) return wasm::WasmModule::kMaxMemPages; | 970 if (max_mem->IsUndefined(isolate)) return wasm::WasmModule::kMaxMemPages; |
965 uint32_t max_pages = Smi::cast(max_mem)->value(); | 971 uint32_t max_pages = Smi::cast(max_mem)->value(); |
966 return max_pages; | 972 return max_pages; |
967 } | 973 } |
968 | 974 |
969 void WasmJs::SetWasmMemoryInstance(Isolate* isolate, | 975 void WasmJs::SetWasmMemoryInstance(Isolate* isolate, |
970 Handle<Object> memory_object, | 976 Handle<Object> memory_object, |
971 Handle<JSObject> instance) { | 977 Handle<JSObject> instance) { |
972 if (!memory_object->IsUndefined(isolate)) { | 978 if (!memory_object->IsUndefined(isolate)) { |
973 DCHECK(IsWasmMemoryObject(isolate, memory_object)); | 979 DCHECK(IsWasmMemoryObject(isolate, memory_object)); |
974 // TODO(gdeepti): This should be a weak list of instance objects | 980 // TODO(gdeepti): This should be a weak list of instance objects |
975 // for instances that share memory. | 981 // for instances that share memory. |
976 JSObject::cast(*memory_object) | 982 JSObject::cast(*memory_object) |
977 ->SetInternalField(kWasmMemoryInstanceObject, *instance); | 983 ->SetInternalField(kWasmMemoryInstanceObject, *instance); |
978 } | 984 } |
979 } | 985 } |
980 } // namespace internal | 986 } // namespace internal |
981 } // namespace v8 | 987 } // namespace v8 |
OLD | NEW |