Revision: 23504
Author:   [email protected]
Date:     Fri Aug 29 00:04:38 2014 UTC
Log:      Version 3.29.29 (based on bleeding_edge revision r23501)

Performance and stability improvements on all platforms.
https://code.google.com/p/v8/source/detail?r=23504

Added:
 /trunk/src/compiler/access-builder.h
 /trunk/test/cctest/compiler/test-run-properties.cc
Modified:
 /trunk/BUILD.gn
 /trunk/ChangeLog
 /trunk/src/compiler/js-typed-lowering.cc
 /trunk/src/compiler/js-typed-lowering.h
 /trunk/src/compiler/pipeline.cc
 /trunk/src/compiler/simplified-operator.h
 /trunk/src/compiler.cc
 /trunk/src/compiler.h
 /trunk/src/objects-printer.cc
 /trunk/src/version.cc
 /trunk/test/cctest/cctest.gyp
 /trunk/test/cctest/cctest.status
 /trunk/test/cctest/compiler/function-tester.h
 /trunk/test/cctest/compiler/test-simplified-lowering.cc
 /trunk/tools/gyp/v8.gyp
 /trunk/tools/run_benchmarks.py
 /trunk/tools/unittests/run_benchmarks_test.py

=======================================
--- /dev/null
+++ /trunk/src/compiler/access-builder.h        Fri Aug 29 00:04:38 2014 UTC
@@ -0,0 +1,96 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef V8_COMPILER_ACCESS_BUILDER_H_
+#define V8_COMPILER_ACCESS_BUILDER_H_
+
+#include "src/compiler/simplified-operator.h"
+
+namespace v8 {
+namespace internal {
+namespace compiler {
+
+// This access builder provides a set of static methods constructing commonly +// used FieldAccess and ElementAccess descriptors. These descriptors server as
+// parameters to simplified load/store operators.
+class AccessBuilder : public AllStatic {
+ public:
+  // Provides access to HeapObject::map() field.
+  static FieldAccess ForMap() {
+ return {kTaggedBase, HeapObject::kMapOffset, Handle<Name>(), Type::Any(),
+            kMachAnyTagged};
+  }
+
+  // Provides access to JSObject::properties() field.
+  static FieldAccess ForJSObjectProperties() {
+    return {kTaggedBase, JSObject::kPropertiesOffset, Handle<Name>(),
+            Type::Any(), kMachAnyTagged};
+  }
+
+  // Provides access to JSObject::elements() field.
+  static FieldAccess ForJSObjectElements() {
+    return {kTaggedBase, JSObject::kElementsOffset, Handle<Name>(),
+            Type::Internal(), kMachAnyTagged};
+  }
+
+  // Provides access to JSArrayBuffer::backing_store() field.
+  static FieldAccess ForJSArrayBufferBackingStore() {
+ return {kTaggedBase, JSArrayBuffer::kBackingStoreOffset, Handle<Name>(),
+            Type::UntaggedPtr(), kMachPtr};
+  }
+
+  // Provides access to ExternalArray::external_pointer() field.
+  static FieldAccess ForExternalArrayPointer() {
+ return {kTaggedBase, ExternalArray::kExternalPointerOffset, Handle<Name>(),
+            Type::UntaggedPtr(), kMachPtr};
+  }
+
+  // Provides access to FixedArray elements.
+  static ElementAccess ForFixedArrayElement() {
+ return {kTaggedBase, FixedArray::kHeaderSize, Type::Any(), kMachAnyTagged};
+  }
+
+  // TODO(mstarzinger): Raw access only for testing, drop me.
+  static ElementAccess ForBackingStoreElement(MachineType rep) {
+    return {kUntaggedBase, kNonHeapObjectHeaderSize - kHeapObjectTag,
+            Type::Any(), rep};
+  }
+
+ // Provides access to Fixed{type}TypedArray and External{type}Array elements.
+  static ElementAccess ForTypedArrayElement(ExternalArrayType type,
+                                            bool is_external) {
+    BaseTaggedness taggedness = is_external ? kUntaggedBase : kTaggedBase;
+    int header_size = is_external ? 0 : FixedTypedArrayBase::kDataOffset;
+    switch (type) {
+      case kExternalInt8Array:
+        return {taggedness, header_size, Type::Signed32(), kMachInt8};
+      case kExternalUint8Array:
+      case kExternalUint8ClampedArray:
+        return {taggedness, header_size, Type::Unsigned32(), kMachUint8};
+      case kExternalInt16Array:
+        return {taggedness, header_size, Type::Signed32(), kMachInt16};
+      case kExternalUint16Array:
+        return {taggedness, header_size, Type::Unsigned32(), kMachUint16};
+      case kExternalInt32Array:
+        return {taggedness, header_size, Type::Signed32(), kMachInt32};
+      case kExternalUint32Array:
+        return {taggedness, header_size, Type::Unsigned32(), kMachUint32};
+      case kExternalFloat32Array:
+        return {taggedness, header_size, Type::Number(), kRepFloat32};
+      case kExternalFloat64Array:
+        return {taggedness, header_size, Type::Number(), kRepFloat64};
+    }
+    UNREACHABLE();
+    return {kUntaggedBase, 0, Type::None(), kMachNone};
+  }
+
+ private:
+  DISALLOW_COPY_AND_ASSIGN(AccessBuilder);
+};
+
+}  // namespace compiler
+}  // namespace internal
+}  // namespace v8
+
+#endif  // V8_COMPILER_ACCESS_BUILDER_H_
=======================================
--- /dev/null
+++ /trunk/test/cctest/compiler/test-run-properties.cc Fri Aug 29 00:04:38 2014 UTC
@@ -0,0 +1,71 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "src/v8.h"
+
+#include "test/cctest/compiler/function-tester.h"
+
+using namespace v8::internal;
+using namespace v8::internal::compiler;
+
+template <typename U>
+static void TypedArrayLoadHelper(const char* array_type) {
+  const int64_t values[] = {
+ 0x00000000, 0x00000001, 0x00000023, 0x00000042, 0x12345678, 0x87654321, + 0x0000003f, 0x0000007f, 0x00003fff, 0x00007fff, 0x3fffffff, 0x7fffffff, + 0x000000ff, 0x00000080, 0x0000ffff, 0x00008000, 0xffffffff, 0x80000000,
+  };
+  size_t size = arraysize(values);
+  EmbeddedVector<char, 1024> values_buffer;
+ StringBuilder values_builder(values_buffer.start(), values_buffer.length());
+  for (unsigned i = 0; i < size; i++) {
+    values_builder.AddFormatted("a[%d] = 0x%08x;", i, values[i]);
+  }
+
+ // Note that below source creates two different typed arrays with distinct
+  // elements kind to get coverage for both access patterns:
+  // - IsFixedTypedArrayElementsKind(x)
+  // - IsExternalArrayElementsKind(y)
+  const char* source =
+      "(function(a) {"
+      "  var x = (a = new %sArray(%d)); %s;"
+      "  var y = (a = new %sArray(%d)); %s; %%TypedArrayGetBuffer(y);"
+      "  if (!%%HasFixed%sElements(x)) %%AbortJS('x');"
+      "  if (!%%HasExternal%sElements(y)) %%AbortJS('y');"
+      "  function f(a,b) {"
+      "    a = a | 0; b = b | 0;"
+      "    return x[a] + y[b];"
+      "  }"
+      "  return f;"
+      "})()";
+  EmbeddedVector<char, 1024> source_buffer;
+  SNPrintF(source_buffer, source, array_type, size, values_buffer.start(),
+ array_type, size, values_buffer.start(), array_type, array_type);
+
+  FunctionTester T(
+      source_buffer.start(),
+ CompilationInfo::kContextSpecializing | CompilationInfo::kTypingEnabled);
+  for (unsigned i = 0; i < size; i++) {
+    for (unsigned j = 0; j < size; j++) {
+      double value_a = static_cast<U>(values[i]);
+      double value_b = static_cast<U>(values[j]);
+      double expected = value_a + value_b;
+      T.CheckCall(T.Val(expected), T.Val(i), T.Val(j));
+    }
+  }
+}
+
+
+TEST(TypedArrayLoad) {
+  FLAG_typed_array_max_size_in_heap = 256;
+  TypedArrayLoadHelper<int8_t>("Int8");
+  TypedArrayLoadHelper<uint8_t>("Uint8");
+  TypedArrayLoadHelper<int16_t>("Int16");
+  TypedArrayLoadHelper<uint16_t>("Uint16");
+  TypedArrayLoadHelper<int32_t>("Int32");
+  TypedArrayLoadHelper<uint32_t>("Uint32");
+  TypedArrayLoadHelper<double>("Float64");
+  // TODO(mstarzinger): Add tests for Float32.
+  // TODO(mstarzinger): Add tests for ClampedUint8.
+}
=======================================
--- /trunk/BUILD.gn     Thu Aug 28 07:03:22 2014 UTC
+++ /trunk/BUILD.gn     Fri Aug 29 00:04:38 2014 UTC
@@ -460,6 +460,7 @@
     "src/codegen.h",
     "src/compilation-cache.cc",
     "src/compilation-cache.h",
