Version 3.12.6

Cleaned up hardfp ABI detection for ARM (V8 issue 2140).

Extended TypedArray support in d8.

git-svn-id: http://v8.googlecode.com/svn/trunk@11956 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
diff --git a/ChangeLog b/ChangeLog
index a707379..cd6ee92 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2012-06-29: Version 3.12.6
+
+        Cleaned up hardfp ABI detection for ARM (V8 issue 2140).
+
+        Extended TypedArray support in d8.
+
+
 2012-06-28: Version 3.12.5
 
         Fixed lazy parsing heuristics to respect outer scope.
diff --git a/include/v8.h b/include/v8.h
index 77ffb38..f8883fc 100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -1551,6 +1551,12 @@
   V8EXPORT Local<String> ObjectProtoToString();
 
   /**
+   * Returns the function invoked as a constructor for this object.
+   * May be the null value.
+   */
+  V8EXPORT Local<Value> GetConstructor();
+
+  /**
    * Returns the name of the function invoked as a constructor for this object.
    */
   V8EXPORT Local<String> GetConstructorName();
diff --git a/src/api.cc b/src/api.cc
index 0d88047..e3596be 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -3031,6 +3031,17 @@
 }
 
 
+Local<Value> v8::Object::GetConstructor() {
+  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
+  ON_BAILOUT(isolate, "v8::Object::GetConstructor()",
+             return Local<v8::Function>());
+  ENTER_V8(isolate);
+  i::Handle<i::JSObject> self = Utils::OpenHandle(this);
+  i::Handle<i::Object> constructor(self->GetConstructor());
+  return Utils::ToLocal(constructor);
+}
+
+
 Local<String> v8::Object::GetConstructorName() {
   i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
   ON_BAILOUT(isolate, "v8::Object::GetConstructorName()",
diff --git a/src/d8.cc b/src/d8.cc
index adfe667..976510c 100644
--- a/src/d8.cc
+++ b/src/d8.cc
@@ -284,7 +284,7 @@
   return Undefined();
 }
 
-static int32_t convertToUint(Local<Value> value_in, TryCatch* try_catch) {
+static int32_t convertToInt(Local<Value> value_in, TryCatch* try_catch) {
   if (value_in->IsInt32()) {
     return value_in->Int32Value();
   }
@@ -296,7 +296,15 @@
   Local<Int32> int32 = number->ToInt32();
   if (try_catch->HasCaught() || int32.IsEmpty()) return 0;
 
-  int32_t raw_value = int32->Int32Value();
+  int32_t value = int32->Int32Value();
+  if (try_catch->HasCaught()) return 0;
+
+  return value;
+}
+
+
+static int32_t convertToUint(Local<Value> value_in, TryCatch* try_catch) {
+  int32_t raw_value = convertToInt(value_in, try_catch);
   if (try_catch->HasCaught()) return 0;
 
   if (raw_value < 0) {
@@ -317,9 +325,11 @@
 
 
 const char kArrayBufferMarkerPropName[] = "d8::_is_array_buffer_";
+const char kArrayMarkerPropName[] = "d8::_is_typed_array_";
 
 
-Handle<Value> Shell::CreateExternalArrayBuffer(int32_t length) {
+Handle<Value> Shell::CreateExternalArrayBuffer(Handle<Object> buffer,
+                                               int32_t length) {
   static const int32_t kMaxSize = 0x7fffffff;
   // Make sure the total size fits into a (signed) int.
   if (length < 0 || length > kMaxSize) {
@@ -331,7 +341,6 @@
   }
   memset(data, 0, length);
 
-  Handle<Object> buffer = Object::New();
   buffer->SetHiddenValue(String::New(kArrayBufferMarkerPropName), True());
   Persistent<Object> persistent_array = Persistent<Object>::New(buffer);
   persistent_array.MakeWeak(data, ExternalArrayWeakCallback);
@@ -346,7 +355,15 @@
 }
 
 
-Handle<Value> Shell::CreateExternalArrayBuffer(const Arguments& args) {
+Handle<Value> Shell::ArrayBuffer(const Arguments& args) {
+  if (!args.IsConstructCall()) {
+    Handle<Value>* rec_args = new Handle<Value>[args.Length()];
+    for (int i = 0; i < args.Length(); ++i) rec_args[i] = args[i];
+    Handle<Value> result = args.Callee()->NewInstance(args.Length(), rec_args);
+    delete[] rec_args;
+    return result;
+  }
+
   if (args.Length() == 0) {
     return ThrowException(
         String::New("ArrayBuffer constructor must have one parameter."));
@@ -355,19 +372,56 @@
   int32_t length = convertToUint(args[0], &try_catch);
   if (try_catch.HasCaught()) return try_catch.Exception();
 
-  return CreateExternalArrayBuffer(length);
+  return CreateExternalArrayBuffer(args.This(), length);
+}
+
+
+Handle<Object> Shell::CreateExternalArray(Handle<Object> array,
+                                          Handle<Object> buffer,
+                                          ExternalArrayType type,
+                                          int32_t length,
+                                          int32_t byteLength,
+                                          int32_t byteOffset,
+                                          int32_t element_size) {
+  ASSERT(element_size == 1 || element_size == 2 ||
+         element_size == 4 || element_size == 8);
+  ASSERT(byteLength == length * element_size);
+
+  void* data = buffer->GetIndexedPropertiesExternalArrayData();
+  ASSERT(data != NULL);
+
+  array->SetIndexedPropertiesToExternalArrayData(
+      static_cast<uint8_t*>(data) + byteOffset, type, length);
+  array->SetHiddenValue(String::New(kArrayMarkerPropName), Int32::New(type));
+  array->Set(String::New("byteLength"), Int32::New(byteLength), ReadOnly);
+  array->Set(String::New("byteOffset"), Int32::New(byteOffset), ReadOnly);
+  array->Set(String::New("length"), Int32::New(length), ReadOnly);
+  array->Set(String::New("BYTES_PER_ELEMENT"), Int32::New(element_size));
+  array->Set(String::New("buffer"), buffer, ReadOnly);
+
+  return array;
 }
 
 
 Handle<Value> Shell::CreateExternalArray(const Arguments& args,
                                          ExternalArrayType type,
                                          int32_t element_size) {
+  if (!args.IsConstructCall()) {
+    Handle<Value>* rec_args = new Handle<Value>[args.Length()];
+    for (int i = 0; i < args.Length(); ++i) rec_args[i] = args[i];
+    Handle<Value> result = args.Callee()->NewInstance(args.Length(), rec_args);
+    delete[] rec_args;
+    return result;
+  }
+
   TryCatch try_catch;
   ASSERT(element_size == 1 || element_size == 2 ||
          element_size == 4 || element_size == 8);
 
-  // Currently, only the following constructors are supported:
+  // All of the following constructors are supported:
   //   TypedArray(unsigned long length)
+  //   TypedArray(type[] array)
+  //   TypedArray(TypedArray array)
   //   TypedArray(ArrayBuffer buffer,
   //              optional unsigned long byteOffset,
   //              optional unsigned long length)
@@ -375,13 +429,15 @@
   int32_t length;
   int32_t byteLength;
   int32_t byteOffset;
+  bool init_from_array = false;
   if (args.Length() == 0) {
     return ThrowException(
         String::New("Array constructor must have at least one parameter."));
   }
   if (args[0]->IsObject() &&
-     !args[0]->ToObject()->GetHiddenValue(
-         String::New(kArrayBufferMarkerPropName)).IsEmpty()) {
+      !args[0]->ToObject()->GetHiddenValue(
+          String::New(kArrayBufferMarkerPropName)).IsEmpty()) {
+    // Construct from ArrayBuffer.
     buffer = args[0]->ToObject();
     int32_t bufferLength =
         convertToUint(buffer->Get(String::New("byteLength")), &try_catch);
@@ -417,30 +473,103 @@
       }
     }
   } else {
-    length = convertToUint(args[0], &try_catch);
+    if (args[0]->IsObject() &&
+        args[0]->ToObject()->Has(String::New("length"))) {
+      // Construct from array.
+      length = convertToUint(
+          args[0]->ToObject()->Get(String::New("length")), &try_catch);
+      if (try_catch.HasCaught()) return try_catch.Exception();
+      init_from_array = true;
+    } else {
+      // Construct from size.
+      length = convertToUint(args[0], &try_catch);
+      if (try_catch.HasCaught()) return try_catch.Exception();
+    }
     byteLength = length * element_size;
     byteOffset = 0;
-    Handle<Value> result = CreateExternalArrayBuffer(byteLength);
-    if (!result->IsObject()) return result;
+
+    Handle<Object> global = Context::GetCurrent()->Global();
+    Handle<Value> array_buffer = global->Get(String::New("ArrayBuffer"));
+    ASSERT(!try_catch.HasCaught() && array_buffer->IsFunction());
+    Handle<Value> buffer_args[] = { Uint32::New(byteLength) };
+    Handle<Value> result = Handle<Function>::Cast(array_buffer)->NewInstance(
+        1, buffer_args);
+    if (try_catch.HasCaught()) return result;
     buffer = result->ToObject();
   }
 
-  void* data = buffer->GetIndexedPropertiesExternalArrayData();
-  ASSERT(data != NULL);
+  Handle<Object> array = CreateExternalArray(
+      args.This(), buffer, type, length, byteLength, byteOffset, element_size);
 
-  Handle<Object> array = Object::New();
-  array->SetIndexedPropertiesToExternalArrayData(
-      static_cast<uint8_t*>(data) + byteOffset, type, length);
-  array->Set(String::New("byteLength"), Int32::New(byteLength), ReadOnly);
-  array->Set(String::New("byteOffset"), Int32::New(byteOffset), ReadOnly);
-  array->Set(String::New("length"), Int32::New(length), ReadOnly);
-  array->Set(String::New("BYTES_PER_ELEMENT"), Int32::New(element_size));
-  array->Set(String::New("buffer"), buffer, ReadOnly);
+  if (init_from_array) {
+    Handle<Object> init = args[0]->ToObject();
+    for (int i = 0; i < length; ++i) array->Set(i, init->Get(i));
+  }
 
   return array;
 }
 
 
+Handle<Value> Shell::SubArray(const Arguments& args) {
+  TryCatch try_catch;
+
+  if (!args.This()->IsObject()) {
+    return ThrowException(
+        String::New("subarray invoked on non-object receiver."));
+  }
+
+  Local<Object> self = args.This();
+  Local<Value> marker = self->GetHiddenValue(String::New(kArrayMarkerPropName));
+  if (marker.IsEmpty()) {
+    return ThrowException(
+        String::New("subarray invoked on wrong receiver type."));
+  }
+
+  Handle<Object> buffer = self->Get(String::New("buffer"))->ToObject();
+  if (try_catch.HasCaught()) return try_catch.Exception();
+  int32_t length =
+      convertToUint(self->Get(String::New("length")), &try_catch);
+  if (try_catch.HasCaught()) return try_catch.Exception();
+  int32_t byteOffset =
+      convertToUint(self->Get(String::New("byteOffset")), &try_catch);
+  if (try_catch.HasCaught()) return try_catch.Exception();
+  int32_t element_size =
+      convertToUint(self->Get(String::New("BYTES_PER_ELEMENT")), &try_catch);
+  if (try_catch.HasCaught()) return try_catch.Exception();
+
+  if (args.Length() == 0) {
+    return ThrowException(
+        String::New("subarray must have at least one parameter."));
+  }
+  int32_t begin = convertToInt(args[0], &try_catch);
+  if (try_catch.HasCaught()) return try_catch.Exception();
+  if (begin < 0) begin += length;
+  if (begin < 0) begin = 0;
+  if (begin > length) begin = length;
+
+  int32_t end;
+  if (args.Length() < 2 || args[1]->IsUndefined()) {
+    end = length;
+  } else {
+    end = convertToInt(args[1], &try_catch);
+    if (try_catch.HasCaught()) return try_catch.Exception();
+    if (end < 0) end += length;
+    if (end < 0) end = 0;
+    if (end > length) end = length;
+    if (end < begin) end = begin;
+  }
+
+  length = end - begin;
+  byteOffset += begin * element_size;
+
+  Local<Function> constructor = Local<Function>::Cast(self->GetConstructor());
+  Handle<Value> construct_args[] = {
+    buffer, Uint32::New(byteOffset), Uint32::New(length)
+  };
+  return constructor->NewInstance(3, construct_args);
+}
+
+
 void Shell::ExternalArrayWeakCallback(Persistent<Value> object, void* data) {
   HandleScope scope;
   int32_t length =
@@ -451,11 +580,6 @@
 }
 
 
-Handle<Value> Shell::ArrayBuffer(const Arguments& args) {
-  return CreateExternalArrayBuffer(args);
-}
-
-
 Handle<Value> Shell::Int8Array(const Arguments& args) {
   return CreateExternalArray(args, v8::kExternalByteArray, sizeof(int8_t));
 }
@@ -472,8 +596,8 @@
 
 
 Handle<Value> Shell::Uint16Array(const Arguments& args) {
-  return CreateExternalArray(args, kExternalUnsignedShortArray,
-                             sizeof(uint16_t));
+  return CreateExternalArray(
+      args, kExternalUnsignedShortArray, sizeof(uint16_t));
 }
 
 
@@ -488,18 +612,18 @@
 
 
 Handle<Value> Shell::Float32Array(const Arguments& args) {
-  return CreateExternalArray(args, kExternalFloatArray,
-                             sizeof(float));  // NOLINT
+  return CreateExternalArray(
+      args, kExternalFloatArray, sizeof(float));  // NOLINT
 }
 
 
 Handle<Value> Shell::Float64Array(const Arguments& args) {
-  return CreateExternalArray(args, kExternalDoubleArray,
-                             sizeof(double));  // NOLINT
+  return CreateExternalArray(
+      args, kExternalDoubleArray, sizeof(double));  // NOLINT
 }
 
 
-Handle<Value> Shell::PixelArray(const Arguments& args) {
+Handle<Value> Shell::Uint8ClampedArray(const Arguments& args) {
   return CreateExternalArray(args, kExternalPixelArray, sizeof(uint8_t));
 }
 
@@ -794,6 +918,15 @@
 };
 #endif
 
+
+Handle<FunctionTemplate> Shell::CreateArrayTemplate(InvocationCallback fun) {
+  Handle<FunctionTemplate> array_template = FunctionTemplate::New(fun);
+  Local<Template> proto_template = array_template->PrototypeTemplate();
+  proto_template->Set(String::New("subarray"), FunctionTemplate::New(SubArray));
+  return array_template;
+}
+
+
 Handle<ObjectTemplate> Shell::CreateGlobalTemplate() {
   Handle<ObjectTemplate> global_template = ObjectTemplate::New();
   global_template->Set(String::New("print"), FunctionTemplate::New(Print));
@@ -812,26 +945,28 @@
                        FunctionTemplate::New(DisableProfiler));
 
   // Bind the handlers for external arrays.
+  PropertyAttribute attr =
+      static_cast<PropertyAttribute>(ReadOnly | DontDelete);
   global_template->Set(String::New("ArrayBuffer"),
-                       FunctionTemplate::New(ArrayBuffer));
+                       CreateArrayTemplate(ArrayBuffer), attr);
   global_template->Set(String::New("Int8Array"),
-                       FunctionTemplate::New(Int8Array));
+                       CreateArrayTemplate(Int8Array), attr);
   global_template->Set(String::New("Uint8Array"),
-                       FunctionTemplate::New(Uint8Array));
+                       CreateArrayTemplate(Uint8Array), attr);
   global_template->Set(String::New("Int16Array"),
-                       FunctionTemplate::New(Int16Array));
+                       CreateArrayTemplate(Int16Array), attr);
   global_template->Set(String::New("Uint16Array"),
-                       FunctionTemplate::New(Uint16Array));
+                       CreateArrayTemplate(Uint16Array), attr);
   global_template->Set(String::New("Int32Array"),
-                       FunctionTemplate::New(Int32Array));
+                       CreateArrayTemplate(Int32Array), attr);
   global_template->Set(String::New("Uint32Array"),
-                       FunctionTemplate::New(Uint32Array));
+                       CreateArrayTemplate(Uint32Array), attr);
   global_template->Set(String::New("Float32Array"),
-                       FunctionTemplate::New(Float32Array));
+                       CreateArrayTemplate(Float32Array), attr);
   global_template->Set(String::New("Float64Array"),
-                       FunctionTemplate::New(Float64Array));
-  global_template->Set(String::New("PixelArray"),
-                       FunctionTemplate::New(PixelArray));
+                       CreateArrayTemplate(Float64Array), attr);
+  global_template->Set(String::New("Uint8ClampedArray"),
+                       CreateArrayTemplate(Uint8ClampedArray), attr);
 
 #ifdef LIVE_OBJECT_LIST
   global_template->Set(String::New("lol_is_enabled"), True());
