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 6542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6553 return Utils::OpenHandle(this)->is_neuterable(); | 6553 return Utils::OpenHandle(this)->is_neuterable(); |
6554 } | 6554 } |
6555 | 6555 |
6556 | 6556 |
6557 v8::ArrayBuffer::Contents v8::ArrayBuffer::Externalize() { | 6557 v8::ArrayBuffer::Contents v8::ArrayBuffer::Externalize() { |
6558 i::Handle<i::JSArrayBuffer> self = Utils::OpenHandle(this); | 6558 i::Handle<i::JSArrayBuffer> self = Utils::OpenHandle(this); |
6559 i::Isolate* isolate = self->GetIsolate(); | 6559 i::Isolate* isolate = self->GetIsolate(); |
6560 Utils::ApiCheck(!self->is_external(), "v8::ArrayBuffer::Externalize", | 6560 Utils::ApiCheck(!self->is_external(), "v8::ArrayBuffer::Externalize", |
6561 "ArrayBuffer already externalized"); | 6561 "ArrayBuffer already externalized"); |
6562 self->set_is_external(true); | 6562 self->set_is_external(true); |
6563 isolate->heap()->UnregisterArrayBuffer(self->backing_store()); | 6563 isolate->heap()->UnregisterArrayBuffer(isolate->heap()->InNewSpace(*self), |
| 6564 self->backing_store()); |
6564 | 6565 |
6565 return GetContents(); | 6566 return GetContents(); |
6566 } | 6567 } |
6567 | 6568 |
6568 | 6569 |
6569 v8::ArrayBuffer::Contents v8::ArrayBuffer::GetContents() { | 6570 v8::ArrayBuffer::Contents v8::ArrayBuffer::GetContents() { |
6570 i::Handle<i::JSArrayBuffer> self = Utils::OpenHandle(this); | 6571 i::Handle<i::JSArrayBuffer> self = Utils::OpenHandle(this); |
6571 size_t byte_length = static_cast<size_t>(self->byte_length()->Number()); | 6572 size_t byte_length = static_cast<size_t>(self->byte_length()->Number()); |
6572 Contents contents; | 6573 Contents contents; |
6573 contents.data_ = self->backing_store(); | 6574 contents.data_ = self->backing_store(); |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6760 return Utils::OpenHandle(this)->is_external(); | 6761 return Utils::OpenHandle(this)->is_external(); |
6761 } | 6762 } |
6762 | 6763 |
6763 | 6764 |
6764 v8::SharedArrayBuffer::Contents v8::SharedArrayBuffer::Externalize() { | 6765 v8::SharedArrayBuffer::Contents v8::SharedArrayBuffer::Externalize() { |
6765 i::Handle<i::JSArrayBuffer> self = Utils::OpenHandle(this); | 6766 i::Handle<i::JSArrayBuffer> self = Utils::OpenHandle(this); |
6766 i::Isolate* isolate = self->GetIsolate(); | 6767 i::Isolate* isolate = self->GetIsolate(); |
6767 Utils::ApiCheck(!self->is_external(), "v8::SharedArrayBuffer::Externalize", | 6768 Utils::ApiCheck(!self->is_external(), "v8::SharedArrayBuffer::Externalize", |
6768 "SharedArrayBuffer already externalized"); | 6769 "SharedArrayBuffer already externalized"); |
6769 self->set_is_external(true); | 6770 self->set_is_external(true); |
6770 isolate->heap()->UnregisterArrayBuffer(self->backing_store()); | 6771 isolate->heap()->UnregisterArrayBuffer(isolate->heap()->InNewSpace(*self), |
| 6772 self->backing_store()); |
6771 return GetContents(); | 6773 return GetContents(); |
6772 } | 6774 } |
6773 | 6775 |
6774 | 6776 |
6775 v8::SharedArrayBuffer::Contents v8::SharedArrayBuffer::GetContents() { | 6777 v8::SharedArrayBuffer::Contents v8::SharedArrayBuffer::GetContents() { |
6776 i::Handle<i::JSArrayBuffer> self = Utils::OpenHandle(this); | 6778 i::Handle<i::JSArrayBuffer> self = Utils::OpenHandle(this); |
6777 size_t byte_length = static_cast<size_t>(self->byte_length()->Number()); | 6779 size_t byte_length = static_cast<size_t>(self->byte_length()->Number()); |
6778 Contents contents; | 6780 Contents contents; |
6779 contents.data_ = self->backing_store(); | 6781 contents.data_ = self->backing_store(); |
6780 contents.byte_length_ = byte_length; | 6782 contents.byte_length_ = byte_length; |
(...skipping 1667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8448 Address callback_address = | 8450 Address callback_address = |
8449 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8451 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
8450 VMState<EXTERNAL> state(isolate); | 8452 VMState<EXTERNAL> state(isolate); |
8451 ExternalCallbackScope call_scope(isolate, callback_address); | 8453 ExternalCallbackScope call_scope(isolate, callback_address); |
8452 callback(info); | 8454 callback(info); |
8453 } | 8455 } |
8454 | 8456 |
8455 | 8457 |
8456 } // namespace internal | 8458 } // namespace internal |
8457 } // namespace v8 | 8459 } // namespace v8 |
OLD | NEW |