Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(215)

Side by Side Diff: src/api.cc

Issue 684103002: allow disabling of ArrayBuffer neutering (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « include/v8.h ('k') | src/objects.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 6020 matching lines...) Expand 10 before | Expand all | Expand 10 after
6031 i::Handle<i::Symbol> key = isolate->factory()->promise_has_handler_symbol(); 6031 i::Handle<i::Symbol> key = isolate->factory()->promise_has_handler_symbol();
6032 return i::JSObject::GetDataProperty(promise, key)->IsTrue(); 6032 return i::JSObject::GetDataProperty(promise, key)->IsTrue();
6033 } 6033 }
6034 6034
6035 6035
6036 bool v8::ArrayBuffer::IsExternal() const { 6036 bool v8::ArrayBuffer::IsExternal() const {
6037 return Utils::OpenHandle(this)->is_external(); 6037 return Utils::OpenHandle(this)->is_external();
6038 } 6038 }
6039 6039
6040 6040
6041 bool v8::ArrayBuffer::IsNeuterable() const {
6042 return Utils::OpenHandle(this)->is_neuterable();
6043 }
6044
6045
6041 v8::ArrayBuffer::Contents v8::ArrayBuffer::Externalize() { 6046 v8::ArrayBuffer::Contents v8::ArrayBuffer::Externalize() {
6042 i::Handle<i::JSArrayBuffer> obj = Utils::OpenHandle(this); 6047 i::Handle<i::JSArrayBuffer> obj = Utils::OpenHandle(this);
6043 Utils::ApiCheck(!obj->is_external(), 6048 Utils::ApiCheck(!obj->is_external(),
6044 "v8::ArrayBuffer::Externalize", 6049 "v8::ArrayBuffer::Externalize",
6045 "ArrayBuffer already externalized"); 6050 "ArrayBuffer already externalized");
6046 obj->set_is_external(true); 6051 obj->set_is_external(true);
6047 size_t byte_length = static_cast<size_t>(obj->byte_length()->Number()); 6052 size_t byte_length = static_cast<size_t>(obj->byte_length()->Number());
6048 Contents contents; 6053 Contents contents;
6049 contents.data_ = obj->backing_store(); 6054 contents.data_ = obj->backing_store();
6050 contents.byte_length_ = byte_length; 6055 contents.byte_length_ = byte_length;
6051 return contents; 6056 return contents;
6052 } 6057 }
6053 6058
6054 6059
6055 void v8::ArrayBuffer::Neuter() { 6060 void v8::ArrayBuffer::Neuter() {
6056 i::Handle<i::JSArrayBuffer> obj = Utils::OpenHandle(this); 6061 i::Handle<i::JSArrayBuffer> obj = Utils::OpenHandle(this);
6057 i::Isolate* isolate = obj->GetIsolate(); 6062 i::Isolate* isolate = obj->GetIsolate();
6058 Utils::ApiCheck(obj->is_external(), 6063 Utils::ApiCheck(obj->is_external(),
6059 "v8::ArrayBuffer::Neuter", 6064 "v8::ArrayBuffer::Neuter",
6060 "Only externalized ArrayBuffers can be neutered"); 6065 "Only externalized ArrayBuffers can be neutered");
6066 Utils::ApiCheck(obj->is_neuterable(), "v8::ArrayBuffer::Neuter",
6067 "Only neuterable ArrayBuffers can be neutered");
6061 LOG_API(obj->GetIsolate(), "v8::ArrayBuffer::Neuter()"); 6068 LOG_API(obj->GetIsolate(), "v8::ArrayBuffer::Neuter()");
6062 ENTER_V8(isolate); 6069 ENTER_V8(isolate);
6063 i::Runtime::NeuterArrayBuffer(obj); 6070 i::Runtime::NeuterArrayBuffer(obj);
6064 } 6071 }
6065 6072
6066 6073
6067 size_t v8::ArrayBuffer::ByteLength() const { 6074 size_t v8::ArrayBuffer::ByteLength() const {
6068 i::Handle<i::JSArrayBuffer> obj = Utils::OpenHandle(this); 6075 i::Handle<i::JSArrayBuffer> obj = Utils::OpenHandle(this);
6069 return static_cast<size_t>(obj->byte_length()->Number()); 6076 return static_cast<size_t>(obj->byte_length()->Number());
6070 } 6077 }
(...skipping 1660 matching lines...) Expand 10 before | Expand all | Expand 10 after
7731 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 7738 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
7732 Address callback_address = 7739 Address callback_address =
7733 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 7740 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
7734 VMState<EXTERNAL> state(isolate); 7741 VMState<EXTERNAL> state(isolate);
7735 ExternalCallbackScope call_scope(isolate, callback_address); 7742 ExternalCallbackScope call_scope(isolate, callback_address);
7736 callback(info); 7743 callback(info);
7737 } 7744 }
7738 7745
7739 7746
7740 } } // namespace v8::internal 7747 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « include/v8.h ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698