diff --git a/src/d8.h b/src/d8.h
index 2789c6d..3410f16 100644
--- a/src/d8.h
+++ b/src/d8.h
@@ -322,7 +322,8 @@
   static Handle<Value> Uint32Array(const Arguments& args);
   static Handle<Value> Float32Array(const Arguments& args);
   static Handle<Value> Float64Array(const Arguments& args);
-  static Handle<Value> PixelArray(const Arguments& args);
+  static Handle<Value> Uint8ClampedArray(const Arguments& args);
+  static Handle<Value> SubArray(const Arguments& args);
   // The OS object on the global object contains methods for performing
   // operating system calls:
   //
@@ -383,8 +384,16 @@
   static void RunShell();
   static bool SetOptions(int argc, char* argv[]);
   static Handle<ObjectTemplate> CreateGlobalTemplate();
-  static Handle<Value> CreateExternalArrayBuffer(int32_t size);
-  static Handle<Value> CreateExternalArrayBuffer(const Arguments& args);
+  static Handle<FunctionTemplate> CreateArrayTemplate(InvocationCallback);
+  static Handle<Value> CreateExternalArrayBuffer(Handle<Object> buffer,
+                                                 int32_t size);
+  static Handle<Object> CreateExternalArray(Handle<Object> array,
+                                            Handle<Object> buffer,
+                                            ExternalArrayType type,
+                                            int32_t length,
+                                            int32_t byteLength,
+                                            int32_t byteOffset,
+                                            int32_t element_size);
   static Handle<Value> CreateExternalArray(const Arguments& args,
                                            ExternalArrayType type,
                                            int32_t element_size);
