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

Side by Side Diff: src/api.cc

Issue 1111413006: Version 4.3.61.17 (cherry-pick) (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@4.3
Patch Set: Created 5 years, 7 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 unified diff | Download patch
« no previous file with comments | « include/v8-version.h ('k') | test/cctest/test-typedarrays.cc » ('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 6344 matching lines...) Expand 10 before | Expand all | Expand 10 after
6355 return Utils::OpenHandle(this)->is_external(); 6355 return Utils::OpenHandle(this)->is_external();
6356 } 6356 }
6357 6357
6358 6358
6359 bool v8::ArrayBuffer::IsNeuterable() const { 6359 bool v8::ArrayBuffer::IsNeuterable() const {
6360 return Utils::OpenHandle(this)->is_neuterable(); 6360 return Utils::OpenHandle(this)->is_neuterable();
6361 } 6361 }
6362 6362
6363 6363
6364 v8::ArrayBuffer::Contents v8::ArrayBuffer::Externalize() { 6364 v8::ArrayBuffer::Contents v8::ArrayBuffer::Externalize() {
6365 i::Handle<i::JSArrayBuffer> obj = Utils::OpenHandle(this); 6365 i::Handle<i::JSArrayBuffer> self = Utils::OpenHandle(this);
6366 Utils::ApiCheck(!obj->is_external(), 6366 Utils::ApiCheck(!self->is_external(), "v8::ArrayBuffer::Externalize",
6367 "v8::ArrayBuffer::Externalize",
6368 "ArrayBuffer already externalized"); 6367 "ArrayBuffer already externalized");
6369 obj->set_is_external(true); 6368 self->set_is_external(true);
6370 size_t byte_length = static_cast<size_t>(obj->byte_length()->Number()); 6369 return GetContents();
6370 }
6371
6372
6373 v8::ArrayBuffer::Contents v8::ArrayBuffer::GetContents() {
6374 i::Handle<i::JSArrayBuffer> self = Utils::OpenHandle(this);
6375 size_t byte_length = static_cast<size_t>(self->byte_length()->Number());
6371 Contents contents; 6376 Contents contents;
6372 contents.data_ = obj->backing_store(); 6377 contents.data_ = self->backing_store();
6373 contents.byte_length_ = byte_length; 6378 contents.byte_length_ = byte_length;
6374 return contents; 6379 return contents;
6375 } 6380 }
6376 6381
6377 6382
6378 void v8::ArrayBuffer::Neuter() { 6383 void v8::ArrayBuffer::Neuter() {
6379 i::Handle<i::JSArrayBuffer> obj = Utils::OpenHandle(this); 6384 i::Handle<i::JSArrayBuffer> obj = Utils::OpenHandle(this);
6380 i::Isolate* isolate = obj->GetIsolate(); 6385 i::Isolate* isolate = obj->GetIsolate();
6381 Utils::ApiCheck(obj->is_external(), 6386 Utils::ApiCheck(obj->is_external(),
6382 "v8::ArrayBuffer::Neuter", 6387 "v8::ArrayBuffer::Neuter",
(...skipping 17 matching lines...) Expand all
6400 LOG_API(i_isolate, "v8::ArrayBuffer::New(size_t)"); 6405 LOG_API(i_isolate, "v8::ArrayBuffer::New(size_t)");
6401 ENTER_V8(i_isolate); 6406 ENTER_V8(i_isolate);
6402 i::Handle<i::JSArrayBuffer> obj = 6407 i::Handle<i::JSArrayBuffer> obj =
6403 i_isolate->factory()->NewJSArrayBuffer(); 6408 i_isolate->factory()->NewJSArrayBuffer();
6404 i::Runtime::SetupArrayBufferAllocatingData(i_isolate, obj, byte_length); 6409 i::Runtime::SetupArrayBufferAllocatingData(i_isolate, obj, byte_length);
6405 return Utils::ToLocal(obj); 6410 return Utils::ToLocal(obj);
6406 } 6411 }
6407 6412
6408 6413
6409 Local<ArrayBuffer> v8::ArrayBuffer::New(Isolate* isolate, void* data, 6414 Local<ArrayBuffer> v8::ArrayBuffer::New(Isolate* isolate, void* data,
6410 size_t byte_length) { 6415 size_t byte_length,
6416 ArrayBufferCreationMode mode) {
6411 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 6417 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
6412 LOG_API(i_isolate, "v8::ArrayBuffer::New(void*, size_t)"); 6418 LOG_API(i_isolate, "v8::ArrayBuffer::New(void*, size_t)");
6413 ENTER_V8(i_isolate); 6419 ENTER_V8(i_isolate);
6414 i::Handle<i::JSArrayBuffer> obj = 6420 i::Handle<i::JSArrayBuffer> obj =
6415 i_isolate->factory()->NewJSArrayBuffer(); 6421 i_isolate->factory()->NewJSArrayBuffer();
6416 i::Runtime::SetupArrayBuffer(i_isolate, obj, true, data, byte_length); 6422 i::Runtime::SetupArrayBuffer(i_isolate, obj,
6423 mode == ArrayBufferCreationMode::kExternalized,
6424 data, byte_length);
6417 return Utils::ToLocal(obj); 6425 return Utils::ToLocal(obj);
6418 } 6426 }
6419 6427
6420 6428
6421 Local<ArrayBuffer> v8::ArrayBufferView::Buffer() { 6429 Local<ArrayBuffer> v8::ArrayBufferView::Buffer() {
6422 i::Handle<i::JSArrayBufferView> obj = Utils::OpenHandle(this); 6430 i::Handle<i::JSArrayBufferView> obj = Utils::OpenHandle(this);
6423 i::Handle<i::JSArrayBuffer> buffer; 6431 i::Handle<i::JSArrayBuffer> buffer;
6424 if (obj->IsJSDataView()) { 6432 if (obj->IsJSDataView()) {
6425 i::Handle<i::JSDataView> data_view(i::JSDataView::cast(*obj)); 6433 i::Handle<i::JSDataView> data_view(i::JSDataView::cast(*obj));
6426 DCHECK(data_view->buffer()->IsJSArrayBuffer()); 6434 DCHECK(data_view->buffer()->IsJSArrayBuffer());
(...skipping 1677 matching lines...) Expand 10 before | Expand all | Expand 10 after
8104 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 8112 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
8105 Address callback_address = 8113 Address callback_address =
8106 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 8114 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
8107 VMState<EXTERNAL> state(isolate); 8115 VMState<EXTERNAL> state(isolate);
8108 ExternalCallbackScope call_scope(isolate, callback_address); 8116 ExternalCallbackScope call_scope(isolate, callback_address);
8109 callback(info); 8117 callback(info);
8110 } 8118 }
8111 8119
8112 8120
8113 } } // namespace v8::internal 8121 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « include/v8-version.h ('k') | test/cctest/test-typedarrays.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698