Revision: 17121
Author:   [email protected]
Date:     Thu Oct 10 08:36:44 2013 UTC
Log:      Implement ArrayBuffer.isView.

[email protected]

Review URL: https://codereview.chromium.org/25700010
http://code.google.com/p/v8/source/detail?r=17121

Modified:
 /branches/bleeding_edge/src/arraybuffer.js
 /branches/bleeding_edge/src/runtime.cc
 /branches/bleeding_edge/src/runtime.h
 /branches/bleeding_edge/test/mjsunit/harmony/typedarrays.js

=======================================
--- /branches/bleeding_edge/src/arraybuffer.js  Thu Jun 27 07:42:08 2013 UTC
+++ /branches/bleeding_edge/src/arraybuffer.js  Thu Oct 10 08:36:44 2013 UTC
@@ -80,6 +80,10 @@
   %ArrayBufferSliceImpl(this, result, first);
   return result;
 }
+
+function ArrayBufferIsView(obj) {
+  return %ArrayBufferIsView(obj);
+}

 function SetUpArrayBuffer() {
   %CheckIsBootstrapping();
@@ -93,6 +97,10 @@

InstallGetter($ArrayBuffer.prototype, "byteLength", ArrayBufferGetByteLength);

+  InstallFunctions($ArrayBuffer, DONT_ENUM, $Array(
+      "isView", ArrayBufferIsView
+  ));
+
   InstallFunctions($ArrayBuffer.prototype, DONT_ENUM, $Array(
       "slice", ArrayBufferSlice
   ));
=======================================
--- /branches/bleeding_edge/src/runtime.cc      Thu Oct  3 07:42:44 2013 UTC
+++ /branches/bleeding_edge/src/runtime.cc      Thu Oct 10 08:36:44 2013 UTC
@@ -799,6 +799,16 @@
   CopyBytes(target_data, source_data + start, target_length);
   return isolate->heap()->undefined_value();
 }
+
+
+RUNTIME_FUNCTION(MaybeObject*, Runtime_ArrayBufferIsView) {
+  HandleScope scope(isolate);
+  ASSERT(args.length() == 1);
+  CONVERT_ARG_CHECKED(Object, object, 0);
+  return object->IsJSArrayBufferView()
+    ? isolate->heap()->true_value()
+    : isolate->heap()->false_value();
+}


 enum TypedArrayId {
=======================================
--- /branches/bleeding_edge/src/runtime.h       Tue Sep 24 15:27:49 2013 UTC
+++ /branches/bleeding_edge/src/runtime.h       Thu Oct 10 08:36:44 2013 UTC
@@ -362,6 +362,7 @@
   F(ArrayBufferInitialize, 2, 1)\
   F(ArrayBufferGetByteLength, 1, 1)\
   F(ArrayBufferSliceImpl, 3, 1) \
+  F(ArrayBufferIsView, 1, 1) \
   \
   F(TypedArrayInitialize, 5, 1) \
   F(TypedArrayInitializeFromArrayLike, 4, 1) \
=======================================
--- /branches/bleeding_edge/test/mjsunit/harmony/typedarrays.js Wed Jul 17 11:16:07 2013 UTC +++ /branches/bleeding_edge/test/mjsunit/harmony/typedarrays.js Thu Oct 10 08:36:44 2013 UTC
@@ -123,6 +123,7 @@
   var ab = new ArrayBuffer(256*elementSize);

   var a0 = new constr(30);
+  assertTrue(ArrayBuffer.isView(a0));
   assertSame(elementSize, a0.BYTES_PER_ELEMENT);
   assertSame(30, a0.length);
   assertSame(30*elementSize, a0.byteLength);
@@ -476,6 +477,7 @@
   var ab = new ArrayBuffer(256);

   var d1 = new DataView(ab, 1, 255);
+  assertTrue(ArrayBuffer.isView(d1));
   assertSame(ab, d1.buffer);
   assertSame(1, d1.byteOffset);
   assertSame(255, d1.byteLength);

--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to