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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 1079 matching lines...) Expand 10 before | Expand all | Expand 10 after
1090 Handle<FixedArrayBase> elements, 1090 Handle<FixedArrayBase> elements,
1091 uint32_t length, 1091 uint32_t length,
1092 EnsureElementsMode mode) { 1092 EnsureElementsMode mode) {
1093 CALL_HEAP_FUNCTION_VOID( 1093 CALL_HEAP_FUNCTION_VOID(
1094 isolate(), 1094 isolate(),
1095 array->EnsureCanContainElements(*elements, length, mode)); 1095 array->EnsureCanContainElements(*elements, length, mode));
1096 } 1096 }
1097 1097
1098 1098
1099 Handle<JSArrayBuffer> Factory::NewJSArrayBuffer() { 1099 Handle<JSArrayBuffer> Factory::NewJSArrayBuffer() {
1100 JSFunction* array_buffer_fun = 1100 Handle<JSFunction> array_buffer_fun(
1101 isolate()->context()->native_context()->array_buffer_fun(); 1101 isolate()->context()->native_context()->array_buffer_fun());
1102 CALL_HEAP_FUNCTION( 1102 CALL_HEAP_FUNCTION(
1103 isolate(), 1103 isolate(),
1104 isolate()->heap()->AllocateJSObject(array_buffer_fun), 1104 isolate()->heap()->AllocateJSObject(*array_buffer_fun),
1105 JSArrayBuffer); 1105 JSArrayBuffer);
1106 } 1106 }
1107 1107
1108 1108
1109 Handle<JSDataView> Factory::NewJSDataView() { 1109 Handle<JSDataView> Factory::NewJSDataView() {
1110 JSFunction* data_view_fun = 1110 Handle<JSFunction> data_view_fun(
1111 isolate()->context()->native_context()->data_view_fun(); 1111 isolate()->context()->native_context()->data_view_fun());
1112 CALL_HEAP_FUNCTION( 1112 CALL_HEAP_FUNCTION(
1113 isolate(), 1113 isolate(),
1114 isolate()->heap()->AllocateJSObject(data_view_fun), 1114 isolate()->heap()->AllocateJSObject(*data_view_fun),
1115 JSDataView); 1115 JSDataView);
1116 } 1116 }
1117 1117
1118 1118
1119 Handle<JSTypedArray> Factory::NewJSTypedArray(ExternalArrayType type) { 1119 static JSFunction* GetTypedArrayFun(ExternalArrayType type,
1120 JSFunction* typed_array_fun; 1120 Context* native_context) {
1121 Context* native_context = isolate()->context()->native_context();
1122 switch (type) { 1121 switch (type) {
1123 case kExternalUnsignedByteArray: 1122 case kExternalUnsignedByteArray:
1124 typed_array_fun = native_context->uint8_array_fun(); 1123 return native_context->uint8_array_fun();
1125 break;
1126 1124
1127 case kExternalByteArray: 1125 case kExternalByteArray:
1128 typed_array_fun = native_context->int8_array_fun(); 1126 return native_context->int8_array_fun();
1129 break;
1130 1127
1131 case kExternalUnsignedShortArray: 1128 case kExternalUnsignedShortArray:
1132 typed_array_fun = native_context->uint16_array_fun(); 1129 return native_context->uint16_array_fun();
1133 break;
1134 1130
1135 case kExternalShortArray: 1131 case kExternalShortArray:
1136 typed_array_fun = native_context->int16_array_fun(); 1132 return native_context->int16_array_fun();
1137 break;
1138 1133
1139 case kExternalUnsignedIntArray: 1134 case kExternalUnsignedIntArray:
1140 typed_array_fun = native_context->uint32_array_fun(); 1135 return native_context->uint32_array_fun();
1141 break;
1142 1136
1143 case kExternalIntArray: 1137 case kExternalIntArray:
1144 typed_array_fun = native_context->int32_array_fun(); 1138 return native_context->int32_array_fun();
1145 break;
1146 1139
1147 case kExternalFloatArray: 1140 case kExternalFloatArray:
1148 typed_array_fun = native_context->float_array_fun(); 1141 return native_context->float_array_fun();
1149 break;
1150 1142
1151 case kExternalDoubleArray: 1143 case kExternalDoubleArray:
1152 typed_array_fun = native_context->double_array_fun(); 1144 return native_context->double_array_fun();
1153 break;
1154 1145
1155 case kExternalPixelArray: 1146 case kExternalPixelArray:
1156 typed_array_fun = native_context->uint8c_array_fun(); 1147 return native_context->uint8c_array_fun();
1157 break;
1158 1148
1159 default: 1149 default:
1160 UNREACHABLE(); 1150 UNREACHABLE();
1161 return Handle<JSTypedArray>(); 1151 return NULL;
1162 } 1152 }
1153 }
1154
1155
1156 Handle<JSTypedArray> Factory::NewJSTypedArray(ExternalArrayType type) {
1157 Context* native_context = isolate()->context()->native_context();
1158 Handle<JSFunction> typed_array_fun_handle(
1159 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!
1163 1160
1164 CALL_HEAP_FUNCTION( 1161 CALL_HEAP_FUNCTION(
1165 isolate(), 1162 isolate(),
1166 isolate()->heap()->AllocateJSObject(typed_array_fun), 1163 isolate()->heap()->AllocateJSObject(*typed_array_fun_handle),
1167 JSTypedArray); 1164 JSTypedArray);
1168 } 1165 }
1169 1166
1170 1167
1171 Handle<JSProxy> Factory::NewJSProxy(Handle<Object> handler, 1168 Handle<JSProxy> Factory::NewJSProxy(Handle<Object> handler,
1172 Handle<Object> prototype) { 1169 Handle<Object> prototype) {
1173 CALL_HEAP_FUNCTION( 1170 CALL_HEAP_FUNCTION(
1174 isolate(), 1171 isolate(),
1175 isolate()->heap()->AllocateJSProxy(*handler, *prototype), 1172 isolate()->heap()->AllocateJSProxy(*handler, *prototype),
1176 JSProxy); 1173 JSProxy);
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
1609 return Handle<Object>::null(); 1606 return Handle<Object>::null();
1610 } 1607 }
1611 1608
1612 1609
1613 Handle<Object> Factory::ToBoolean(bool value) { 1610 Handle<Object> Factory::ToBoolean(bool value) {
1614 return value ? true_value() : false_value(); 1611 return value ? true_value() : false_value();
1615 } 1612 }
1616 1613
1617 1614
1618 } } // namespace v8::internal 1615 } } // namespace v8::internal
OLDNEW
« 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