OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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.h" | 5 #include "src/api.h" |
6 | 6 |
7 #include <string.h> // For memcpy, strlen. | 7 #include <string.h> // For memcpy, strlen. |
8 #ifdef V8_USE_ADDRESS_SANITIZER | 8 #ifdef V8_USE_ADDRESS_SANITIZER |
9 #include <sanitizer/asan_interface.h> | 9 #include <sanitizer/asan_interface.h> |
10 #endif // V8_USE_ADDRESS_SANITIZER | 10 #endif // V8_USE_ADDRESS_SANITIZER |
(...skipping 6219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6230 } | 6230 } |
6231 | 6231 |
6232 | 6232 |
6233 bool v8::ArrayBuffer::IsNeuterable() const { | 6233 bool v8::ArrayBuffer::IsNeuterable() const { |
6234 return Utils::OpenHandle(this)->is_neuterable(); | 6234 return Utils::OpenHandle(this)->is_neuterable(); |
6235 } | 6235 } |
6236 | 6236 |
6237 | 6237 |
6238 v8::ArrayBuffer::Contents v8::ArrayBuffer::Externalize() { | 6238 v8::ArrayBuffer::Contents v8::ArrayBuffer::Externalize() { |
6239 i::Handle<i::JSArrayBuffer> self = Utils::OpenHandle(this); | 6239 i::Handle<i::JSArrayBuffer> self = Utils::OpenHandle(this); |
| 6240 i::Isolate* isolate = self->GetIsolate(); |
6240 Utils::ApiCheck(!self->is_external(), "v8::ArrayBuffer::Externalize", | 6241 Utils::ApiCheck(!self->is_external(), "v8::ArrayBuffer::Externalize", |
6241 "ArrayBuffer already externalized"); | 6242 "ArrayBuffer already externalized"); |
6242 self->set_is_external(true); | 6243 self->set_is_external(true); |
| 6244 isolate->heap()->UnregisterArrayBuffer(self->backing_store()); |
| 6245 |
6243 return GetContents(); | 6246 return GetContents(); |
6244 } | 6247 } |
6245 | 6248 |
6246 | 6249 |
6247 v8::ArrayBuffer::Contents v8::ArrayBuffer::GetContents() { | 6250 v8::ArrayBuffer::Contents v8::ArrayBuffer::GetContents() { |
6248 i::Handle<i::JSArrayBuffer> self = Utils::OpenHandle(this); | 6251 i::Handle<i::JSArrayBuffer> self = Utils::OpenHandle(this); |
6249 size_t byte_length = static_cast<size_t>(self->byte_length()->Number()); | 6252 size_t byte_length = static_cast<size_t>(self->byte_length()->Number()); |
6250 Contents contents; | 6253 Contents contents; |
6251 contents.data_ = self->backing_store(); | 6254 contents.data_ = self->backing_store(); |
6252 contents.byte_length_ = byte_length; | 6255 contents.byte_length_ = byte_length; |
(...skipping 1759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8012 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 8015 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
8013 Address callback_address = | 8016 Address callback_address = |
8014 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8017 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
8015 VMState<EXTERNAL> state(isolate); | 8018 VMState<EXTERNAL> state(isolate); |
8016 ExternalCallbackScope call_scope(isolate, callback_address); | 8019 ExternalCallbackScope call_scope(isolate, callback_address); |
8017 callback(info); | 8020 callback(info); |
8018 } | 8021 } |
8019 | 8022 |
8020 | 8023 |
8021 } } // namespace v8::internal | 8024 } } // namespace v8::internal |
OLD | NEW |