+    "src/compiler/access-builder.h",
     "src/compiler/ast-graph-builder.cc",
     "src/compiler/ast-graph-builder.h",
     "src/compiler/change-lowering.cc",
=======================================
--- /trunk/ChangeLog    Thu Aug 28 15:38:17 2014 UTC
+++ /trunk/ChangeLog    Fri Aug 29 00:04:38 2014 UTC
@@ -1,3 +1,8 @@
+2014-08-29: Version 3.29.29
+
+        Performance and stability improvements on all platforms.
+
+
 2014-08-28: Version 3.29.27

         Performance and stability improvements on all platforms.
=======================================
--- /trunk/src/compiler/js-typed-lowering.cc    Thu Aug 21 07:23:04 2014 UTC
+++ /trunk/src/compiler/js-typed-lowering.cc    Fri Aug 29 00:04:38 2014 UTC
@@ -2,6 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.

+#include "src/compiler/access-builder.h"
 #include "src/compiler/graph-inl.h"
 #include "src/compiler/js-typed-lowering.h"
 #include "src/compiler/node-aux-data-inl.h"
@@ -497,6 +498,43 @@
   // TODO(turbofan): js-typed-lowering of ToBoolean(string)
   return NoChange();
 }
+
+
+Reduction JSTypedLowering::ReduceJSPropertyLoad(Node* node) {
+  Node* key = NodeProperties::GetValueInput(node, 1);
+  Node* base = NodeProperties::GetValueInput(node, 0);
+  Type* key_type = NodeProperties::GetBounds(key).upper;
+  Type* base_type = NodeProperties::GetBounds(base).upper;
+  // TODO(mstarzinger): This lowering is not correct if:
+  //   a) The typed array turns external (i.e. MaterializeArrayBuffer)
+  //   b) The typed array or it's buffer is neutered.
+  //   c) The index is out of bounds.
+  if (base_type->IsConstant() && key_type->Is(Type::Integral32()) &&
+      base_type->AsConstant()->Value()->IsJSTypedArray()) {
+    // JSLoadProperty(typed-array, int32)
+ JSTypedArray* array = JSTypedArray::cast(*base_type->AsConstant()->Value());
+    ElementsKind elements_kind = array->map()->elements_kind();
+    ExternalArrayType type = array->type();
+    ElementAccess element_access;
+    Node* elements = graph()->NewNode(
+ simplified()->LoadField(AccessBuilder::ForJSObjectElements()), base,
+        NodeProperties::GetEffectInput(node));
+    if (IsExternalArrayElementsKind(elements_kind)) {
+      elements = graph()->NewNode(
+ simplified()->LoadField(AccessBuilder::ForExternalArrayPointer()),
+          elements, NodeProperties::GetEffectInput(node));
+      element_access = AccessBuilder::ForTypedArrayElement(type, true);
+    } else {
+      DCHECK(IsFixedTypedArrayElementsKind(elements_kind));
+      element_access = AccessBuilder::ForTypedArrayElement(type, false);
+    }
+    Node* value =
+ graph()->NewNode(simplified()->LoadElement(element_access), elements,
+                         key, NodeProperties::GetEffectInput(node));
+    return ReplaceEagerly(node, value);
+  }
+  return NoChange();
+}


 static Reduction ReplaceWithReduction(Node* node, Reduction reduction) {
@@ -573,6 +611,8 @@
     case IrOpcode::kJSToString:
       return ReplaceWithReduction(node,
                                   ReduceJSToStringInput(node->InputAt(0)));
+    case IrOpcode::kJSLoadProperty:
+      return ReduceJSPropertyLoad(node);
     default:
       break;
   }
