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);
{
// -- 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"));
}
}
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();
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")
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);
// in runtime.js:
// var $Array = global.Array;
-var $ArrayBuffer = global.__ArrayBuffer;
+var $ArrayBuffer = global.ArrayBuffer;
// -------------------------------------------------------------------
}
// 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);
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");
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);
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");
// ArrayBuffer
function TestByteLength(param, expectedByteLength) {
- var ab = new __ArrayBuffer(param);
+ var ab = new ArrayBuffer(param);
assertSame(expectedByteLength, ab.byteLength);
}
/* 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);
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);
// 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);
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);
}
-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
if (obj)
assertArrayEquals([], props(obj));
}
-TestEnumerable(__ArrayBuffer, new __ArrayBuffer());
-TestEnumerable(__Uint8Array);
+TestEnumerable(ArrayBuffer, new ArrayBuffer());
+TestEnumerable(Uint8Array);
// Test arbitrary properties on ArrayBuffer
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);