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

Side by Side Diff: src/api.cc

Issue 150813004: In-heap small typed arrays (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Patch for landing Created 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/accessors.cc ('k') | src/bootstrapper.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 6000 matching lines...) Expand 10 before | Expand all | Expand 10 after
6011 ENTER_V8(i_isolate); 6011 ENTER_V8(i_isolate);
6012 i::Handle<i::JSArrayBuffer> obj = 6012 i::Handle<i::JSArrayBuffer> obj =
6013 i_isolate->factory()->NewJSArrayBuffer(); 6013 i_isolate->factory()->NewJSArrayBuffer();
6014 i::Runtime::SetupArrayBuffer(i_isolate, obj, true, data, byte_length); 6014 i::Runtime::SetupArrayBuffer(i_isolate, obj, true, data, byte_length);
6015 return Utils::ToLocal(obj); 6015 return Utils::ToLocal(obj);
6016 } 6016 }
6017 6017
6018 6018
6019 Local<ArrayBuffer> v8::ArrayBufferView::Buffer() { 6019 Local<ArrayBuffer> v8::ArrayBufferView::Buffer() {
6020 i::Handle<i::JSArrayBufferView> obj = Utils::OpenHandle(this); 6020 i::Handle<i::JSArrayBufferView> obj = Utils::OpenHandle(this);
6021 ASSERT(obj->buffer()->IsJSArrayBuffer()); 6021 i::Handle<i::JSArrayBuffer> buffer;
6022 i::Handle<i::JSArrayBuffer> buffer(i::JSArrayBuffer::cast(obj->buffer())); 6022 if (obj->IsJSDataView()) {
6023 i::Handle<i::JSDataView> data_view(i::JSDataView::cast(*obj));
6024 ASSERT(data_view->buffer()->IsJSArrayBuffer());
6025 buffer = i::handle(i::JSArrayBuffer::cast(data_view->buffer()));
6026 } else {
6027 ASSERT(obj->IsJSTypedArray());
6028 buffer = i::JSTypedArray::cast(*obj)->GetBuffer();
6029 }
6023 return Utils::ToLocal(buffer); 6030 return Utils::ToLocal(buffer);
6024 } 6031 }
6025 6032
6026 6033
6027 size_t v8::ArrayBufferView::ByteOffset() { 6034 size_t v8::ArrayBufferView::ByteOffset() {
6028 i::Handle<i::JSArrayBufferView> obj = Utils::OpenHandle(this); 6035 i::Handle<i::JSArrayBufferView> obj = Utils::OpenHandle(this);
6029 return static_cast<size_t>(obj->byte_offset()->Number()); 6036 return static_cast<size_t>(obj->byte_offset()->Number());
6030 } 6037 }
6031 6038
6032 6039
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
6083 isolate, obj, buffer, byte_offset, byte_length); 6090 isolate, obj, buffer, byte_offset, byte_length);
6084 6091
6085 i::Handle<i::Object> length_object = 6092 i::Handle<i::Object> length_object =
6086 isolate->factory()->NewNumberFromSize(length); 6093 isolate->factory()->NewNumberFromSize(length);
6087 obj->set_length(*length_object); 6094 obj->set_length(*length_object);
6088 6095
6089 i::Handle<i::ExternalArray> elements = 6096 i::Handle<i::ExternalArray> elements =
6090 isolate->factory()->NewExternalArray( 6097 isolate->factory()->NewExternalArray(
6091 static_cast<int>(length), array_type, 6098 static_cast<int>(length), array_type,
6092 static_cast<uint8_t*>(buffer->backing_store()) + byte_offset); 6099 static_cast<uint8_t*>(buffer->backing_store()) + byte_offset);
6093 obj->set_elements(*elements); 6100 i::Handle<i::Map> map =
6101 i::JSObject::GetElementsTransitionMap(obj, elements_kind);
6102 obj->set_map_and_elements(*map, *elements);
6094 return obj; 6103 return obj;
6095 } 6104 }
6096 6105
6097 6106
6098 #define TYPED_ARRAY_NEW(Type, type, TYPE, ctype, size) \ 6107 #define TYPED_ARRAY_NEW(Type, type, TYPE, ctype, size) \
6099 Local<Type##Array> Type##Array::New(Handle<ArrayBuffer> array_buffer, \ 6108 Local<Type##Array> Type##Array::New(Handle<ArrayBuffer> array_buffer, \
6100 size_t byte_offset, size_t length) { \ 6109 size_t byte_offset, size_t length) { \
6101 i::Isolate* isolate = i::Isolate::Current(); \ 6110 i::Isolate* isolate = i::Isolate::Current(); \
6102 EnsureInitializedForIsolate(isolate, \ 6111 EnsureInitializedForIsolate(isolate, \
6103 "v8::" #Type "Array::New(Handle<ArrayBuffer>, size_t, size_t)"); \ 6112 "v8::" #Type "Array::New(Handle<ArrayBuffer>, size_t, size_t)"); \
(...skipping 1531 matching lines...) Expand 10 before | Expand all | Expand 10 after
7635 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 7644 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
7636 Address callback_address = 7645 Address callback_address =
7637 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 7646 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
7638 VMState<EXTERNAL> state(isolate); 7647 VMState<EXTERNAL> state(isolate);
7639 ExternalCallbackScope call_scope(isolate, callback_address); 7648 ExternalCallbackScope call_scope(isolate, callback_address);
7640 callback(info); 7649 callback(info);
7641 } 7650 }
7642 7651
7643 7652
7644 } } // namespace v8::internal 7653 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/accessors.cc ('k') | src/bootstrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698