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

Side by Side Diff: src/api.cc

Issue 15855012: Change ArrayBuffer API and implementation to use embedder-provided allocator. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: CR feedback Created 7 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « include/v8.h ('k') | src/d8.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 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 5142 matching lines...) Expand 10 before | Expand all | Expand 10 after
5153 5153
5154 5154
5155 void v8::V8::SetJitCodeEventHandler( 5155 void v8::V8::SetJitCodeEventHandler(
5156 JitCodeEventOptions options, JitCodeEventHandler event_handler) { 5156 JitCodeEventOptions options, JitCodeEventHandler event_handler) {
5157 i::Isolate* isolate = i::Isolate::Current(); 5157 i::Isolate* isolate = i::Isolate::Current();
5158 // Ensure that logging is initialized for our isolate. 5158 // Ensure that logging is initialized for our isolate.
5159 isolate->InitializeLoggingAndCounters(); 5159 isolate->InitializeLoggingAndCounters();
5160 isolate->logger()->SetCodeEventHandler(options, event_handler); 5160 isolate->logger()->SetCodeEventHandler(options, event_handler);
5161 } 5161 }
5162 5162
5163 void v8::V8::SetArrayBufferAllocator(
5164 ArrayBuffer::Allocator* allocator) {
5165 if (!ApiCheck(i::V8::ArrayBufferAllocator() == NULL,
5166 "v8::V8::SetArrayBufferAllocator",
5167 "ArrayBufferAllocator might only be set once"))
5168 return;
5169 i::V8::SetArrayBufferAllocator(allocator);
5170 }
5171
5163 5172
5164 bool v8::V8::Dispose() { 5173 bool v8::V8::Dispose() {
5165 i::Isolate* isolate = i::Isolate::Current(); 5174 i::Isolate* isolate = i::Isolate::Current();
5166 if (!ApiCheck(isolate != NULL && isolate->IsDefaultIsolate(), 5175 if (!ApiCheck(isolate != NULL && isolate->IsDefaultIsolate(),
5167 "v8::V8::Dispose()", 5176 "v8::V8::Dispose()",
5168 "Use v8::Isolate::Dispose() for a non-default isolate.")) { 5177 "Use v8::Isolate::Dispose() for a non-default isolate.")) {
5169 return false; 5178 return false;
5170 } 5179 }
5171 i::V8::TearDown(); 5180 i::V8::TearDown();
5172 return true; 5181 return true;
(...skipping 949 matching lines...) Expand 10 before | Expand all | Expand 10 after
6122 has_pending_exception = result.is_null(); 6131 has_pending_exception = result.is_null();
6123 EXCEPTION_BAILOUT_CHECK(isolate, Local<Object>()); 6132 EXCEPTION_BAILOUT_CHECK(isolate, Local<Object>());
6124 return Utils::ToLocal(result); 6133 return Utils::ToLocal(result);
6125 } 6134 }
6126 6135
6127 6136
6128 bool v8::ArrayBuffer::IsExternal() const { 6137 bool v8::ArrayBuffer::IsExternal() const {
6129 return Utils::OpenHandle(this)->is_external(); 6138 return Utils::OpenHandle(this)->is_external();
6130 } 6139 }
6131 6140
6132 v8::ArrayBufferContents::~ArrayBufferContents() { 6141 v8::ArrayBuffer::Contents v8::ArrayBuffer::Externalize() {
6133 free(data_);
6134 data_ = NULL;
6135 byte_length_ = 0;
6136 }
6137
6138
6139 void v8::ArrayBuffer::Externalize(ArrayBufferContents* contents) {
6140 i::Handle<i::JSArrayBuffer> obj = Utils::OpenHandle(this); 6142 i::Handle<i::JSArrayBuffer> obj = Utils::OpenHandle(this);
6141 ApiCheck(!obj->is_external(), 6143 ApiCheck(!obj->is_external(),
6142 "v8::ArrayBuffer::Externalize", 6144 "v8::ArrayBuffer::Externalize",
6143 "ArrayBuffer already externalized"); 6145 "ArrayBuffer already externalized");
6144 obj->set_is_external(true); 6146 obj->set_is_external(true);
6145 size_t byte_length = static_cast<size_t>(obj->byte_length()->Number()); 6147 size_t byte_length = static_cast<size_t>(obj->byte_length()->Number());
6146 ApiCheck(contents->data_ == NULL, 6148 Contents contents;
6147 "v8::ArrayBuffer::Externalize", 6149 contents.data_ = obj->backing_store();
6148 "Externalizing into non-empty ArrayBufferContents"); 6150 contents.byte_length_ = byte_length;
6149 contents->data_ = obj->backing_store(); 6151 return contents;
6150 contents->byte_length_ = byte_length;
6151 } 6152 }
6152 6153
6153 6154
6154 void v8::ArrayBuffer::Neuter() { 6155 void v8::ArrayBuffer::Neuter() {
6155 i::Handle<i::JSArrayBuffer> obj = Utils::OpenHandle(this); 6156 i::Handle<i::JSArrayBuffer> obj = Utils::OpenHandle(this);
6156 i::Isolate* isolate = obj->GetIsolate(); 6157 i::Isolate* isolate = obj->GetIsolate();
6157 ApiCheck(obj->is_external(), 6158 ApiCheck(obj->is_external(),
6158 "v8::ArrayBuffer::Neuter", 6159 "v8::ArrayBuffer::Neuter",
6159 "Only externalized ArrayBuffers can be neutered"); 6160 "Only externalized ArrayBuffers can be neutered");
6160 LOG_API(obj->GetIsolate(), "v8::ArrayBuffer::Neuter()"); 6161 LOG_API(obj->GetIsolate(), "v8::ArrayBuffer::Neuter()");
(...skipping 1834 matching lines...) Expand 10 before | Expand all | Expand 10 after
7995 7996
7996 v->VisitPointers(blocks_.first(), first_block_limit_); 7997 v->VisitPointers(blocks_.first(), first_block_limit_);
7997 7998
7998 for (int i = 1; i < blocks_.length(); i++) { 7999 for (int i = 1; i < blocks_.length(); i++) {
7999 v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]); 8000 v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]);
8000 } 8001 }
8001 } 8002 }
8002 8003
8003 8004
8004 } } // namespace v8::internal 8005 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « include/v8.h ('k') | src/d8.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698