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

Side by Side Diff: src/api.cc

Issue 17153011: DataView implementation. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fixes 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/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 6164 matching lines...) Expand 10 before | Expand all | Expand 10 after
6175 6175
6176 void v8::ArrayBuffer::Neuter() { 6176 void v8::ArrayBuffer::Neuter() {
6177 i::Handle<i::JSArrayBuffer> obj = Utils::OpenHandle(this); 6177 i::Handle<i::JSArrayBuffer> obj = Utils::OpenHandle(this);
6178 i::Isolate* isolate = obj->GetIsolate(); 6178 i::Isolate* isolate = obj->GetIsolate();
6179 ApiCheck(obj->is_external(), 6179 ApiCheck(obj->is_external(),
6180 "v8::ArrayBuffer::Neuter", 6180 "v8::ArrayBuffer::Neuter",
6181 "Only externalized ArrayBuffers can be neutered"); 6181 "Only externalized ArrayBuffers can be neutered");
6182 LOG_API(obj->GetIsolate(), "v8::ArrayBuffer::Neuter()"); 6182 LOG_API(obj->GetIsolate(), "v8::ArrayBuffer::Neuter()");
6183 ENTER_V8(isolate); 6183 ENTER_V8(isolate);
6184 6184
6185 for (i::Handle<i::Object> array_obj(obj->weak_first_array(), isolate); 6185 for (i::Handle<i::Object> view_obj(obj->weak_first_view(), isolate);
6186 !array_obj->IsUndefined();) { 6186 !view_obj->IsUndefined();) {
6187 i::Handle<i::JSTypedArray> typed_array(i::JSTypedArray::cast(*array_obj)); 6187 i::Handle<i::JSArrayBufferView> view(i::JSArrayBufferView::cast(*view_obj));
6188 typed_array->Neuter(); 6188 if (view->IsJSTypedArray()) {
6189 array_obj = i::handle(typed_array->weak_next(), isolate); 6189 i::JSTypedArray::cast(*view)->Neuter();
6190 } else if (view->IsJSDataView()) {
6191 i::JSDataView::cast(*view)->Neuter();
6192 } else {
6193 UNREACHABLE();
6194 }
6195 view_obj = i::handle(view->weak_next(), isolate);
6190 } 6196 }
6191 obj->Neuter(); 6197 obj->Neuter();
6192 } 6198 }
6193 6199
6194 6200
6195 size_t v8::ArrayBuffer::ByteLength() const { 6201 size_t v8::ArrayBuffer::ByteLength() const {
6196 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 6202 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
6197 if (IsDeadCheck(isolate, "v8::ArrayBuffer::ByteLength()")) return 0; 6203 if (IsDeadCheck(isolate, "v8::ArrayBuffer::ByteLength()")) return 0;
6198 i::Handle<i::JSArrayBuffer> obj = Utils::OpenHandle(this); 6204 i::Handle<i::JSArrayBuffer> obj = Utils::OpenHandle(this);
6199 return static_cast<size_t>(obj->byte_length()->Number()); 6205 return static_cast<size_t>(obj->byte_length()->Number());
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
6279 i::Handle<i::JSTypedArray> obj = 6285 i::Handle<i::JSTypedArray> obj =
6280 isolate->factory()->NewJSTypedArray(array_type); 6286 isolate->factory()->NewJSTypedArray(array_type);
6281 i::Handle<i::JSArrayBuffer> buffer = Utils::OpenHandle(*array_buffer); 6287 i::Handle<i::JSArrayBuffer> buffer = Utils::OpenHandle(*array_buffer);
6282 6288
6283 ASSERT(byte_offset % sizeof(ElementType) == 0); 6289 ASSERT(byte_offset % sizeof(ElementType) == 0);
6284 ASSERT(byte_offset + length * sizeof(ElementType) <= 6290 ASSERT(byte_offset + length * sizeof(ElementType) <=
6285 static_cast<size_t>(buffer->byte_length()->Number())); 6291 static_cast<size_t>(buffer->byte_length()->Number()));
6286 6292
6287 obj->set_buffer(*buffer); 6293 obj->set_buffer(*buffer);
6288 6294
6289 obj->set_weak_next(buffer->weak_first_array()); 6295 obj->set_weak_next(buffer->weak_first_view());
6290 buffer->set_weak_first_array(*obj); 6296 buffer->set_weak_first_view(*obj);
6291 6297
6292 i::Handle<i::Object> byte_offset_object = isolate->factory()->NewNumber( 6298 i::Handle<i::Object> byte_offset_object = isolate->factory()->NewNumber(
6293 static_cast<double>(byte_offset)); 6299 static_cast<double>(byte_offset));
6294 obj->set_byte_offset(*byte_offset_object); 6300 obj->set_byte_offset(*byte_offset_object);
6295 6301
6296 i::Handle<i::Object> byte_length_object = isolate->factory()->NewNumber( 6302 i::Handle<i::Object> byte_length_object = isolate->factory()->NewNumber(
6297 static_cast<double>(length * sizeof(ElementType))); 6303 static_cast<double>(length * sizeof(ElementType)));
6298 obj->set_byte_length(*byte_length_object); 6304 obj->set_byte_length(*byte_length_object);
6299 6305
6300 i::Handle<i::Object> length_object = isolate->factory()->NewNumber( 6306 i::Handle<i::Object> length_object = isolate->factory()->NewNumber(
(...skipping 1770 matching lines...) Expand 10 before | Expand all | Expand 10 after
8071 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 8077 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
8072 Address callback_address = 8078 Address callback_address =
8073 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 8079 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
8074 VMState<EXTERNAL> state(isolate); 8080 VMState<EXTERNAL> state(isolate);
8075 ExternalCallbackScope call_scope(isolate, callback_address); 8081 ExternalCallbackScope call_scope(isolate, callback_address);
8076 return callback(info); 8082 return callback(info);
8077 } 8083 }
8078 8084
8079 8085
8080 } } // namespace v8::internal 8086 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « include/v8.h ('k') | src/bootstrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698