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

Side by Side Diff: src/api.cc

Issue 1302803003: [api] Relax CHECK for ArrayBuffer API abuse (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add test Created 5 years, 4 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 | test/mjsunit/regress/regress-crbug-522496.js » ('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 6542 matching lines...) Expand 10 before | Expand all | Expand 10 after
6553 i_isolate->factory()->NewJSArrayBuffer(i::SharedFlag::kNotShared); 6553 i_isolate->factory()->NewJSArrayBuffer(i::SharedFlag::kNotShared);
6554 i::Runtime::SetupArrayBufferAllocatingData(i_isolate, obj, byte_length); 6554 i::Runtime::SetupArrayBufferAllocatingData(i_isolate, obj, byte_length);
6555 return Utils::ToLocal(obj); 6555 return Utils::ToLocal(obj);
6556 } 6556 }
6557 6557
6558 6558
6559 Local<ArrayBuffer> v8::ArrayBuffer::New(Isolate* isolate, void* data, 6559 Local<ArrayBuffer> v8::ArrayBuffer::New(Isolate* isolate, void* data,
6560 size_t byte_length, 6560 size_t byte_length,
6561 ArrayBufferCreationMode mode) { 6561 ArrayBufferCreationMode mode) {
6562 // Embedders must guarantee that the external backing store is valid. 6562 // Embedders must guarantee that the external backing store is valid.
6563 CHECK(data != NULL); 6563 CHECK(byte_length == 0 || data != NULL);
6564 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 6564 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
6565 LOG_API(i_isolate, "v8::ArrayBuffer::New(void*, size_t)"); 6565 LOG_API(i_isolate, "v8::ArrayBuffer::New(void*, size_t)");
6566 ENTER_V8(i_isolate); 6566 ENTER_V8(i_isolate);
6567 i::Handle<i::JSArrayBuffer> obj = 6567 i::Handle<i::JSArrayBuffer> obj =
6568 i_isolate->factory()->NewJSArrayBuffer(i::SharedFlag::kNotShared); 6568 i_isolate->factory()->NewJSArrayBuffer(i::SharedFlag::kNotShared);
6569 i::Runtime::SetupArrayBuffer(i_isolate, obj, 6569 i::Runtime::SetupArrayBuffer(i_isolate, obj,
6570 mode == ArrayBufferCreationMode::kExternalized, 6570 mode == ArrayBufferCreationMode::kExternalized,
6571 data, byte_length); 6571 data, byte_length);
6572 return Utils::ToLocal(obj); 6572 return Utils::ToLocal(obj);
6573 } 6573 }
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
6752 i::SharedFlag::kShared); 6752 i::SharedFlag::kShared);
6753 return Utils::ToLocalShared(obj); 6753 return Utils::ToLocalShared(obj);
6754 } 6754 }
6755 6755
6756 6756
6757 Local<SharedArrayBuffer> v8::SharedArrayBuffer::New( 6757 Local<SharedArrayBuffer> v8::SharedArrayBuffer::New(
6758 Isolate* isolate, void* data, size_t byte_length, 6758 Isolate* isolate, void* data, size_t byte_length,
6759 ArrayBufferCreationMode mode) { 6759 ArrayBufferCreationMode mode) {
6760 CHECK(i::FLAG_harmony_sharedarraybuffer); 6760 CHECK(i::FLAG_harmony_sharedarraybuffer);
6761 // Embedders must guarantee that the external backing store is valid. 6761 // Embedders must guarantee that the external backing store is valid.
6762 CHECK(data != NULL); 6762 CHECK(byte_length == 0 || data != NULL);
6763 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 6763 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
6764 LOG_API(i_isolate, "v8::SharedArrayBuffer::New(void*, size_t)"); 6764 LOG_API(i_isolate, "v8::SharedArrayBuffer::New(void*, size_t)");
6765 ENTER_V8(i_isolate); 6765 ENTER_V8(i_isolate);
6766 i::Handle<i::JSArrayBuffer> obj = 6766 i::Handle<i::JSArrayBuffer> obj =
6767 i_isolate->factory()->NewJSArrayBuffer(i::SharedFlag::kShared); 6767 i_isolate->factory()->NewJSArrayBuffer(i::SharedFlag::kShared);
6768 i::Runtime::SetupArrayBuffer(i_isolate, obj, 6768 i::Runtime::SetupArrayBuffer(i_isolate, obj,
6769 mode == ArrayBufferCreationMode::kExternalized, 6769 mode == ArrayBufferCreationMode::kExternalized,
6770 data, byte_length, i::SharedFlag::kShared); 6770 data, byte_length, i::SharedFlag::kShared);
6771 return Utils::ToLocalShared(obj); 6771 return Utils::ToLocalShared(obj);
6772 } 6772 }
(...skipping 1635 matching lines...) Expand 10 before | Expand all | Expand 10 after
8408 Address callback_address = 8408 Address callback_address =
8409 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 8409 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
8410 VMState<EXTERNAL> state(isolate); 8410 VMState<EXTERNAL> state(isolate);
8411 ExternalCallbackScope call_scope(isolate, callback_address); 8411 ExternalCallbackScope call_scope(isolate, callback_address);
8412 callback(info); 8412 callback(info);
8413 } 8413 }
8414 8414
8415 8415
8416 } // namespace internal 8416 } // namespace internal
8417 } // namespace v8 8417 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-crbug-522496.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698