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

Side by Side Diff: src/api.cc

Issue 2657463004: Merged: Squashed multiple commits. (Closed)
Patch Set: Created 3 years, 11 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 | « no previous file | src/value-serializer.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 7554 matching lines...) Expand 10 before | Expand all | Expand 10 after
7565 return static_cast<size_t>(obj->byte_length()->Number()); 7565 return static_cast<size_t>(obj->byte_length()->Number());
7566 } 7566 }
7567 7567
7568 7568
7569 Local<ArrayBuffer> v8::ArrayBuffer::New(Isolate* isolate, size_t byte_length) { 7569 Local<ArrayBuffer> v8::ArrayBuffer::New(Isolate* isolate, size_t byte_length) {
7570 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 7570 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
7571 LOG_API(i_isolate, ArrayBuffer, New); 7571 LOG_API(i_isolate, ArrayBuffer, New);
7572 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate); 7572 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate);
7573 i::Handle<i::JSArrayBuffer> obj = 7573 i::Handle<i::JSArrayBuffer> obj =
7574 i_isolate->factory()->NewJSArrayBuffer(i::SharedFlag::kNotShared); 7574 i_isolate->factory()->NewJSArrayBuffer(i::SharedFlag::kNotShared);
7575 i::JSArrayBuffer::SetupAllocatingData(obj, i_isolate, byte_length); 7575 // TODO(jbroman): It may be useful in the future to provide a MaybeLocal
7576 // version that throws an exception or otherwise does not crash.
7577 if (!i::JSArrayBuffer::SetupAllocatingData(obj, i_isolate, byte_length)) {
7578 i::FatalProcessOutOfMemory("v8::ArrayBuffer::New");
7579 }
7576 return Utils::ToLocal(obj); 7580 return Utils::ToLocal(obj);
7577 } 7581 }
7578 7582
7579 7583
7580 Local<ArrayBuffer> v8::ArrayBuffer::New(Isolate* isolate, void* data, 7584 Local<ArrayBuffer> v8::ArrayBuffer::New(Isolate* isolate, void* data,
7581 size_t byte_length, 7585 size_t byte_length,
7582 ArrayBufferCreationMode mode) { 7586 ArrayBufferCreationMode mode) {
7583 // Embedders must guarantee that the external backing store is valid. 7587 // Embedders must guarantee that the external backing store is valid.
7584 CHECK(byte_length == 0 || data != NULL); 7588 CHECK(byte_length == 0 || data != NULL);
7585 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 7589 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
7755 7759
7756 7760
7757 Local<SharedArrayBuffer> v8::SharedArrayBuffer::New(Isolate* isolate, 7761 Local<SharedArrayBuffer> v8::SharedArrayBuffer::New(Isolate* isolate,
7758 size_t byte_length) { 7762 size_t byte_length) {
7759 CHECK(i::FLAG_harmony_sharedarraybuffer); 7763 CHECK(i::FLAG_harmony_sharedarraybuffer);
7760 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 7764 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
7761 LOG_API(i_isolate, SharedArrayBuffer, New); 7765 LOG_API(i_isolate, SharedArrayBuffer, New);
7762 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate); 7766 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate);
7763 i::Handle<i::JSArrayBuffer> obj = 7767 i::Handle<i::JSArrayBuffer> obj =
7764 i_isolate->factory()->NewJSArrayBuffer(i::SharedFlag::kShared); 7768 i_isolate->factory()->NewJSArrayBuffer(i::SharedFlag::kShared);
7765 i::JSArrayBuffer::SetupAllocatingData(obj, i_isolate, byte_length, true, 7769 // TODO(jbroman): It may be useful in the future to provide a MaybeLocal
7766 i::SharedFlag::kShared); 7770 // version that throws an exception or otherwise does not crash.
7771 if (!i::JSArrayBuffer::SetupAllocatingData(obj, i_isolate, byte_length, true,
7772 i::SharedFlag::kShared)) {
7773 i::FatalProcessOutOfMemory("v8::SharedArrayBuffer::New");
7774 }
7767 return Utils::ToLocalShared(obj); 7775 return Utils::ToLocalShared(obj);
7768 } 7776 }
7769 7777
7770 7778
7771 Local<SharedArrayBuffer> v8::SharedArrayBuffer::New( 7779 Local<SharedArrayBuffer> v8::SharedArrayBuffer::New(
7772 Isolate* isolate, void* data, size_t byte_length, 7780 Isolate* isolate, void* data, size_t byte_length,
7773 ArrayBufferCreationMode mode) { 7781 ArrayBufferCreationMode mode) {
7774 CHECK(i::FLAG_harmony_sharedarraybuffer); 7782 CHECK(i::FLAG_harmony_sharedarraybuffer);
7775 // Embedders must guarantee that the external backing store is valid. 7783 // Embedders must guarantee that the external backing store is valid.
7776 CHECK(byte_length == 0 || data != NULL); 7784 CHECK(byte_length == 0 || data != NULL);
(...skipping 2262 matching lines...) Expand 10 before | Expand all | Expand 10 after
10039 Address callback_address = 10047 Address callback_address =
10040 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 10048 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
10041 VMState<EXTERNAL> state(isolate); 10049 VMState<EXTERNAL> state(isolate);
10042 ExternalCallbackScope call_scope(isolate, callback_address); 10050 ExternalCallbackScope call_scope(isolate, callback_address);
10043 callback(info); 10051 callback(info);
10044 } 10052 }
10045 10053
10046 10054
10047 } // namespace internal 10055 } // namespace internal
10048 } // namespace v8 10056 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/value-serializer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698