diff --git a/src/debug.cc b/src/debug.cc
index ffe5b0d..1f5164f 100644
--- a/src/debug.cc
+++ b/src/debug.cc
@@ -896,17 +896,17 @@
                                    Address c_entry_fp,
                                    Address last_fp,
                                    Address larger_fp,
-                                   Address last_in_fp,
-                                   Address last_out_fp,
                                    int count,
+                                   char* stack,
                                    int end) {
   OS::PrintError("start:       %d\n", start);
   OS::PrintError("c_entry_fp:  %p\n", static_cast<void*>(c_entry_fp));
   OS::PrintError("last_fp:     %p\n", static_cast<void*>(last_fp));
   OS::PrintError("larger_fp:   %p\n", static_cast<void*>(larger_fp));
-  OS::PrintError("last_in_fp:  %p\n", static_cast<void*>(last_in_fp));
-  OS::PrintError("last_out_fp: %p\n", static_cast<void*>(last_out_fp));
   OS::PrintError("count:       %d\n", count);
+  if (stack != NULL) {
+    OS::PrintError("stack:       %s\n", stack);
+  }
   OS::PrintError("end:         %d\n", end);
   OS::Abort();
 }
@@ -1014,25 +1014,27 @@
       // - FP of the frame at which we plan to stop stepping out (last FP).
       // - current FP that's larger than last FP.
       // - Counter for the number of steps to step out.
