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

Unified Diff: src/api.cc

Issue 1095083002: Allow for accessing an ArrayBuffer contents without externalizing it (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: updates Created 5 years, 8 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/v8.h ('k') | test/cctest/test-typedarrays.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index 991b9eebb6c9e8fff4ce5c6981ec6d26df6a4d0b..b816ca26ee8bfc061d5dca1bb363e9cdcbb959bd 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -6376,14 +6376,19 @@ bool v8::ArrayBuffer::IsNeuterable() const {
v8::ArrayBuffer::Contents v8::ArrayBuffer::Externalize() {
- i::Handle<i::JSArrayBuffer> obj = Utils::OpenHandle(this);
- Utils::ApiCheck(!obj->is_external(),
- "v8::ArrayBuffer::Externalize",
+ i::Handle<i::JSArrayBuffer> self = Utils::OpenHandle(this);
+ Utils::ApiCheck(!self->is_external(), "v8::ArrayBuffer::Externalize",
"ArrayBuffer already externalized");
- obj->set_is_external(true);
- size_t byte_length = static_cast<size_t>(obj->byte_length()->Number());
+ self->set_is_external(true);
+ return GetContents();
+}
+
+
+v8::ArrayBuffer::Contents v8::ArrayBuffer::GetContents() {
+ i::Handle<i::JSArrayBuffer> self = Utils::OpenHandle(this);
+ size_t byte_length = static_cast<size_t>(self->byte_length()->Number());
Contents contents;
- contents.data_ = obj->backing_store();
+ contents.data_ = self->backing_store();
contents.byte_length_ = byte_length;
return contents;
}
@@ -6421,13 +6426,16 @@ Local<ArrayBuffer> v8::ArrayBuffer::New(Isolate* isolate, size_t byte_length) {
Local<ArrayBuffer> v8::ArrayBuffer::New(Isolate* isolate, void* data,
- size_t byte_length) {
+ size_t byte_length,
+ ArrayBufferCreationMode mode) {
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
LOG_API(i_isolate, "v8::ArrayBuffer::New(void*, size_t)");
ENTER_V8(i_isolate);
i::Handle<i::JSArrayBuffer> obj =
i_isolate->factory()->NewJSArrayBuffer();
- i::Runtime::SetupArrayBuffer(i_isolate, obj, true, data, byte_length);
+ i::Runtime::SetupArrayBuffer(i_isolate, obj,
+ mode == ArrayBufferCreationMode::kExternalized,
+ data, byte_length);
return Utils::ToLocal(obj);
}
« no previous file with comments | « include/v8.h ('k') | test/cctest/test-typedarrays.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698