=======================================
--- /trunk/src/compiler/js-typed-lowering.h     Wed Aug 20 00:06:26 2014 UTC
+++ /trunk/src/compiler/js-typed-lowering.h     Fri Aug 29 00:04:38 2014 UTC
@@ -39,6 +39,7 @@
   Reduction ReplaceWith(Node* node) { return Reducer::Replace(node); }
   Reduction ReduceJSAdd(Node* node);
   Reduction ReduceJSComparison(Node* node);
+  Reduction ReduceJSPropertyLoad(Node* node);
   Reduction ReduceJSEqual(Node* node, bool invert);
   Reduction ReduceJSStrictEqual(Node* node, bool invert);
   Reduction ReduceJSToNumberInput(Node* input);
=======================================
--- /trunk/src/compiler/pipeline.cc     Thu Aug 28 09:24:16 2014 UTC
+++ /trunk/src/compiler/pipeline.cc     Fri Aug 29 00:04:38 2014 UTC
@@ -16,11 +16,13 @@
 #include "src/compiler/js-generic-lowering.h"
 #include "src/compiler/js-inlining.h"
 #include "src/compiler/js-typed-lowering.h"
+#include "src/compiler/machine-operator-reducer.h"
 #include "src/compiler/phi-reducer.h"
 #include "src/compiler/register-allocator.h"
 #include "src/compiler/schedule.h"
 #include "src/compiler/scheduler.h"
 #include "src/compiler/simplified-lowering.h"
