Revision: 14560
Author:   [email protected]
Date:     Mon May  6 09:19:27 2013
Log:      Added an extra flag that enables only ArrayBuffer.

This makes Blink experimentation easier.

[email protected]

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

Added:
 /branches/bleeding_edge/src/arraybuffer.js
Modified:
 /branches/bleeding_edge/src/bootstrapper.cc
 /branches/bleeding_edge/src/flag-definitions.h
 /branches/bleeding_edge/src/typedarray.js
 /branches/bleeding_edge/test/cctest/test-api.cc
 /branches/bleeding_edge/tools/gyp/v8.gyp

=======================================
--- /dev/null
+++ /branches/bleeding_edge/src/arraybuffer.js  Mon May  6 09:19:27 2013
@@ -0,0 +1,100 @@
+// Copyright 2013 the V8 project authors. All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+//       notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+//       copyright notice, this list of conditions and the following
+//       disclaimer in the documentation and/or other materials provided
+//       with the distribution.
+//     * Neither the name of Google Inc. nor the names of its
+//       contributors may be used to endorse or promote products derived
+//       from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+"use strict";
+
+var $ArrayBuffer = global.ArrayBuffer;
+
+// -------------------------------------------------------------------
+
+function ArrayBufferConstructor(byteLength) { // length = 1
+  if (%_IsConstructCall()) {
+    var l = TO_POSITIVE_INTEGER(byteLength);
+    %ArrayBufferInitialize(this, l);
+  } else {
+    return new $ArrayBuffer(byteLength);
+  }
+}
+
+function ArrayBufferGetByteLength() {
+  if (!IS_ARRAYBUFFER(this)) {
+    throw MakeTypeError('incompatible_method_receiver',
+                        ['ArrayBuffer.prototype.byteLength', this]);
+  }
+  return %ArrayBufferGetByteLength(this);
+}
+
+// ES6 Draft 15.13.5.5.3
+function ArrayBufferSlice(start, end) {
+  if (!IS_ARRAYBUFFER(this)) {
+    throw MakeTypeError('incompatible_method_receiver',
+                        ['ArrayBuffer.prototype.slice', this]);
+  }
+
+  var relativeStart = TO_INTEGER(start);
+  var first;
+  if (relativeStart < 0) {
+    first = MathMax(this.byteLength + relativeStart, 0);
+  } else {
+    first = MathMin(relativeStart, this.byteLength);
+  }
+  var relativeEnd = IS_UNDEFINED(end) ? this.byteLength : TO_INTEGER(end);
+  var fin;
+  if (relativeEnd < 0) {
+    fin = MathMax(this.byteLength + relativeEnd, 0);
+  } else {
+    fin = MathMin(relativeEnd, this.byteLength);
+  }
+
+  var newLen = fin - first;
+  // TODO(dslomov): implement inheritance
+  var result = new $ArrayBuffer(newLen);
+
+  %ArrayBufferSliceImpl(this, result, first);
+  return result;
+}
+
+function SetUpArrayBuffer() {
+  %CheckIsBootstrapping();
+
+  // Set up the ArrayBuffer constructor function.
+  %SetCode($ArrayBuffer, ArrayBufferConstructor);
+  %FunctionSetPrototype($ArrayBuffer, new $Object());
+
+  // Set up the constructor property on the ArrayBuffer prototype object.
+ %SetProperty($ArrayBuffer.prototype, "constructor", $ArrayBuffer, DONT_ENUM);
+
+ InstallGetter($ArrayBuffer.prototype, "byteLength", ArrayBufferGetByteLength);
+
+  InstallFunctions($ArrayBuffer.prototype, DONT_ENUM, $Array(
+      "slice", ArrayBufferSlice
+  ));
+}
+
+SetUpArrayBuffer();
+
+
=======================================
--- /branches/bleeding_edge/src/bootstrapper.cc Thu May  2 04:36:48 2013
+++ /branches/bleeding_edge/src/bootstrapper.cc Mon May  6 09:19:27 2013
@@ -1316,37 +1316,37 @@
                       Builtins::kIllegal, true);
     }
   }