+      // - stack trace string.
       if (it.done()) {
         // We crawled the entire stack, never reaching last_fp_.
         PutValuesOnStackAndDie(0xBEEEEEEE,
                                frame->fp(),
                                thread_local_.last_fp_,
-                               NULL,
-                               thread_local_.step_into_fp_,
-                               thread_local_.step_out_fp_,
+                               reinterpret_cast<Address>(0xDEADDEAD),
                                count,
-                               0xFEEEEEEE);
+                               NULL,
+                               0xCEEEEEEE);
       } else if (it.frame()->fp() != thread_local_.last_fp_) {
         // We crawled over last_fp_, without getting a match.
-        PutValuesOnStackAndDie(0xBEEEEEEE,
+        Handle<String> stack = isolate_->StackTraceString();
+        char buffer[2048];
+        String::WriteToFlat(*stack, buffer, 0, 2047);
+        PutValuesOnStackAndDie(0xDEEEEEEE,
                                frame->fp(),
                                thread_local_.last_fp_,
                                it.frame()->fp(),
-                               thread_local_.step_into_fp_,
-                               thread_local_.step_out_fp_,
                                count,
+                               buffer,
                                0xFEEEEEEE);
       }
 
diff --git a/src/debug.h b/src/debug.h
index 445137c..9b5c250 100644
--- a/src/debug.h
+++ b/src/debug.h
@@ -236,9 +236,8 @@
                                         Address c_entry_fp,
                                         Address last_fp,
                                         Address larger_fp,
-                                        Address last_in_fp,
-                                        Address last_out_fp,
                                         int count,
+                                        char* stack,
                                         int end));
   Object* Break(Arguments args);
   void SetBreakPoint(Handle<JSFunction> function,
diff --git a/src/objects-inl.h b/src/objects-inl.h
index b334669..074f1ed 100644
--- a/src/objects-inl.h
+++ b/src/objects-inl.h
@@ -4798,6 +4798,11 @@
 }
 
 
