Remove __ prefix from Harmony typed arrays implementation
authordslomov@chromium.org <dslomov@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Mon, 29 Apr 2013 11:18:27 +0000 (11:18 +0000)
committerdslomov@chromium.org <dslomov@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Mon, 29 Apr 2013 11:18:27 +0000 (11:18 +0000)
R=rossberg@chromium.org
BUG=

Review URL: https://codereview.chromium.org/14402026

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@14477 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/bootstrapper.cc
src/d8.cc
src/flag-definitions.h
src/macros.py
src/typedarray.js
test/cctest/test-api.cc
test/mjsunit/harmony/typedarrays.js

index 5d9e617..1edf5ce 100644 (file)
@@ -1320,7 +1320,7 @@ void Genesis::InitializeExperimentalGlobal() {
   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,
+          InstallFunction(global, "ArrayBuffer", JS_ARRAY_BUFFER_TYPE,
                           JSArrayBuffer::kSize,
                           isolate()->initial_object_prototype(),
                           Builtins::kIllegal, true);
@@ -1329,21 +1329,21 @@ void Genesis::InitializeExperimentalGlobal() {
     {
       // -- T y p e d A r r a y s
       native_context()->set_int8_array_fun(
-          *InstallTypedArray("__Int8Array"));
+          *InstallTypedArray("Int8Array"));
       native_context()->set_uint8_array_fun(
-          *InstallTypedArray("__Uint8Array"));
+          *InstallTypedArray("Uint8Array"));
       native_context()->set_int16_array_fun(
-          *InstallTypedArray("__Int16Array"));
+          *InstallTypedArray("Int16Array"));
       native_context()->set_uint16_array_fun(
-          *InstallTypedArray("__Uint16Array"));
+          *InstallTypedArray("Uint16Array"));
       native_context()->set_int32_array_fun(
-          *InstallTypedArray("__Int32Array"));
+          *InstallTypedArray("Int32Array"));
       native_context()->set_uint32_array_fun(
-          *InstallTypedArray("__Uint32Array"));
+          *InstallTypedArray("Uint32Array"));
       native_context()->set_float_array_fun(
-          *InstallTypedArray("__Float32Array"));
+          *InstallTypedArray("Float32Array"));
       native_context()->set_double_array_fun(
-          *InstallTypedArray("__Float64Array"));
+          *InstallTypedArray("Float64Array"));
     }
   }
 