+
+  if (FLAG_harmony_array_buffer) {
+    // -- A r r a y B u f f e r
+    Handle<JSFunction> array_buffer_fun =
+        InstallFunction(global, "ArrayBuffer", JS_ARRAY_BUFFER_TYPE,
+                        JSArrayBuffer::kSize,
+                        isolate()->initial_object_prototype(),
+                        Builtins::kIllegal, true);
+    native_context()->set_array_buffer_fun(*array_buffer_fun);
+  }

   if (FLAG_harmony_typed_arrays) {
-    {  // -- A r r a y B u f f e r
-      Handle<JSFunction> array_buffer_fun =
-          InstallFunction(global, "ArrayBuffer", JS_ARRAY_BUFFER_TYPE,
-                          JSArrayBuffer::kSize,
-                          isolate()->initial_object_prototype(),
-                          Builtins::kIllegal, true);
-      native_context()->set_array_buffer_fun(*array_buffer_fun);
-    }
-    {
-      // -- T y p e d A r r a y s
-      Handle<JSFunction> int8_fun = InstallTypedArray("Int8Array");
-      native_context()->set_int8_array_fun(*int8_fun);
-      Handle<JSFunction> uint8_fun = InstallTypedArray("Uint8Array");
-      native_context()->set_uint8_array_fun(*uint8_fun);
-      Handle<JSFunction> int16_fun = InstallTypedArray("Int16Array");
-      native_context()->set_int16_array_fun(*int16_fun);
-      Handle<JSFunction> uint16_fun = InstallTypedArray("Uint16Array");
-      native_context()->set_uint16_array_fun(*uint16_fun);
-      Handle<JSFunction> int32_fun = InstallTypedArray("Int32Array");
-      native_context()->set_int32_array_fun(*int32_fun);
-      Handle<JSFunction> uint32_fun = InstallTypedArray("Uint32Array");
-      native_context()->set_uint32_array_fun(*uint32_fun);
-      Handle<JSFunction> float_fun = InstallTypedArray("Float32Array");
-      native_context()->set_float_array_fun(*float_fun);
-      Handle<JSFunction> double_fun = InstallTypedArray("Float64Array");
-      native_context()->set_double_array_fun(*double_fun);
- Handle<JSFunction> uint8c_fun = InstallTypedArray("Uint8ClampedArray");
-      native_context()->set_uint8c_array_fun(*uint8c_fun);
-     }
+    // -- T y p e d A r r a y s
+    Handle<JSFunction> int8_fun = InstallTypedArray("Int8Array");
+    native_context()->set_int8_array_fun(*int8_fun);
+    Handle<JSFunction> uint8_fun = InstallTypedArray("Uint8Array");
+    native_context()->set_uint8_array_fun(*uint8_fun);
+    Handle<JSFunction> int16_fun = InstallTypedArray("Int16Array");
+    native_context()->set_int16_array_fun(*int16_fun);
+    Handle<JSFunction> uint16_fun = InstallTypedArray("Uint16Array");
+    native_context()->set_uint16_array_fun(*uint16_fun);
+    Handle<JSFunction> int32_fun = InstallTypedArray("Int32Array");
+    native_context()->set_int32_array_fun(*int32_fun);
+    Handle<JSFunction> uint32_fun = InstallTypedArray("Uint32Array");
+    native_context()->set_uint32_array_fun(*uint32_fun);
+    Handle<JSFunction> float_fun = InstallTypedArray("Float32Array");
+    native_context()->set_float_array_fun(*float_fun);
+    Handle<JSFunction> double_fun = InstallTypedArray("Float64Array");
+    native_context()->set_double_array_fun(*double_fun);
+    Handle<JSFunction> uint8c_fun = InstallTypedArray("Uint8ClampedArray");
+    native_context()->set_uint8c_array_fun(*uint8c_fun);
   }

   if (FLAG_harmony_generators) {
@@ -1992,6 +1992,11 @@
                "native object-observe.js") == 0) {
       if (!CompileExperimentalBuiltin(isolate(), i)) return false;
     }
+    if (FLAG_harmony_array_buffer &&
+        strcmp(ExperimentalNatives::GetScriptName(i).start(),
+               "native arraybuffer.js") == 0) {
+      if (!CompileExperimentalBuiltin(isolate(), i)) return false;
+    }
     if (FLAG_harmony_typed_arrays &&
         strcmp(ExperimentalNatives::GetScriptName(i).start(),
                "native typedarray.js") == 0) {
=======================================
--- /branches/bleeding_edge/src/flag-definitions.h      Fri May  3 04:05:54 2013
+++ /branches/bleeding_edge/src/flag-definitions.h      Mon May  6 09:19:27 2013
@@ -166,6 +166,9 @@
"enable harmony object observation (implies harmony collections")
 DEFINE_bool(harmony_typed_arrays, false,
             "enable harmony typed arrays")
+DEFINE_bool(harmony_array_buffer, false,
+            "enable harmony array buffer")
+DEFINE_implication(harmony_typed_arrays, harmony_array_buffer)
 DEFINE_bool(harmony_generators, false, "enable harmony generators")
 DEFINE_bool(harmony, false, "enable all harmony features (except typeof)")
 DEFINE_implication(harmony, harmony_scoping)
=======================================
--- /branches/bleeding_edge/src/typedarray.js   Fri May  3 02:43:44 2013
+++ /branches/bleeding_edge/src/typedarray.js   Mon May  6 09:19:27 2013
@@ -31,56 +31,7 @@
 // in runtime.js:
 // var $Array = global.Array;

-var $ArrayBuffer = global.ArrayBuffer;