+Object* JSReceiver::GetConstructor() {
+  return map()->constructor();
+}
+
+
 bool JSReceiver::HasProperty(String* name) {
   if (IsJSProxy()) {
     return JSProxy::cast(this)->HasPropertyWithHandler(name);
diff --git a/src/objects.h b/src/objects.h
index 90564f3..274f1dc 100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -1435,6 +1435,9 @@
   // Return the object's prototype (might be Heap::null_value()).
   inline Object* GetPrototype();
 
+  // Return the constructor function (may be Heap::null_value()).
+  inline Object* GetConstructor();
+
   // Set the object's prototype (only JSReceiver and null are allowed).
   MUST_USE_RESULT MaybeObject* SetPrototype(Object* value,
                                             bool skip_hidden_prototypes);
diff --git a/src/platform-linux.cc b/src/platform-linux.cc
index f6db423..9028fd0 100644
--- a/src/platform-linux.cc
+++ b/src/platform-linux.cc
@@ -161,48 +161,43 @@
 }
 
 
-// Simple helper function to detect whether the C code is compiled with
-// option -mfloat-abi=hard. The register d0 is loaded with 1.0 and the register
-// pair r0, r1 is loaded with 0.0. If -mfloat-abi=hard is pased to GCC then
-// calling this will return 1.0 and otherwise 0.0.
-static void ArmUsingHardFloatHelper() {
-  asm("mov r0, #0":::"r0");
-#if defined(__VFP_FP__) && !defined(__SOFTFP__)
-  // Load 0x3ff00000 into r1 using instructions available in both ARM
-  // and Thumb mode.
-  asm("mov r1, #3":::"r1");
-  asm("mov r2, #255":::"r2");
-  asm("lsl r1, r1, #8":::"r1");
-  asm("orr r1, r1, r2":::"r1");
-  asm("lsl r1, r1, #20":::"r1");
-  // For vmov d0, r0, r1 use ARM mode.
-#ifdef __thumb__
-  asm volatile(
-    "@   Enter ARM Mode  \n\t"
-    "    adr r3, 1f      \n\t"
-    "    bx  r3          \n\t"
-    "    .ALIGN 4        \n\t"
-    "    .ARM            \n"
-    "1:  vmov d0, r0, r1 \n\t"
-    "@   Enter THUMB Mode\n\t"
-    "    adr r3, 2f+1    \n\t"
-    "    bx  r3          \n\t"
-    "    .THUMB          \n"
-    "2:                  \n\t":::"r3");
-#else
-  asm("vmov d0, r0, r1");
-#endif  // __thumb__
-#endif  // defined(__VFP_FP__) && !defined(__SOFTFP__)
-  asm("mov r1, #0":::"r1");
-}
-
-
 bool OS::ArmUsingHardFloat() {
-  // Cast helper function from returning void to returning double.
-  typedef double (*F)();
-  F f = FUNCTION_CAST<F>(FUNCTION_ADDR(ArmUsingHardFloatHelper));
-  return f() == 1.0;
+  // GCC versions 4.6 and above define __ARM_PCS or __ARM_PCS_VFP to specify
+  // the Floating Point ABI used (PCS stands for Procedure Call Standard).
+  // We use these as well as a couple of other defines to statically determine
+  // what FP ABI used.
+  // GCC versions 4.4 and below don't support hard-fp.
+  // GCC versions 4.5 may support hard-fp without defining __ARM_PCS or
+  // __ARM_PCS_VFP.
+
+#define GCC_VERSION (__GNUC__ * 10000                                          \
+                     + __GNUC_MINOR__ * 100                                    \
+                     + __GNUC_PATCHLEVEL__)
+#if GCC_VERSION >= 40600
+#if defined(__ARM_PCS_VFP)
+  return true;
+#else
+  return false;
+#endif
+
+#elif GCC_VERSION < 40500
+  return false;
+
+#else
+#if defined(__ARM_PCS_VFP)
+  return true;
+#elif defined(__ARM_PCS) || defined(__SOFTFP) || !defined(__VFP_FP__)
+  return false;
+#else
+#error "Your version of GCC does not report the FP ABI compiled for."          \
+       "Please report it on this issue"                                        \
+       "http://code.google.com/p/v8/issues/detail?id=2140"
+
+#endif
+#endif
+#undef GCC_VERSION
 }
