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

Side by Side Diff: src/api.cc

Issue 241843002: Version 3.24.35.33 (merged r20525) (Closed) Base URL: https://v8.googlecode.com/svn/branches/3.24
Patch Set: 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 | « no previous file | src/version.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 5884 matching lines...) Expand 10 before | Expand all | Expand 10 after
5895 i::Handle<i::JSTypedArray> NewTypedArray( 5895 i::Handle<i::JSTypedArray> NewTypedArray(
5896 i::Isolate* isolate, 5896 i::Isolate* isolate,
5897 Handle<ArrayBuffer> array_buffer, size_t byte_offset, size_t length) { 5897 Handle<ArrayBuffer> array_buffer, size_t byte_offset, size_t length) {
5898 i::Handle<i::JSTypedArray> obj = 5898 i::Handle<i::JSTypedArray> obj =
5899 isolate->factory()->NewJSTypedArray(array_type); 5899 isolate->factory()->NewJSTypedArray(array_type);
5900 i::Handle<i::JSArrayBuffer> buffer = Utils::OpenHandle(*array_buffer); 5900 i::Handle<i::JSArrayBuffer> buffer = Utils::OpenHandle(*array_buffer);
5901 5901
5902 ASSERT(byte_offset % sizeof(ElementType) == 0); 5902 ASSERT(byte_offset % sizeof(ElementType) == 0);
5903 5903
5904 CHECK(length <= (std::numeric_limits<size_t>::max() / sizeof(ElementType))); 5904 CHECK(length <= (std::numeric_limits<size_t>::max() / sizeof(ElementType)));
5905 CHECK(length <= static_cast<size_t>(i::Smi::kMaxValue));
5905 size_t byte_length = length * sizeof(ElementType); 5906 size_t byte_length = length * sizeof(ElementType);
5906 SetupArrayBufferView( 5907 SetupArrayBufferView(
5907 isolate, obj, buffer, byte_offset, byte_length); 5908 isolate, obj, buffer, byte_offset, byte_length);
5908 5909
5909 i::Handle<i::Object> length_object = 5910 i::Handle<i::Object> length_object =
5910 isolate->factory()->NewNumberFromSize(length); 5911 isolate->factory()->NewNumberFromSize(length);
5911 obj->set_length(*length_object); 5912 obj->set_length(*length_object);
5912 5913
5913 i::Handle<i::ExternalArray> elements = 5914 i::Handle<i::ExternalArray> elements =
5914 isolate->factory()->NewExternalArray( 5915 isolate->factory()->NewExternalArray(
5915 static_cast<int>(length), array_type, 5916 static_cast<int>(length), array_type,
5916 static_cast<uint8_t*>(buffer->backing_store()) + byte_offset); 5917 static_cast<uint8_t*>(buffer->backing_store()) + byte_offset);
5917 obj->set_elements(*elements); 5918 obj->set_elements(*elements);
5918 return obj; 5919 return obj;
5919 } 5920 }
5920 5921
5921 5922
5922 #define TYPED_ARRAY_NEW(Type, type, TYPE, ctype, size) \ 5923 #define TYPED_ARRAY_NEW(Type, type, TYPE, ctype, size) \
5923 Local<Type##Array> Type##Array::New(Handle<ArrayBuffer> array_buffer, \ 5924 Local<Type##Array> Type##Array::New(Handle<ArrayBuffer> array_buffer, \
5924 size_t byte_offset, size_t length) { \ 5925 size_t byte_offset, size_t length) { \
5925 i::Isolate* isolate = i::Isolate::Current(); \ 5926 i::Isolate* isolate = i::Isolate::Current(); \
5926 EnsureInitializedForIsolate(isolate, \ 5927 EnsureInitializedForIsolate(isolate, \
5927 "v8::" #Type "Array::New(Handle<ArrayBuffer>, size_t, size_t)"); \ 5928 "v8::" #Type "Array::New(Handle<ArrayBuffer>, size_t, size_t)"); \
5928 LOG_API(isolate, \ 5929 LOG_API(isolate, \
5929 "v8::" #Type "Array::New(Handle<ArrayBuffer>, size_t, size_t)"); \ 5930 "v8::" #Type "Array::New(Handle<ArrayBuffer>, size_t, size_t)"); \
5930 ENTER_V8(isolate); \ 5931 ENTER_V8(isolate); \
5932 if (!Utils::ApiCheck(length <= static_cast<size_t>(i::Smi::kMaxValue), \
5933 "v8::" #Type "Array::New(Handle<ArrayBuffer>, size_t, size_t)", \
5934 "length exceeds max allowed value")) { \
5935 return Local<Type##Array>(); \
5936 } \
5931 i::Handle<i::JSTypedArray> obj = \ 5937 i::Handle<i::JSTypedArray> obj = \
5932 NewTypedArray<ctype, v8::kExternal##Type##Array, \ 5938 NewTypedArray<ctype, v8::kExternal##Type##Array, \
5933 i::EXTERNAL_##TYPE##_ELEMENTS>( \ 5939 i::EXTERNAL_##TYPE##_ELEMENTS>( \
5934 isolate, array_buffer, byte_offset, length); \ 5940 isolate, array_buffer, byte_offset, length); \
5935 return Utils::ToLocal##Type##Array(obj); \ 5941 return Utils::ToLocal##Type##Array(obj); \
5936 } 5942 }
5937 5943
5938 5944
5939 TYPED_ARRAYS(TYPED_ARRAY_NEW) 5945 TYPED_ARRAYS(TYPED_ARRAY_NEW)
5940 #undef TYPED_ARRAY_NEW 5946 #undef TYPED_ARRAY_NEW
(...skipping 1397 matching lines...) Expand 10 before | Expand all | Expand 10 after
7338 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 7344 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
7339 Address callback_address = 7345 Address callback_address =
7340 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 7346 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
7341 VMState<EXTERNAL> state(isolate); 7347 VMState<EXTERNAL> state(isolate);
7342 ExternalCallbackScope call_scope(isolate, callback_address); 7348 ExternalCallbackScope call_scope(isolate, callback_address);
7343 callback(info); 7349 callback(info);
7344 } 7350 }
7345 7351
7346 7352
7347 } } // namespace v8::internal 7353 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/version.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698