+#include "src/compiler/simplified-operator-reducer.h"
 #include "src/compiler/typer.h"
 #include "src/compiler/verifier.h"
 #include "src/hydrogen.h"
@@ -213,7 +215,7 @@
     GraphReplayPrinter::PrintReplay(&graph);
   }

-  if (FLAG_turbo_types) {
+  if (info()->is_typing_enabled()) {
     {
       // Type the graph.
       PhaseStats typer_stats(info(), PhaseStats::CREATE_GRAPH, "typer");
@@ -247,15 +249,20 @@
     }
     {
       // Lower changes that have been inserted before.
-      PhaseStats lowering_stats(info(), PhaseStats::CREATE_GRAPH,
+      PhaseStats lowering_stats(info(), PhaseStats::OPTIMIZATION,
                                 "change lowering");
       SourcePositionTable::Scope pos(&source_positions,
                                      SourcePosition::Unknown());
       Linkage linkage(info());
       MachineOperatorBuilder machine(zone());
+      SimplifiedOperatorReducer simple_reducer(&jsgraph, &machine);
       ChangeLowering lowering(&jsgraph, &linkage, &machine);
+      MachineOperatorReducer mach_reducer(&graph);
       GraphReducer graph_reducer(&graph);
+ // TODO(titzer): Figure out if we should run all reducers at once here.
+      graph_reducer.AddReducer(&simple_reducer);
       graph_reducer.AddReducer(&lowering);
+      graph_reducer.AddReducer(&mach_reducer);
       graph_reducer.ReduceGraph();

       VerifyAndPrintGraph(&graph, "Lowered changes");
=======================================
--- /trunk/src/compiler/simplified-operator.h   Wed Aug 20 00:06:26 2014 UTC
+++ /trunk/src/compiler/simplified-operator.h   Fri Aug 29 00:04:38 2014 UTC
@@ -92,6 +92,55 @@
          op->opcode() == IrOpcode::kStoreElement);
   return static_cast<Operator1<ElementAccess>*>(op)->parameter();
 }
+
+
+// This access helper provides a set of static methods constructing commonly
+// used FieldAccess and ElementAccess descriptors.
+class Access : public AllStatic {
+ public:
+  // Provides access to JSObject::elements() field.
+  static FieldAccess ForJSObjectElements() {
+    return {kTaggedBase, JSObject::kElementsOffset, Handle<Name>(),
+            Type::Internal(), kMachAnyTagged};
+  }
+
+  // Provides access to ExternalArray::external_pointer() field.
+  static FieldAccess ForExternalArrayPointer() {
+ return {kTaggedBase, ExternalArray::kExternalPointerOffset, Handle<Name>(),
+            Type::UntaggedPtr(), kMachPtr};
+  }
+
+ // Provides access to Fixed{type}TypedArray and External{type}Array elements.
+  static ElementAccess ForTypedArrayElement(ExternalArrayType type,
+                                            bool is_external) {
+    BaseTaggedness taggedness = is_external ? kUntaggedBase : kTaggedBase;
+    int header_size = is_external ? 0 : FixedTypedArrayBase::kDataOffset;
+    switch (type) {
+      case kExternalInt8Array:
+        return {taggedness, header_size, Type::Signed32(), kMachInt8};
+      case kExternalUint8Array:
+      case kExternalUint8ClampedArray:
+        return {taggedness, header_size, Type::Unsigned32(), kMachUint8};
+      case kExternalInt16Array:
+        return {taggedness, header_size, Type::Signed32(), kMachInt16};
+      case kExternalUint16Array:
+        return {taggedness, header_size, Type::Unsigned32(), kMachUint16};
+      case kExternalInt32Array:
+        return {taggedness, header_size, Type::Signed32(), kMachInt32};
+      case kExternalUint32Array:
+        return {taggedness, header_size, Type::Unsigned32(), kMachUint32};
+      case kExternalFloat32Array:
+        return {taggedness, header_size, Type::Number(), kRepFloat32};
+      case kExternalFloat64Array:
+        return {taggedness, header_size, Type::Number(), kRepFloat64};
+    }
+    UNREACHABLE();
+    return {kUntaggedBase, 0, Type::None(), kMachNone};
+  }
+
+ private:
+  DISALLOW_COPY_AND_ASSIGN(Access);
+};


 // Interface for building simplified operators, which represent the
=======================================
--- /trunk/src/compiler.cc      Wed Aug 27 00:06:40 2014 UTC
+++ /trunk/src/compiler.cc      Fri Aug 29 00:04:38 2014 UTC
@@ -139,6 +139,7 @@
   if (script_->type()->value() == Script::TYPE_NATIVE) MarkAsNative();
   if (isolate_->debug()->is_active()) MarkAsDebug();
   if (FLAG_context_specialization) MarkAsContextSpecializing();
+  if (FLAG_turbo_types) MarkAsTypingEnabled();

   if (!shared_info_.is_null()) {
     DCHECK(strict_mode() == SLOPPY);
=======================================
--- /trunk/src/compiler.h       Thu Aug 28 09:24:16 2014 UTC
+++ /trunk/src/compiler.h       Fri Aug 29 00:04:38 2014 UTC
@@ -81,7 +81,8 @@
     kParseRestriction = 1 << 14,
     kSerializing = 1 << 15,
     kContextSpecializing = 1 << 16,
-    kInliningEnabled = 1 << 17
+    kInliningEnabled = 1 << 17,
+    kTypingEnabled = 1 << 18
   };

   CompilationInfo(Handle<JSFunction> closure, Zone* zone);
@@ -190,6 +191,10 @@
   void MarkAsInliningEnabled() { SetFlag(kInliningEnabled); }

   bool is_inlining_enabled() const { return GetFlag(kInliningEnabled); }
+
+  void MarkAsTypingEnabled() { SetFlag(kTypingEnabled); }
+
+  bool is_typing_enabled() const { return GetFlag(kTypingEnabled); }

   bool IsCodePreAgingActive() const {
     return FLAG_optimize_for_size && FLAG_age_code && !will_serialize() &&
=======================================
--- /trunk/src/objects-printer.cc       Wed Aug 27 00:06:40 2014 UTC
+++ /trunk/src/objects-printer.cc       Fri Aug 29 00:04:38 2014 UTC
@@ -751,7 +751,7 @@
 void JSTypedArray::JSTypedArrayPrint(OStream& os) {  // NOLINT
   HeapObject::PrintHeader(os, "JSTypedArray");
   os << " - map = " << reinterpret_cast<void*>(map()) << "\n";
-  os << " - buffer =" << Brief(buffer());
+  os << " - buffer = " << Brief(buffer());
   os << "\n - byte_offset = " << Brief(byte_offset());
   os << "\n - byte_length = " << Brief(byte_length());
   os << "\n - length = " << Brief(length());
=======================================
--- /trunk/src/version.cc       Thu Aug 28 15:38:17 2014 UTC
+++ /trunk/src/version.cc       Fri Aug 29 00:04:38 2014 UTC
@@ -34,7 +34,7 @@
 // system so their names cannot be changed without changing the scripts.
 #define MAJOR_VERSION     3
 #define MINOR_VERSION     29
-#define BUILD_NUMBER      27
+#define BUILD_NUMBER      29
 #define PATCH_LEVEL       0
 // Use 1 for candidates and 0 otherwise.
 // (Boolean macro values are not supported by all preprocessors.)
=======================================
--- /trunk/test/cctest/cctest.gyp       Thu Aug 28 15:38:17 2014 UTC
+++ /trunk/test/cctest/cctest.gyp       Fri Aug 29 00:04:38 2014 UTC
@@ -79,6 +79,7 @@
         'compiler/test-run-jsexceptions.cc',
         'compiler/test-run-jsops.cc',
         'compiler/test-run-machops.cc',
+        'compiler/test-run-properties.cc',
         'compiler/test-run-variables.cc',
         'compiler/test-schedule.cc',
         'compiler/test-scheduler.cc',
=======================================
--- /trunk/test/cctest/cctest.status    Wed Aug 27 00:06:40 2014 UTC
+++ /trunk/test/cctest/cctest.status    Fri Aug 29 00:04:38 2014 UTC
@@ -269,6 +269,9 @@
##############################################################################
 ['arch == arm', {

+ # TODO(mstarzinger): This fails on ARM hardware, but not in the simulator.
+  'test-run-properties/TypedArrayLoad': [SKIP],
+
   # BUG(355): Test crashes on ARM.
   'test-log/ProfLazyMode': [SKIP],

=======================================
--- /trunk/test/cctest/compiler/function-tester.h Thu Aug 28 09:24:16 2014 UTC +++ /trunk/test/cctest/compiler/function-tester.h Fri Aug 29 00:04:38 2014 UTC
@@ -32,7 +32,8 @@
         flags_(flags) {
     Compile(function);
const uint32_t supported_flags = CompilationInfo::kContextSpecializing |
-                                     CompilationInfo::kInliningEnabled;
+                                     CompilationInfo::kInliningEnabled |
+                                     CompilationInfo::kTypingEnabled;
     CHECK_EQ(0, flags_ & ~supported_flags);
   }

@@ -53,6 +54,9 @@
     if (flags_ & CompilationInfo::kInliningEnabled) {
       info.MarkAsInliningEnabled();
     }
+    if (flags_ & CompilationInfo::kTypingEnabled) {
+      info.MarkAsTypingEnabled();
+    }
     CHECK(Rewriter::Rewrite(&info));
     CHECK(Scope::Analyze(&info));
     CHECK_NE(NULL, info.scope());
=======================================
--- /trunk/test/cctest/compiler/test-simplified-lowering.cc Thu Aug 28 15:38:17 2014 UTC +++ /trunk/test/cctest/compiler/test-simplified-lowering.cc Fri Aug 29 00:04:38 2014 UTC
@@ -4,6 +4,7 @@

 #include <limits>

+#include "src/compiler/access-builder.h"
 #include "src/compiler/control-builders.h"
 #include "src/compiler/generic-node-inl.h"
 #include "src/compiler/graph-visualizer.h"
@@ -51,48 +52,6 @@
   Factory* factory() { return this->isolate()->factory(); }
   Heap* heap() { return this->isolate()->heap(); }
 };
-
-
-// TODO(dcarney): find a home for these functions.
-namespace {
-
-FieldAccess ForJSObjectMap() {
-  FieldAccess access = {kTaggedBase, JSObject::kMapOffset, Handle<Name>(),
-                        Type::Any(), kMachAnyTagged};
-  return access;
-}
-
-
-FieldAccess ForJSObjectProperties() {
-  FieldAccess access = {kTaggedBase, JSObject::kPropertiesOffset,
-                        Handle<Name>(), Type::Any(), kMachAnyTagged};
-  return access;
-}
-
-
-FieldAccess ForArrayBufferBackingStore() {
-  FieldAccess access = {
- kTaggedBase, JSArrayBuffer::kBackingStoreOffset, Handle<Name>(),
-      Type::UntaggedPtr(), kMachPtr,
-  };
-  return access;
-}
-
-
-ElementAccess ForFixedArrayElement() {
- ElementAccess access = {kTaggedBase, FixedArray::kHeaderSize, Type::Any(),
-                          kMachAnyTagged};
-  return access;
-}
-
-
-ElementAccess ForBackingStoreElement(MachineType rep) {
-  ElementAccess access = {kUntaggedBase,
-                          kNonHeapObjectHeaderSize - kHeapObjectTag,
-                          Type::Any(), rep};
-  return access;
-}
-}


 #ifndef V8_TARGET_ARCH_ARM64
@@ -166,7 +125,7 @@

 TEST(RunLoadMap) {
   SimplifiedLoweringTester<Object*> t(kMachAnyTagged);
-  FieldAccess access = ForJSObjectMap();
+  FieldAccess access = AccessBuilder::ForMap();
   Node* load = t.LoadField(access, t.Parameter(0));
   t.Return(load);

@@ -184,7 +143,7 @@

 TEST(RunStoreMap) {
   SimplifiedLoweringTester<int32_t> t(kMachAnyTagged, kMachAnyTagged);
-  FieldAccess access = ForJSObjectMap();
+  FieldAccess access = AccessBuilder::ForMap();
   t.StoreField(access, t.Parameter(1), t.Parameter(0));
   t.Return(t.jsgraph.TrueConstant());

@@ -204,7 +163,7 @@

 TEST(RunLoadProperties) {
   SimplifiedLoweringTester<Object*> t(kMachAnyTagged);
-  FieldAccess access = ForJSObjectProperties();
+  FieldAccess access = AccessBuilder::ForJSObjectProperties();
   Node* load = t.LoadField(access, t.Parameter(0));
   t.Return(load);

@@ -222,7 +181,7 @@

 TEST(RunLoadStoreMap) {
   SimplifiedLoweringTester<Object*> t(kMachAnyTagged, kMachAnyTagged);
-  FieldAccess access = ForJSObjectMap();
+  FieldAccess access = AccessBuilder::ForMap();
   Node* load = t.LoadField(access, t.Parameter(0));
   t.StoreField(access, t.Parameter(1), load);
   t.Return(load);
@@ -245,7 +204,7 @@

 TEST(RunLoadStoreFixedArrayIndex) {
   SimplifiedLoweringTester<Object*> t(kMachAnyTagged);
-  ElementAccess access = ForFixedArrayElement();
+  ElementAccess access = AccessBuilder::ForFixedArrayElement();
   Node* load = t.LoadElement(access, t.Parameter(0), t.Int32Constant(0));
   t.StoreElement(access, t.Parameter(0), t.Int32Constant(1), load);
   t.Return(load);
@@ -270,9 +229,10 @@
 TEST(RunLoadStoreArrayBuffer) {
   SimplifiedLoweringTester<Object*> t(kMachAnyTagged);
   const int index = 12;
-  ElementAccess buffer_access = ForBackingStoreElement(kMachInt8);
-  Node* backing_store =
-      t.LoadField(ForArrayBufferBackingStore(), t.Parameter(0));
+  ElementAccess buffer_access =
+      AccessBuilder::ForBackingStoreElement(kMachInt8);
+  Node* backing_store = t.LoadField(
+      AccessBuilder::ForJSArrayBufferBackingStore(), t.Parameter(0));
   Node* load =
       t.LoadElement(buffer_access, backing_store, t.Int32Constant(index));
   t.StoreElement(buffer_access, backing_store, t.Int32Constant(index + 1),
=======================================
--- /trunk/tools/gyp/v8.gyp     Thu Aug 28 07:03:22 2014 UTC
+++ /trunk/tools/gyp/v8.gyp     Fri Aug 29 00:04:38 2014 UTC
@@ -342,6 +342,7 @@
         '../../src/codegen.h',
         '../../src/compilation-cache.cc',
         '../../src/compilation-cache.h',
+        '../../src/compiler/access-builder.h',
         '../../src/compiler/ast-graph-builder.cc',
         '../../src/compiler/ast-graph-builder.h',
         '../../src/compiler/change-lowering.cc',
=======================================
--- /trunk/tools/run_benchmarks.py      Mon Aug 25 19:57:56 2014 UTC
+++ /trunk/tools/run_benchmarks.py      Fri Aug 29 00:04:38 2014 UTC
@@ -92,6 +92,7 @@
 """

 import json
+import math
 import optparse
 import os
 import re
@@ -116,6 +117,16 @@
 GENERIC_RESULTS_RE = re.compile(
     r"^Trace\(([^\)]+)\), Result\(([^\)]+)\), StdDev\(([^\)]+)\)$")

+
+def GeometricMean(values):
+  """Returns the geometric mean of a list of values.
+
+  The mean is calculated using log to avoid overflow.
+  """
+  values = map(float, values)
+  return str(math.exp(sum(map(math.log, values)) / len(values)))
+
+
 class Results(object):
   """Place holder for result traces."""
   def __init__(self, traces=None, errors=None):
@@ -160,6 +171,7 @@
     self.results_regexp = None
     self.stddev_regexp = None
     self.units = "score"
+    self.total = False


 class Graph(Node):
@@ -187,6 +199,7 @@
     self.run_count = suite.get("run_count", parent.run_count)
     self.run_count = suite.get("run_count_%s" % arch, self.run_count)
     self.units = suite.get("units", parent.units)
+    self.total = suite.get("total", parent.total)

     # A regular expression for results. If the parent graph provides a
     # regexp and the current suite has none, a string place holder for the
@@ -276,8 +289,29 @@
     for stdout in runner():
       for trace in self._children:
         trace.ConsumeOutput(stdout)
- return reduce(lambda r, t: r + t.GetResults(), self._children, Results()) + res = reduce(lambda r, t: r + t.GetResults(), self._children, Results())

+    if not res.traces or not self.total:
+      return res
+
+    # Assume all traces have the same structure.
+    if len(set(map(lambda t: len(t["results"]), res.traces))) != 1:
+      res.errors.append("Not all traces have the same number of results.")
+      return res
+
+    # Calculate the geometric means for all traces. Above we made sure that
+ # there is at least one trace and that the number of results is the same
+    # for each trace.
+    n_results = len(res.traces[0]["results"])
+    total_results = [GeometricMean(t["results"][i] for t in res.traces)
+                     for i in range(0, n_results)]
+    res.traces.append({
+      "graphs": self.graphs + ["Total"],
+      "units": res.traces[0]["units"],
+      "results": total_results,
+      "stddev": "",
+    })
+    return res

 class RunnableTrace(Trace, Runnable):
   """Represents a runnable benchmark suite definition that is a leaf."""
=======================================
--- /trunk/tools/unittests/run_benchmarks_test.py Mon Aug 25 19:57:56 2014 UTC +++ /trunk/tools/unittests/run_benchmarks_test.py Fri Aug 29 00:04:38 2014 UTC
@@ -293,6 +293,35 @@
     self._VerifyErrors([])
     self._VerifyMock(path.join("out", "Release", "d7"), "--flag", "run.js")

+  def testBuildbotWithTotal(self):
+    test_input = dict(V8_JSON)
+    test_input["total"] = True
+    self._WriteTestInput(test_input)
+    self._MockCommand(["."], ["Richards: 1.234\nDeltaBlue: 10657567\n"])
+    self.assertEquals(0, self._CallMain("--buildbot"))
+    self._VerifyResults("test", "score", [
+      {"name": "Richards", "results": ["1.234"], "stddev": ""},
+      {"name": "DeltaBlue", "results": ["10657567"], "stddev": ""},
+      {"name": "Total", "results": ["3626.49109719"], "stddev": ""},
+    ])
+    self._VerifyErrors([])
+    self._VerifyMock(path.join("out", "Release", "d7"), "--flag", "run.js")
+
+  def testBuildbotWithTotalAndErrors(self):
+    test_input = dict(V8_JSON)
+    test_input["total"] = True
+    self._WriteTestInput(test_input)
+ self._MockCommand(["."], ["x\nRichaards: 1.234\nDeltaBlue: 10657567\ny\n"])
+    self.assertEquals(1, self._CallMain("--buildbot"))
+    self._VerifyResults("test", "score", [
+      {"name": "Richards", "results": [], "stddev": ""},
+      {"name": "DeltaBlue", "results": ["10657567"], "stddev": ""},
+    ])
+    self._VerifyErrors(
+ ["Regexp \"^Richards: (.+)$\" didn't match for benchmark Richards.",
+         "Not all traces have the same number of results."])
+    self._VerifyMock(path.join("out", "Release", "d7"), "--flag", "run.js")
+
   def testRegexpNoMatch(self):
     self._WriteTestInput(V8_JSON)
self._MockCommand(["."], ["x\nRichaards: 1.234\nDeltaBlue: 10657567\ny\n"])

--
--
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/d/optout.

Reply via email to