+
 #endif  // def __arm__
 
 
diff --git a/src/version.cc b/src/version.cc
index aaff665..d5a287d 100644
--- a/src/version.cc
+++ b/src/version.cc
@@ -34,7 +34,7 @@
 // cannot be changed without changing the SCons build script.
 #define MAJOR_VERSION     3
 #define MINOR_VERSION     12
-#define BUILD_NUMBER      5
+#define BUILD_NUMBER      6
 #define PATCH_LEVEL       0
 // Use 1 for candidates and 0 otherwise.
 // (Boolean macro values are not supported by all preprocessors.)
diff --git a/test/mjsunit/elements-kind.js b/test/mjsunit/elements-kind.js
index 508a6b3..b74a212 100644
--- a/test/mjsunit/elements-kind.js
+++ b/test/mjsunit/elements-kind.js
@@ -143,7 +143,7 @@
 assertKind(elements_kind.external_unsigned_int,   new Uint32Array(23));
 assertKind(elements_kind.external_float,          new Float32Array(7));
 assertKind(elements_kind.external_double,         new Float64Array(0));
-assertKind(elements_kind.external_pixel,          new PixelArray(512));
+assertKind(elements_kind.external_pixel,          new Uint8ClampedArray(512));
 
 // Crankshaft support for smi-only array elements.
 function monomorphic(array) {
diff --git a/test/mjsunit/external-array.js b/test/mjsunit/external-array.js
index d029220..37dc7a0 100644
--- a/test/mjsunit/external-array.js
+++ b/test/mjsunit/external-array.js
@@ -27,6 +27,12 @@
 
 // Flags: --allow-natives-syntax --expose-gc
 
+// Helper
+function assertInstance(o, f) {
+  assertSame(o.constructor, f);
+  assertInstanceof(o, f);
+}
+
 // This is a regression test for overlapping key and value registers.
 function f(a) {
   a[0] = 0;
@@ -51,49 +57,58 @@
 
 // Test derivation from an ArrayBuffer
 var ab = new ArrayBuffer(12);
+assertInstance(ab, ArrayBuffer);
 var derived_uint8 = new Uint8Array(ab);
+assertInstance(derived_uint8, Uint8Array);
 assertSame(ab, derived_uint8.buffer);
 assertEquals(12, derived_uint8.length);
 assertEquals(12, derived_uint8.byteLength);
 assertEquals(0, derived_uint8.byteOffset);
 assertEquals(1, derived_uint8.BYTES_PER_ELEMENT);
 var derived_uint8_2 = new Uint8Array(ab,7);
+assertInstance(derived_uint8_2, Uint8Array);
 assertSame(ab, derived_uint8_2.buffer);
 assertEquals(5, derived_uint8_2.length);
 assertEquals(5, derived_uint8_2.byteLength);
 assertEquals(7, derived_uint8_2.byteOffset);
 assertEquals(1, derived_uint8_2.BYTES_PER_ELEMENT);
 var derived_int16 = new Int16Array(ab);
+assertInstance(derived_int16, Int16Array);
 assertSame(ab, derived_int16.buffer);
 assertEquals(6, derived_int16.length);
 assertEquals(12, derived_int16.byteLength);
 assertEquals(0, derived_int16.byteOffset);
 assertEquals(2, derived_int16.BYTES_PER_ELEMENT);
 var derived_int16_2 = new Int16Array(ab,6);
+assertInstance(derived_int16_2, Int16Array);
 assertSame(ab, derived_int16_2.buffer);
 assertEquals(3, derived_int16_2.length);
 assertEquals(6, derived_int16_2.byteLength);
 assertEquals(6, derived_int16_2.byteOffset);
 assertEquals(2, derived_int16_2.BYTES_PER_ELEMENT);
 var derived_uint32 = new Uint32Array(ab);
+assertInstance(derived_uint32, Uint32Array);
 assertSame(ab, derived_uint32.buffer);
 assertEquals(3, derived_uint32.length);
 assertEquals(12, derived_uint32.byteLength);
 assertEquals(0, derived_uint32.byteOffset);
 assertEquals(4, derived_uint32.BYTES_PER_ELEMENT);
 var derived_uint32_2 = new Uint32Array(ab,4);
+assertInstance(derived_uint32_2, Uint32Array);
 assertSame(ab, derived_uint32_2.buffer);
 assertEquals(2, derived_uint32_2.length);
 assertEquals(8, derived_uint32_2.byteLength);
 assertEquals(4, derived_uint32_2.byteOffset);
 assertEquals(4, derived_uint32_2.BYTES_PER_ELEMENT);
 var derived_uint32_3 = new Uint32Array(ab,4,1);
+assertInstance(derived_uint32_3, Uint32Array);
 assertSame(ab, derived_uint32_3.buffer);
 assertEquals(1, derived_uint32_3.length);
 assertEquals(4, derived_uint32_3.byteLength);
 assertEquals(4, derived_uint32_3.byteOffset);
 assertEquals(4, derived_uint32_3.BYTES_PER_ELEMENT);
 var derived_float64 = new Float64Array(ab,0,1);
+assertInstance(derived_float64, Float64Array);
 assertSame(ab, derived_float64.buffer);
 assertEquals(1, derived_float64.length);
 assertEquals(8, derived_float64.byteLength);
@@ -144,6 +159,7 @@
 assertSame(a.buffer, (new Uint16Array(a.buffer)).buffer);
 assertSame(a.buffer, (new Float32Array(a.buffer,4)).buffer);
 assertSame(a.buffer, (new Int8Array(a.buffer,3,51)).buffer);
+assertInstance(a.buffer, ArrayBuffer);
 
 // Test the correct behavior of the |BYTES_PER_ELEMENT| property (which is
 // "constant", but not read-only).
@@ -198,7 +214,7 @@
 
 // Test loads and stores.
 types = [Array, Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array,
-         Uint32Array, PixelArray, Float32Array, Float64Array];
+         Uint32Array, Uint8ClampedArray, Float32Array, Float64Array];
 
 test_result_nan = [NaN, 0, 0, 0, 0, 0, 0, 0, NaN, NaN];
 test_result_low_int = [-1, -1, 255, -1, 65535, -1, 0xFFFFFFFF, 0, -1, -1];
@@ -412,22 +428,115 @@
 
 
 // Check handling of 0-sized buffers and arrays.
-
 ab = new ArrayBuffer(0);
+assertInstance(ab, ArrayBuffer);
 assertEquals(0, ab.byteLength);
 a = new Int8Array(ab);
+assertInstance(a, Int8Array);
 assertEquals(0, a.byteLength);
 assertEquals(0, a.length);
 a[0] = 1;
-assertEquals(undefined, a[0])
+assertEquals(undefined, a[0]);
 ab = new ArrayBuffer(16);
+assertInstance(ab, ArrayBuffer);
 a = new Float32Array(ab,4,0);
+assertInstance(a, Float32Array);
 assertEquals(0, a.byteLength);
 assertEquals(0, a.length);
 a[0] = 1;
-assertEquals(undefined, a[0])
+assertEquals(undefined, a[0]);
 a = new Uint16Array(0);
+assertInstance(a, Uint16Array);
 assertEquals(0, a.byteLength);
 assertEquals(0, a.length);
 a[0] = 1;
-assertEquals(undefined, a[0])
+assertEquals(undefined, a[0]);
+
+
+// Check construction from arrays.
+a = new Uint32Array([]);
+assertInstance(a, Uint32Array);
+assertEquals(0, a.length);
+assertEquals(0, a.byteLength);
+assertEquals(0, a.buffer.byteLength);
+assertEquals(4, a.BYTES_PER_ELEMENT);
+assertInstance(a.buffer, ArrayBuffer);
+a = new Uint16Array([1,2,3]);
+assertInstance(a, Uint16Array);
+assertEquals(3, a.length);
+assertEquals(6, a.byteLength);
+assertEquals(6, a.buffer.byteLength);
+assertEquals(2, a.BYTES_PER_ELEMENT);
+assertEquals(1, a[0]);
+assertEquals(3, a[2]);
+assertInstance(a.buffer, ArrayBuffer);
+a = new Uint32Array(a);
+assertInstance(a, Uint32Array);
+assertEquals(3, a.length);
+assertEquals(12, a.byteLength);
+assertEquals(12, a.buffer.byteLength);
+assertEquals(4, a.BYTES_PER_ELEMENT);
+assertEquals(1, a[0]);
+assertEquals(3, a[2]);
+assertInstance(a.buffer, ArrayBuffer);
+
+// Check subarrays.
+a = new Uint16Array([1,2,3,4,5,6]);
+aa = a.subarray(3);
+assertInstance(aa, Uint16Array);
+assertEquals(3, aa.length);
+assertEquals(6, aa.byteLength);
+assertEquals(2, aa.BYTES_PER_ELEMENT);
+assertSame(a.buffer, aa.buffer);
+aa = a.subarray(3,5);
+assertInstance(aa, Uint16Array);
+assertEquals(2, aa.length);
+assertEquals(4, aa.byteLength);
+assertEquals(2, aa.BYTES_PER_ELEMENT);
+assertSame(a.buffer, aa.buffer);
+aa = a.subarray(4,8);
+assertInstance(aa, Uint16Array);
+assertEquals(2, aa.length);
+assertEquals(4, aa.byteLength);
+assertEquals(2, aa.BYTES_PER_ELEMENT);
+assertSame(a.buffer, aa.buffer);
+aa = a.subarray(9);
+assertInstance(aa, Uint16Array);
+assertEquals(0, aa.length);
+assertEquals(0, aa.byteLength);
+assertEquals(2, aa.BYTES_PER_ELEMENT);
+assertSame(a.buffer, aa.buffer);
+aa = a.subarray(-4);
+assertInstance(aa, Uint16Array);
+assertEquals(4, aa.length);
+assertEquals(8, aa.byteLength);
+assertEquals(2, aa.BYTES_PER_ELEMENT);
+assertSame(a.buffer, aa.buffer);
+aa = a.subarray(-3,-1);
+assertInstance(aa, Uint16Array);
+assertEquals(2, aa.length);
+assertEquals(4, aa.byteLength);
+assertEquals(2, aa.BYTES_PER_ELEMENT);
+assertSame(a.buffer, aa.buffer);
+aa = a.subarray(3,2);
+assertInstance(aa, Uint16Array);
+assertEquals(0, aa.length);
+assertEquals(0, aa.byteLength);
+assertEquals(2, aa.BYTES_PER_ELEMENT);
+assertSame(a.buffer, aa.buffer);
+aa = a.subarray(-3,-4);
+assertInstance(aa, Uint16Array);
+assertEquals(0, aa.length);
+assertEquals(0, aa.byteLength);
+assertEquals(2, aa.BYTES_PER_ELEMENT);
+assertSame(a.buffer, aa.buffer);
+aa = a.subarray(0,-8);
+assertInstance(aa, Uint16Array);
+assertEquals(0, aa.length);
+assertEquals(0, aa.byteLength);
+assertEquals(2, aa.BYTES_PER_ELEMENT);
+assertSame(a.buffer, aa.buffer);
+
+assertThrows(function(){ a.subarray.call({}, 0) });
+assertThrows(function(){ a.subarray.call([], 0) });
+assertThrows(function(){ a.subarray.call(a) });
diff --git a/test/mjsunit/mjsunit.js b/test/mjsunit/mjsunit.js
index 65fb301..25d7c00 100644
--- a/test/mjsunit/mjsunit.js
+++ b/test/mjsunit/mjsunit.js
@@ -321,7 +321,7 @@
   assertInstanceof = function assertInstanceof(obj, type) {
     if (!(obj instanceof type)) {
       var actualTypeName = null;
-      var actualConstructor = Object.prototypeOf(obj).constructor;
+      var actualConstructor = Object.getPrototypeOf(obj).constructor;
       if (typeof actualConstructor == "function") {
         actualTypeName = actualConstructor.name || String(actualConstructor);
       }
diff --git a/test/mjsunit/pixel-array-rounding.js b/test/mjsunit/pixel-array-rounding.js
index ef5a10b..0c307e6 100644
--- a/test/mjsunit/pixel-array-rounding.js
+++ b/test/mjsunit/pixel-array-rounding.js
@@ -27,7 +27,7 @@
 
 // Flags: --allow-natives-syntax
 
-var pixels = new PixelArray(8);
+var pixels = new Uint8ClampedArray(8);
 
 function f() {
   for (var i = 0; i < 8; i++) {
diff --git a/test/mjsunit/regress/regress-1563.js b/test/mjsunit/regress/regress-1563.js
index c25b6c7..884b125 100644
--- a/test/mjsunit/regress/regress-1563.js
+++ b/test/mjsunit/regress/regress-1563.js
@@ -27,7 +27,7 @@
 
 // Flags: --allow-natives-syntax
 
-obj = new PixelArray(10);
+obj = new Uint8ClampedArray(10);
 
 // Test that undefined gets properly clamped in Crankshafted pixel array
 // assignments.