-// -------------------------------------------------------------------
-
-function ArrayBufferConstructor(byteLength) { // length = 1
-  if (%_IsConstructCall()) {
-    var l = TO_POSITIVE_INTEGER(byteLength);
-    %ArrayBufferInitialize(this, l);
-  } else {
-    return new $ArrayBuffer(byteLength);
-  }
-}
-
-function ArrayBufferGetByteLength() {
-  if (!IS_ARRAYBUFFER(this)) {
-    throw MakeTypeError('incompatible_method_receiver',
-                        ['ArrayBuffer.prototype.byteLength', this]);
-  }
-  return %ArrayBufferGetByteLength(this);
-}
-
-// ES6 Draft 15.13.5.5.3
-function ArrayBufferSlice(start, end) {
-  if (!IS_ARRAYBUFFER(this)) {
-    throw MakeTypeError('incompatible_method_receiver',
-                        ['ArrayBuffer.prototype.slice', this]);
-  }
-
-  var relativeStart = TO_INTEGER(start);
-  var first;
-  if (relativeStart < 0) {
-    first = MathMax(this.byteLength + relativeStart, 0);
-  } else {
-    first = MathMin(relativeStart, this.byteLength);
-  }
-  var relativeEnd = IS_UNDEFINED(end) ? this.byteLength : TO_INTEGER(end);
-  var fin;
-  if (relativeEnd < 0) {
-    fin = MathMax(this.byteLength + relativeEnd, 0);
-  } else {
-    fin = MathMin(relativeEnd, this.byteLength);
-  }
-
-  var newLen = fin - first;
-  // TODO(dslomov): implement inheritance
-  var result = new $ArrayBuffer(newLen);
-
-  %ArrayBufferSliceImpl(this, result, first);
-  return result;
-}

 // --------------- Typed Arrays ---------------------

@@ -119,7 +70,7 @@
   function ConstructByLength(obj, length) {
     var l = IS_UNDEFINED(length) ? 0 : TO_POSITIVE_INTEGER(length);
     var byteLength = l * elementSize;
-    var buffer = new $ArrayBuffer(byteLength);
+    var buffer = new global.ArrayBuffer(byteLength);
     %TypedArrayInitialize(obj, arrayId, buffer, 0, byteLength);
   }

@@ -197,25 +148,6 @@

 // -------------------------------------------------------------------

-function SetUpArrayBuffer() {
-  %CheckIsBootstrapping();
-
-  // Set up the ArrayBuffer constructor function.
-  %SetCode($ArrayBuffer, ArrayBufferConstructor);
-  %FunctionSetPrototype($ArrayBuffer, new $Object());
-
-  // Set up the constructor property on the ArrayBuffer prototype object.
- %SetProperty($ArrayBuffer.prototype, "constructor", $ArrayBuffer, DONT_ENUM);
-
- InstallGetter($ArrayBuffer.prototype, "byteLength", ArrayBufferGetByteLength);
-
-  InstallFunctions($ArrayBuffer.prototype, DONT_ENUM, $Array(
-      "slice", ArrayBufferSlice
-  ));
-}
-
-SetUpArrayBuffer();
-
 function SetupTypedArray(arrayId, name, constructor, elementSize) {
   %CheckIsBootstrapping();
   var fun = CreateTypedArrayConstructor(name, elementSize,
=======================================
--- /branches/bleeding_edge/test/cctest/test-api.cc     Thu May  2 23:47:24 2013
+++ /branches/bleeding_edge/test/cctest/test-api.cc     Mon May  6 09:19:27 2013
@@ -2257,6 +2257,7 @@


 THREADED_TEST(ArrayBuffer) {
+  i::FLAG_harmony_array_buffer = true;
   i::FLAG_harmony_typed_arrays = true;

   LocalContext env;
@@ -15107,6 +15108,7 @@
 void TypedArrayTestHelper(v8::ExternalArrayType array_type,
                           int64_t low, int64_t high) {
   const int kElementCount = 50;
+  i::FLAG_harmony_array_buffer = true;
   i::FLAG_harmony_typed_arrays = true;

   LocalContext env;
@@ -15191,6 +15193,7 @@

 #define IS_TYPED_ARRAY_TEST(TypedArray) \
THREADED_TEST(Is##TypedArray) { \ + i::FLAG_harmony_array_buffer = true; \ i::FLAG_harmony_typed_arrays = true; \ LocalContext env; \ v8::Isolate* isolate = env->GetIsolate(); \
=======================================
--- /branches/bleeding_edge/tools/gyp/v8.gyp    Fri Apr 19 05:46:32 2013
+++ /branches/bleeding_edge/tools/gyp/v8.gyp    Mon May  6 09:19:27 2013
@@ -800,6 +800,7 @@
               '../../src/proxy.js',
               '../../src/collection.js',
               '../../src/object-observe.js',
+              '../../src/arraybuffer.js',
               '../../src/typedarray.js',
               '../../src/generator.js'
             ],

--
--
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