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

Unified Diff: src/factory.cc

Issue 22426003: Handlify factory methods for typed array, ArrayBuffer and DataView. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/factory.cc
diff --git a/src/factory.cc b/src/factory.cc
index c5a1fddb88b413c843f7ca051a421026b035537c..5a3b48feff43957d0a5f7cb214926fd6f15eb0c4 100644
--- a/src/factory.cc
+++ b/src/factory.cc
@@ -1097,73 +1097,70 @@ void Factory::EnsureCanContainElements(Handle<JSArray> array,
Handle<JSArrayBuffer> Factory::NewJSArrayBuffer() {
- JSFunction* array_buffer_fun =
- isolate()->context()->native_context()->array_buffer_fun();
+ Handle<JSFunction> array_buffer_fun(
+ isolate()->context()->native_context()->array_buffer_fun());
CALL_HEAP_FUNCTION(
isolate(),
- isolate()->heap()->AllocateJSObject(array_buffer_fun),
+ isolate()->heap()->AllocateJSObject(*array_buffer_fun),
JSArrayBuffer);
}
Handle<JSDataView> Factory::NewJSDataView() {
- JSFunction* data_view_fun =
- isolate()->context()->native_context()->data_view_fun();
+ Handle<JSFunction> data_view_fun(
+ isolate()->context()->native_context()->data_view_fun());
CALL_HEAP_FUNCTION(
isolate(),
- isolate()->heap()->AllocateJSObject(data_view_fun),
+ isolate()->heap()->AllocateJSObject(*data_view_fun),
JSDataView);
}
-Handle<JSTypedArray> Factory::NewJSTypedArray(ExternalArrayType type) {
- JSFunction* typed_array_fun;
- Context* native_context = isolate()->context()->native_context();
+static JSFunction* GetTypedArrayFun(ExternalArrayType type,
+ Context* native_context) {
switch (type) {
case kExternalUnsignedByteArray:
- typed_array_fun = native_context->uint8_array_fun();
- break;
+ return native_context->uint8_array_fun();
case kExternalByteArray:
- typed_array_fun = native_context->int8_array_fun();
- break;
+ return native_context->int8_array_fun();
case kExternalUnsignedShortArray:
- typed_array_fun = native_context->uint16_array_fun();
- break;
+ return native_context->uint16_array_fun();
case kExternalShortArray:
- typed_array_fun = native_context->int16_array_fun();
- break;
+ return native_context->int16_array_fun();
case kExternalUnsignedIntArray:
- typed_array_fun = native_context->uint32_array_fun();
- break;
+ return native_context->uint32_array_fun();
case kExternalIntArray:
- typed_array_fun = native_context->int32_array_fun();
- break;
+ return native_context->int32_array_fun();
case kExternalFloatArray:
- typed_array_fun = native_context->float_array_fun();
- break;
+ return native_context->float_array_fun();
case kExternalDoubleArray:
- typed_array_fun = native_context->double_array_fun();
- break;
+ return native_context->double_array_fun();
case kExternalPixelArray:
- typed_array_fun = native_context->uint8c_array_fun();
- break;
+ return native_context->uint8c_array_fun();
default:
UNREACHABLE();
- return Handle<JSTypedArray>();
+ return NULL;
}
+}
+
+
+Handle<JSTypedArray> Factory::NewJSTypedArray(ExternalArrayType type) {
+ Context* native_context = isolate()->context()->native_context();
+ Handle<JSFunction> typed_array_fun_handle(
+ GetTypedArrayFun(type, native_context));
Michael Starzinger 2013/08/06 18:05:46 nit: Instead of passing "Context*" into GetTypedAr
Dmitry Lomov (no reviews) 2013/08/06 19:15:09 Done, great idea - thanks!
CALL_HEAP_FUNCTION(
isolate(),
- isolate()->heap()->AllocateJSObject(typed_array_fun),
+ isolate()->heap()->AllocateJSObject(*typed_array_fun_handle),
JSTypedArray);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698