index 22ace17..958f476 100644 (file)
--- a/src/d8.cc
+++ b/src/d8.cc
@@ -1459,28 +1459,30 @@ Handle<ObjectTemplate> Shell::CreateGlobalTemplate(Isolate* isolate) {
   global_template->Set(String::New("Realm"), realm_template);
 
   // Bind the handlers for external arrays.
-  PropertyAttribute attr =
-      static_cast<PropertyAttribute>(ReadOnly | DontDelete);
-  global_template->Set(PerIsolateData::ArrayBuffer_string(isolate),
-                       CreateArrayBufferTemplate(ArrayBuffer), attr);
-  global_template->Set(String::New("Int8Array"),
-                       CreateArrayTemplate(Int8Array), attr);
-  global_template->Set(String::New("Uint8Array"),
-                       CreateArrayTemplate(Uint8Array), attr);
-  global_template->Set(String::New("Int16Array"),
-                       CreateArrayTemplate(Int16Array), attr);
-  global_template->Set(String::New("Uint16Array"),
-                       CreateArrayTemplate(Uint16Array), attr);
-  global_template->Set(String::New("Int32Array"),
-                       CreateArrayTemplate(Int32Array), attr);
-  global_template->Set(String::New("Uint32Array"),
-                       CreateArrayTemplate(Uint32Array), attr);
-  global_template->Set(String::New("Float32Array"),
-                       CreateArrayTemplate(Float32Array), attr);
-  global_template->Set(String::New("Float64Array"),
-                       CreateArrayTemplate(Float64Array), attr);
-  global_template->Set(String::New("Uint8ClampedArray"),
-                       CreateArrayTemplate(Uint8ClampedArray), attr);
+  if (!i::FLAG_harmony_typed_arrays) {
+    PropertyAttribute attr =
+        static_cast<PropertyAttribute>(ReadOnly | DontDelete);
+    global_template->Set(PerIsolateData::ArrayBuffer_string(isolate),
+                         CreateArrayBufferTemplate(ArrayBuffer), attr);
+    global_template->Set(String::New("Int8Array"),
+                         CreateArrayTemplate(Int8Array), attr);
+    global_template->Set(String::New("Uint8Array"),
+                         CreateArrayTemplate(Uint8Array), attr);
+    global_template->Set(String::New("Int16Array"),
+                         CreateArrayTemplate(Int16Array), attr);
+    global_template->Set(String::New("Uint16Array"),
+                         CreateArrayTemplate(Uint16Array), attr);
+    global_template->Set(String::New("Int32Array"),
+                         CreateArrayTemplate(Int32Array), attr);
+    global_template->Set(String::New("Uint32Array"),
+                         CreateArrayTemplate(Uint32Array), attr);
+    global_template->Set(String::New("Float32Array"),
+                         CreateArrayTemplate(Float32Array), attr);
+    global_template->Set(String::New("Float64Array"),
+                         CreateArrayTemplate(Float64Array), attr);
+    global_template->Set(String::New("Uint8ClampedArray"),
+                         CreateArrayTemplate(Uint8ClampedArray), attr);
+  }
 
 #if !defined(V8_SHARED) && !defined(_WIN32) && !defined(_WIN64)
   Handle<ObjectTemplate> os_templ = ObjectTemplate::New();
index f0b617a..1e454ff 100644 (file)
@@ -177,7 +177,7 @@ DEFINE_implication(harmony, harmony_observation)
 DEFINE_implication(harmony, harmony_generators)
 DEFINE_implication(harmony_modules, harmony_scoping)
 DEFINE_implication(harmony_observation, harmony_collections)
-DEFINE_implication(harmony, harmony_typed_arrays)
+// TODO[dslomov] add harmony => harmony_typed_arrays
 
 // Flags for experimental implementation features.
 DEFINE_bool(packed_arrays, true, "optimizes arrays that have no holes")
index 0c52f38..643d6c7 100644 (file)
@@ -116,7 +116,7 @@ macro IS_ERROR(arg)             = (%_ClassOf(arg) === 'Error');
 macro IS_SCRIPT(arg)            = (%_ClassOf(arg) === 'Script');
 macro IS_ARGUMENTS(arg)         = (%_ClassOf(arg) === 'Arguments');
 macro IS_GLOBAL(arg)            = (%_ClassOf(arg) === 'global');
-macro IS_ARRAYBUFFER(arg)       = (%_ClassOf(arg) === '__ArrayBuffer');
+macro IS_ARRAYBUFFER(arg)       = (%_ClassOf(arg) === 'ArrayBuffer');
 macro IS_GENERATOR(arg)         = (%_ClassOf(arg) === 'Generator');
 macro IS_UNDETECTABLE(arg)      = (%_IsUndetectableObject(arg));
 macro FLOOR(arg)                = $floor(arg);
index 24fcf1e..7549652 100644 (file)
@@ -31,7 +31,7 @@
 // in runtime.js:
 // var $Array = global.Array;
 
-var $ArrayBuffer = global.__ArrayBuffer;
+var $ArrayBuffer = global.ArrayBuffer;
 
 // -------------------------------------------------------------------
 
@@ -181,12 +181,12 @@ function SetupTypedArray(arrayId, name, constructor, elementSize) {
 }
 
 // arrayIds below should be synchronized with Runtime_TypedArrayInitialize.
-SetupTypedArray(1, "Uint8Array", global.__Uint8Array, 1);
-SetupTypedArray(2, "Int8Array", global.__Int8Array, 1);
-SetupTypedArray(3, "Uint16Array", global.__Uint16Array, 2);
-SetupTypedArray(4, "Int16Array", global.__Int16Array, 2);
-SetupTypedArray(5, "Uint32Array", global.__Uint32Array, 4);
-SetupTypedArray(6, "Int32Array", global.__Int32Array, 4);
-SetupTypedArray(7, "Float32Array", global.__Float32Array, 4);
-SetupTypedArray(8, "Float64Array", global.__Float64Array, 8);
+SetupTypedArray(1, "Uint8Array", global.Uint8Array, 1);
+SetupTypedArray(2, "Int8Array", global.Int8Array, 1);
+SetupTypedArray(3, "Uint16Array", global.Uint16Array, 2);
+SetupTypedArray(4, "Int16Array", global.Int16Array, 2);
+SetupTypedArray(5, "Uint32Array", global.Uint32Array, 4);
+SetupTypedArray(6, "Int32Array", global.Int32Array, 4);
+SetupTypedArray(7, "Float32Array", global.Float32Array, 4);
+SetupTypedArray(8, "Float64Array", global.Float64Array, 8);
 
index abe0ffe..d0b986b 100644 (file)
@@ -2271,7 +2271,7 @@ THREADED_TEST(ArrayBuffer) {
   v8::Handle<v8::Value> result = CompileRun("ab.byteLength");
   CHECK_EQ(1024, result->Int32Value());
 
-  result = CompileRun("var u8 = new __Uint8Array(ab);"
+  result = CompileRun("var u8 = new Uint8Array(ab);"
                       "u8[0] = 0xFF;"
                       "u8[1] = 0xAA;"
                       "u8.length");
@@ -2283,8 +2283,8 @@ THREADED_TEST(ArrayBuffer) {
   result = CompileRun("u8[0] + u8[1]");
   CHECK_EQ(0xDD, result->Int32Value());
 
-  result = CompileRun("var ab1 = new __ArrayBuffer(2);"
-                      "var u8_a = new __Uint8Array(ab1);"
+  result = CompileRun("var ab1 = new ArrayBuffer(2);"
+                      "var u8_a = new Uint8Array(ab1);"
                       "u8_a[0] = 0xAA;"
                       "u8_a[1] = 0xFF; u8_a.buffer");
   Local<v8::ArrayBuffer> ab1 = v8::ArrayBuffer::Cast(*result);
@@ -2303,7 +2303,7 @@ THREADED_TEST(ArrayBuffer) {
   CHECK_EQ(100, static_cast<int>(ab3->ByteLength()));
   CHECK_EQ(my_data, ab3->Data());
   env->Global()->Set(v8_str("ab3"), ab3);
-  result = CompileRun("var u8_b = new __Uint8Array(ab3);"
+  result = CompileRun("var u8_b = new Uint8Array(ab3);"
                       "u8_b[0] = 0xBB;"
                       "u8_b[1] = 0xCC;"
                       "u8_b.length");
index 7f9c763..418d55e 100644 (file)
@@ -30,7 +30,7 @@
 // ArrayBuffer
 
 function TestByteLength(param, expectedByteLength) {
-  var ab = new __ArrayBuffer(param);
+  var ab = new ArrayBuffer(param);
   assertSame(expectedByteLength, ab.byteLength);
 }
 
@@ -47,18 +47,18 @@ function TestArrayBufferCreation() {
 
 /* TODO[dslomov]: Reenable the test
   assertThrows(function() {
-    var ab1 = new __ArrayBuffer(0xFFFFFFFFFFFF)
+    var ab1 = new ArrayBuffer(0xFFFFFFFFFFFF)
   }, RangeError);
 */
 
-  var ab = new __ArrayBuffer();
+  var ab = new ArrayBuffer();
   assertSame(0, ab.byteLength);
 }
 
 TestArrayBufferCreation();
 
 function TestByteLengthNotWritable() {
-  var ab = new __ArrayBuffer(1024);
+  var ab = new ArrayBuffer(1024);
   assertSame(1024, ab.byteLength);
 
   assertThrows(function() { "use strict"; ab.byteLength = 42; }, TypeError);
@@ -67,13 +67,13 @@ function TestByteLengthNotWritable() {
 TestByteLengthNotWritable();
 
 function TestSlice(expectedResultLen, initialLen, start, end) {
-  var ab = new __ArrayBuffer(initialLen);
+  var ab = new ArrayBuffer(initialLen);
   var slice = ab.slice(start, end);
   assertSame(expectedResultLen, slice.byteLength);
 }
 
 function TestArrayBufferSlice() {
-  var ab = new __ArrayBuffer(1024);
+  var ab = new ArrayBuffer(1024);
   var ab1 = ab.slice(512, 1024);
   assertSame(512, ab1.byteLength);
 
@@ -111,7 +111,7 @@ TestArrayBufferSlice();
 // Typed arrays
 
 function TestTypedArray(proto, elementSize, typicalElement) {
-  var ab = new __ArrayBuffer(256*elementSize);
+  var ab = new ArrayBuffer(256*elementSize);
 
   var a1 = new proto(ab, 128*elementSize, 128);
   assertSame(ab, a1.buffer);
@@ -175,7 +175,7 @@ function TestTypedArray(proto, elementSize, typicalElement) {
   if (elementSize !== 1) {
     assertThrows(function() { new proto(ab, 128*elementSize - 1, 10); },
                  RangeError);
-    var unalignedArrayBuffer = new __ArrayBuffer(10*elementSize + 1);
+    var unalignedArrayBuffer = new ArrayBuffer(10*elementSize + 1);
     var goodArray = new proto(unalignedArrayBuffer, 0, 10);
     assertSame(10, goodArray.length);
     assertSame(10*elementSize, goodArray.byteLength);
@@ -186,14 +186,14 @@ function TestTypedArray(proto, elementSize, typicalElement) {
 
 }
 
-TestTypedArray(__Uint8Array, 1, 0xFF);
-TestTypedArray(__Int8Array, 1, -0x7F);
-TestTypedArray(__Uint16Array, 2, 0xFFFF);
-TestTypedArray(__Int16Array, 2, -0x7FFF);
-TestTypedArray(__Uint32Array, 4, 0xFFFFFFFF);
-TestTypedArray(__Int32Array, 4, -0x7FFFFFFF);
-TestTypedArray(__Float32Array, 4, 0.5);
-TestTypedArray(__Float64Array, 8, 0.5);
+TestTypedArray(Uint8Array, 1, 0xFF);
+TestTypedArray(Int8Array, 1, -0x7F);
+TestTypedArray(Uint16Array, 2, 0xFFFF);
+TestTypedArray(Int16Array, 2, -0x7FFF);
+TestTypedArray(Uint32Array, 4, 0xFFFFFFFF);
+TestTypedArray(Int32Array, 4, -0x7FFFFFFF);
+TestTypedArray(Float32Array, 4, 0.5);
+TestTypedArray(Float64Array, 8, 0.5);
 
 
 // General tests for properties
@@ -210,8 +210,8 @@ function TestEnumerable(func, obj) {
   if (obj)
     assertArrayEquals([], props(obj));
 }
-TestEnumerable(__ArrayBuffer, new __ArrayBuffer());
-TestEnumerable(__Uint8Array);
+TestEnumerable(ArrayBuffer, new ArrayBuffer());
+TestEnumerable(Uint8Array);
 
 
 // Test arbitrary properties on ArrayBuffer
@@ -225,7 +225,7 @@ function TestArbitrary(m) {
     TestProperty(m, 'foo' + i, 'bar' + i);
   }
 }
-TestArbitrary(new __ArrayBuffer(256));
+TestArbitrary(new ArrayBuffer(256));
 
 // Test direct constructor call
-assertTrue(__ArrayBuffer() instanceof __ArrayBuffer);
+assertTrue(ArrayBuffer() instanceof ArrayBuffer);