OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 5964 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5975 v8::ArrayBuffer::Contents v8::ArrayBuffer::Externalize() { | 5975 v8::ArrayBuffer::Contents v8::ArrayBuffer::Externalize() { |
5976 i::Handle<i::JSArrayBuffer> obj = Utils::OpenHandle(this); | 5976 i::Handle<i::JSArrayBuffer> obj = Utils::OpenHandle(this); |
5977 Utils::ApiCheck(!obj->is_external(), | 5977 Utils::ApiCheck(!obj->is_external(), |
5978 "v8::ArrayBuffer::Externalize", | 5978 "v8::ArrayBuffer::Externalize", |
5979 "ArrayBuffer already externalized"); | 5979 "ArrayBuffer already externalized"); |
5980 obj->set_is_external(true); | 5980 obj->set_is_external(true); |
5981 size_t byte_length = static_cast<size_t>(obj->byte_length()->Number()); | 5981 size_t byte_length = static_cast<size_t>(obj->byte_length()->Number()); |
5982 Contents contents; | 5982 Contents contents; |
5983 contents.data_ = obj->backing_store(); | 5983 contents.data_ = obj->backing_store(); |
5984 contents.byte_length_ = byte_length; | 5984 contents.byte_length_ = byte_length; |
| 5985 contents.shared_ = obj->is_shared(); |
5985 return contents; | 5986 return contents; |
5986 } | 5987 } |
5987 | 5988 |
5988 | 5989 |
5989 void v8::ArrayBuffer::Neuter() { | 5990 void v8::ArrayBuffer::Neuter() { |
5990 i::Handle<i::JSArrayBuffer> obj = Utils::OpenHandle(this); | 5991 i::Handle<i::JSArrayBuffer> obj = Utils::OpenHandle(this); |
5991 i::Isolate* isolate = obj->GetIsolate(); | 5992 i::Isolate* isolate = obj->GetIsolate(); |
5992 Utils::ApiCheck(obj->is_external(), | 5993 Utils::ApiCheck(obj->is_external(), |
5993 "v8::ArrayBuffer::Neuter", | 5994 "v8::ArrayBuffer::Neuter", |
5994 "Only externalized ArrayBuffers can be neutered"); | 5995 "Only externalized ArrayBuffers can be neutered"); |
(...skipping 15 matching lines...) Expand all Loading... |
6010 LOG_API(i_isolate, "v8::ArrayBuffer::New(size_t)"); | 6011 LOG_API(i_isolate, "v8::ArrayBuffer::New(size_t)"); |
6011 ENTER_V8(i_isolate); | 6012 ENTER_V8(i_isolate); |
6012 i::Handle<i::JSArrayBuffer> obj = | 6013 i::Handle<i::JSArrayBuffer> obj = |
6013 i_isolate->factory()->NewJSArrayBuffer(); | 6014 i_isolate->factory()->NewJSArrayBuffer(); |
6014 i::Runtime::SetupArrayBufferAllocatingData(i_isolate, obj, byte_length); | 6015 i::Runtime::SetupArrayBufferAllocatingData(i_isolate, obj, byte_length); |
6015 return Utils::ToLocal(obj); | 6016 return Utils::ToLocal(obj); |
6016 } | 6017 } |
6017 | 6018 |
6018 | 6019 |
6019 Local<ArrayBuffer> v8::ArrayBuffer::New(Isolate* isolate, void* data, | 6020 Local<ArrayBuffer> v8::ArrayBuffer::New(Isolate* isolate, void* data, |
6020 size_t byte_length) { | 6021 size_t byte_length, bool shared) { |
6021 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 6022 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
6022 EnsureInitializedForIsolate(i_isolate, "v8::ArrayBuffer::New(void*, size_t)"); | 6023 EnsureInitializedForIsolate(i_isolate, "v8::ArrayBuffer::New(void*, size_t)"); |
6023 LOG_API(i_isolate, "v8::ArrayBuffer::New(void*, size_t)"); | 6024 LOG_API(i_isolate, "v8::ArrayBuffer::New(void*, size_t)"); |
6024 ENTER_V8(i_isolate); | 6025 ENTER_V8(i_isolate); |
6025 i::Handle<i::JSArrayBuffer> obj = | 6026 i::Handle<i::JSArrayBuffer> obj = |
6026 i_isolate->factory()->NewJSArrayBuffer(); | 6027 i_isolate->factory()->NewJSArrayBuffer(); |
6027 i::Runtime::SetupArrayBuffer(i_isolate, obj, true, data, byte_length); | 6028 i::Runtime::SetupArrayBuffer(i_isolate, obj, true, data, byte_length, shared); |
6028 return Utils::ToLocal(obj); | 6029 return Utils::ToLocal(obj); |
6029 } | 6030 } |
6030 | 6031 |
6031 | 6032 |
6032 Local<ArrayBuffer> v8::ArrayBufferView::Buffer() { | 6033 Local<ArrayBuffer> v8::ArrayBufferView::Buffer() { |
6033 i::Handle<i::JSArrayBufferView> obj = Utils::OpenHandle(this); | 6034 i::Handle<i::JSArrayBufferView> obj = Utils::OpenHandle(this); |
6034 i::Handle<i::JSArrayBuffer> buffer; | 6035 i::Handle<i::JSArrayBuffer> buffer; |
6035 if (obj->IsJSDataView()) { | 6036 if (obj->IsJSDataView()) { |
6036 i::Handle<i::JSDataView> data_view(i::JSDataView::cast(*obj)); | 6037 i::Handle<i::JSDataView> data_view(i::JSDataView::cast(*obj)); |
6037 ASSERT(data_view->buffer()->IsJSArrayBuffer()); | 6038 ASSERT(data_view->buffer()->IsJSArrayBuffer()); |
(...skipping 1653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7691 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 7692 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
7692 Address callback_address = | 7693 Address callback_address = |
7693 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 7694 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
7694 VMState<EXTERNAL> state(isolate); | 7695 VMState<EXTERNAL> state(isolate); |
7695 ExternalCallbackScope call_scope(isolate, callback_address); | 7696 ExternalCallbackScope call_scope(isolate, callback_address); |
7696 callback(info); | 7697 callback(info); |
7697 } | 7698 } |
7698 | 7699 |
7699 | 7700 |
7700 } } // namespace v8::internal | 7701 } } // namespace v8::internal |
OLD | NEW |