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

Unified Diff: src/factory.cc

Issue 14195034: First cut at API for native Typed Arrays. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Self-review Created 7 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 side-by-side diff with in-line comments
Download patch
Index: src/factory.cc
diff --git a/src/factory.cc b/src/factory.cc
index f36006c1140db9bae82216352f4df5215d35735a..8dfab1803f165169b020a9c975cfb117b9826619 100644
--- a/src/factory.cc
+++ b/src/factory.cc
@@ -1056,6 +1056,54 @@ Handle<JSArrayBuffer> Factory::NewJSArrayBuffer() {
}
+Handle<JSTypedArray> Factory::NewJSTypedArray(ExternalArrayType type) {
+ JSFunction* typed_array_fun;
+ Context* native_context = isolate()->context()->native_context();
+ switch (type) {
+ case kExternalUnsignedByteArray:
+ typed_array_fun = native_context->uint8_array_fun();
+ break;
+
+ case kExternalByteArray:
+ typed_array_fun = native_context->int8_array_fun();
+ break;
+
+ case kExternalUnsignedShortArray:
+ typed_array_fun = native_context->uint16_array_fun();
+ break;
+
+ case kExternalShortArray:
+ typed_array_fun = native_context->int16_array_fun();
+ break;
+
+ case kExternalUnsignedIntArray:
+ typed_array_fun = native_context->uint32_array_fun();
+ break;
+
+ case kExternalIntArray:
+ typed_array_fun = native_context->int32_array_fun();
+ break;
+
+ case kExternalFloatArray:
+ typed_array_fun = native_context->float_array_fun();
+ break;
+
+ case kExternalDoubleArray:
+ typed_array_fun = native_context->double_array_fun();
+ break;
+
+ default:
+ UNREACHABLE();
+ return Handle<JSTypedArray>();
+ }
+
+ CALL_HEAP_FUNCTION(
+ isolate(),
+ isolate()->heap()->AllocateJSObject(typed_array_fun),
+ JSTypedArray);
+}
+
+
Handle<JSProxy> Factory::NewJSProxy(Handle<Object> handler,
Handle<Object> prototype) {
CALL_HEAP_FUNCTION(

Powered by Google App Engine
This is Rietveld 408576698