Replace our homegrown ARRAY_SIZE() with Chrome's arraysize().
authorbmeurer@chromium.org <bmeurer@chromium.org>
Tue, 26 Aug 2014 09:19:24 +0000 (09:19 +0000)
committerbmeurer@chromium.org <bmeurer@chromium.org>
Tue, 26 Aug 2014 09:19:24 +0000 (09:19 +0000)
Our own ARRAY_SIZE() was pretty bad at error checking. If you use
arrasize() in a wrong way, the compiler will issue an error instead of
silently doing the wrong thing. The previous ARRAY_SIZE() macro is still
available as ARRAYSIZE_UNSAFE() similar to Chrome.

R=yangguo@chromium.org

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

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

72 files changed:
src/api.cc
src/arm/code-stubs-arm.cc
src/arm64/assembler-arm64.cc
src/arm64/code-stubs-arm64.cc
src/arm64/instrument-arm64.cc
src/arm64/simulator-arm64.cc
src/ast.cc
src/base/logging.cc
src/base/macros.h
src/bootstrapper.cc
src/cached-powers.cc
src/code-stubs.cc
src/compiler/arm/instruction-selector-arm.cc
src/compiler/arm64/instruction-selector-arm64.cc
src/compiler/graph-builder.h
src/compiler/graph.h
src/compiler/ia32/instruction-selector-ia32.cc
src/compiler/instruction-selector.cc
src/compiler/js-generic-lowering.cc
src/compiler/x64/instruction-selector-x64.cc
src/conversions.cc
src/debug.cc
src/deoptimizer.h
src/execution.cc
src/factory.cc
src/full-codegen.cc
src/global-handles.cc
src/heap/heap.cc
src/hydrogen.cc
src/ia32/code-stubs-ia32.cc
src/isolate.cc
src/jsregexp.cc
src/lithium-codegen.cc
src/messages.cc
src/mips/code-stubs-mips.cc
src/mips64/code-stubs-mips64.cc
src/mksnapshot.cc
src/objects.cc
src/parser.cc
src/runtime.cc
src/serialize.cc
src/strtod.cc
src/types.cc
src/vector.h
src/x64/code-stubs-x64.cc
src/x87/code-stubs-x87.cc
test/base-unittests/platform/platform-unittest.cc
test/cctest/compiler/call-tester.h
test/cctest/compiler/test-branch-combine.cc
test/cctest/compiler/test-instruction.cc
test/cctest/compiler/test-js-constant-cache.cc
test/cctest/compiler/test-js-typed-lowering.cc
test/cctest/compiler/test-node-cache.cc
test/cctest/compiler/test-phi-reducer.cc
test/cctest/compiler/test-representation-change.cc
test/cctest/compiler/test-run-machops.cc
test/cctest/compiler/test-simplified-lowering.cc
test/cctest/compiler/test-structured-ifbuilder-fuzzer.cc
test/cctest/compiler/test-structured-machine-assembler.cc
test/cctest/compiler/value-helper.h
test/cctest/test-api.cc
test/cctest/test-checks.cc
test/cctest/test-compiler.cc
test/cctest/test-cpu-profiler.cc
test/cctest/test-date.cc
test/cctest/test-debug.cc
test/cctest/test-heap-profiler.cc
test/cctest/test-mark-compact.cc
test/cctest/test-object-observe.cc
test/cctest/test-parsing.cc
test/cctest/test-random-number-generator.cc
testing/gtest-support.h

index 45efd68..041d86b 100644 (file)
@@ -2065,7 +2065,7 @@ MUST_USE_RESULT static i::MaybeHandle<i::Object> CallV8HeapFunction(
   i::Handle<i::Object> argv[] = { data };
   return CallV8HeapFunction(name,
                             i::Isolate::Current()->js_builtins_object(),
-                            ARRAY_SIZE(argv),
+                            arraysize(argv),
                             argv);
 }
 
@@ -2967,7 +2967,7 @@ bool Value::Equals(Handle<Value> that) const {
   EXCEPTION_PREAMBLE(isolate);
   i::Handle<i::Object> result;
   has_pending_exception = !CallV8HeapFunction(
-      "EQUALS", obj, ARRAY_SIZE(args), args).ToHandle(&result);
+      "EQUALS", obj, arraysize(args), args).ToHandle(&result);
   EXCEPTION_BAILOUT_CHECK(isolate, false);
   return *result == i::Smi::FromInt(i::EQUAL);
 }
@@ -3196,7 +3196,7 @@ Local<Value> v8::Object::GetOwnPropertyDescriptor(Local<String> key) {
   has_pending_exception = !CallV8HeapFunction(
       "ObjectGetOwnPropertyDescriptor",
       isolate->factory()->undefined_value(),
-      ARRAY_SIZE(args),
+      arraysize(args),
       args).ToHandle(&result);
   EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>());
   return Utils::ToLocal(result);
@@ -5735,7 +5735,7 @@ static i::Handle<i::String> RegExpFlagsToString(RegExp::Flags flags) {
   if ((flags & RegExp::kGlobal) != 0) flags_buf[num_flags++] = 'g';
   if ((flags & RegExp::kMultiline) != 0) flags_buf[num_flags++] = 'm';
   if ((flags & RegExp::kIgnoreCase) != 0) flags_buf[num_flags++] = 'i';
-  DCHECK(num_flags <= static_cast<int>(ARRAY_SIZE(flags_buf)));
+  DCHECK(num_flags <= static_cast<int>(arraysize(flags_buf)));
   return isolate->factory()->InternalizeOneByteString(
       i::Vector<const uint8_t>(flags_buf, num_flags));
 }
@@ -5841,7 +5841,7 @@ bool Value::IsPromise() const {
       isolate,
       isolate->is_promise(),
       isolate->factory()->undefined_value(),
-      ARRAY_SIZE(argv), argv,
+      arraysize(argv), argv,
       false).ToHandle(&b);
   EXCEPTION_BAILOUT_CHECK(isolate, false);
   return b->BooleanValue();
@@ -5882,7 +5882,7 @@ void Promise::Resolver::Resolve(Handle<Value> value) {
       isolate,
       isolate->promise_resolve(),
       isolate->factory()->undefined_value(),
-      ARRAY_SIZE(argv), argv,
+      arraysize(argv), argv,
       false).is_null();
   EXCEPTION_BAILOUT_CHECK(isolate, /* void */ ;);
 }
@@ -5899,7 +5899,7 @@ void Promise::Resolver::Reject(Handle<Value> value) {
       isolate,
       isolate->promise_reject(),
       isolate->factory()->undefined_value(),
-      ARRAY_SIZE(argv), argv,
+      arraysize(argv), argv,
       false).is_null();
   EXCEPTION_BAILOUT_CHECK(isolate, /* void */ ;);
 }
@@ -5917,7 +5917,7 @@ Local<Promise> Promise::Chain(Handle<Function> handler) {
       isolate,
       isolate->promise_chain(),
       promise,
-      ARRAY_SIZE(argv), argv,
+      arraysize(argv), argv,
       false).ToHandle(&result);
   EXCEPTION_BAILOUT_CHECK(isolate, Local<Promise>());
   return Local<Promise>::Cast(Utils::ToLocal(result));
@@ -5936,7 +5936,7 @@ Local<Promise> Promise::Catch(Handle<Function> handler) {
       isolate,
       isolate->promise_catch(),
       promise,
-      ARRAY_SIZE(argv), argv,
+      arraysize(argv), argv,
       false).ToHandle(&result);
   EXCEPTION_BAILOUT_CHECK(isolate, Local<Promise>());
   return Local<Promise>::Cast(Utils::ToLocal(result));
@@ -5955,7 +5955,7 @@ Local<Promise> Promise::Then(Handle<Function> handler) {
       isolate,
       isolate->promise_then(),
       promise,
-      ARRAY_SIZE(argv), argv,
+      arraysize(argv), argv,
       false).ToHandle(&result);
   EXCEPTION_BAILOUT_CHECK(isolate, Local<Promise>());
   return Local<Promise>::Cast(Utils::ToLocal(result));
@@ -7575,7 +7575,7 @@ void HandleScopeImplementer::IterateThis(ObjectVisitor* v) {
   }
 
   List<Context*>* context_lists[2] = { &saved_contexts_, &entered_contexts_};
-  for (unsigned i = 0; i < ARRAY_SIZE(context_lists); i++) {
+  for (unsigned i = 0; i < arraysize(context_lists); i++) {
     if (context_lists[i]->is_empty()) continue;
     Object** start = reinterpret_cast<Object**>(&context_lists[i]->first());
     v->VisitPointers(start, start + context_lists[i]->length());
index d96560f..0d6ec18 100644 (file)
@@ -23,7 +23,7 @@ void FastNewClosureStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   Register registers[] = { cp, r2 };
   descriptor->Initialize(
-      MajorKey(), ARRAY_SIZE(registers), registers,
+      MajorKey(), arraysize(registers), registers,
       Runtime::FunctionForId(Runtime::kNewClosureFromStubFailure)->entry);
 }
 
@@ -31,14 +31,14 @@ void FastNewClosureStub::InitializeInterfaceDescriptor(
 void FastNewContextStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   Register registers[] = { cp, r1 };
-  descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers);
+  descriptor->Initialize(MajorKey(), arraysize(registers), registers);
 }
 
 
 void ToNumberStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   Register registers[] = { cp, r0 };
-  descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers);
+  descriptor->Initialize(MajorKey(), arraysize(registers), registers);
 }
 
 
@@ -46,7 +46,7 @@ void NumberToStringStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   Register registers[] = { cp, r0 };
   descriptor->Initialize(
-      MajorKey(), ARRAY_SIZE(registers), registers,
+      MajorKey(), arraysize(registers), registers,
       Runtime::FunctionForId(Runtime::kNumberToStringRT)->entry);
 }
 
@@ -60,7 +60,7 @@ void FastCloneShallowArrayStub::InitializeInterfaceDescriptor(
     Representation::Smi(),
     Representation::Tagged() };
   descriptor->Initialize(
-      MajorKey(), ARRAY_SIZE(registers), registers,
+      MajorKey(), arraysize(registers), registers,
       Runtime::FunctionForId(Runtime::kCreateArrayLiteralStubBailout)->entry,
       representations);
 }
@@ -70,7 +70,7 @@ void FastCloneShallowObjectStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   Register registers[] = { cp, r3, r2, r1, r0 };
   descriptor->Initialize(
-      MajorKey(), ARRAY_SIZE(registers), registers,
+      MajorKey(), arraysize(registers), registers,
       Runtime::FunctionForId(Runtime::kCreateObjectLiteral)->entry);
 }
 
@@ -78,7 +78,7 @@ void FastCloneShallowObjectStub::InitializeInterfaceDescriptor(
 void CreateAllocationSiteStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   Register registers[] = { cp, r2, r3 };
-  descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers);
+  descriptor->Initialize(MajorKey(), arraysize(registers), registers);
 }
 
 
@@ -86,7 +86,7 @@ void CallFunctionStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   // r1  function    the function to call
   Register registers[] = {cp, r1};
-  descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers);
+  descriptor->Initialize(MajorKey(), arraysize(registers), registers);
 }
 
 
@@ -100,7 +100,7 @@ void CallConstructStub::InitializeInterfaceDescriptor(
   // TODO(turbofan): So far we don't gather type feedback and hence skip the
   // slot parameter, but ArrayConstructStub needs the vector to be undefined.
   Register registers[] = {cp, r0, r1, r2};
-  descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers);
+  descriptor->Initialize(MajorKey(), arraysize(registers), registers);
 }
 
 
@@ -108,7 +108,7 @@ void RegExpConstructResultStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   Register registers[] = { cp, r2, r1, r0 };
   descriptor->Initialize(
-      MajorKey(), ARRAY_SIZE(registers), registers,
+      MajorKey(), arraysize(registers), registers,
       Runtime::FunctionForId(Runtime::kRegExpConstructResult)->entry);
 }
 
@@ -118,7 +118,7 @@ void TransitionElementsKindStub::InitializeInterfaceDescriptor(
   Register registers[] = { cp, r0, r1 };
   Address entry =
       Runtime::FunctionForId(Runtime::kTransitionElementsKind)->entry;
-  descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers,
+  descriptor->Initialize(MajorKey(), arraysize(registers), registers,
                          FUNCTION_ADDR(entry));
 }
 
@@ -126,7 +126,7 @@ void TransitionElementsKindStub::InitializeInterfaceDescriptor(
 void CompareNilICStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   Register registers[] = { cp, r0 };
-  descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers,
+  descriptor->Initialize(MajorKey(), arraysize(registers), registers,
                          FUNCTION_ADDR(CompareNilIC_Miss));
   descriptor->SetMissHandler(
       ExternalReference(IC_Utility(IC::kCompareNilIC_Miss), isolate()));
@@ -149,7 +149,7 @@ static void InitializeArrayConstructorDescriptor(
 
   if (constant_stack_parameter_count == 0) {
     Register registers[] = { cp, r1, r2 };
-    descriptor->Initialize(major, ARRAY_SIZE(registers), registers,
+    descriptor->Initialize(major, arraysize(registers), registers,
                            deopt_handler, NULL, constant_stack_parameter_count,
                            JS_FUNCTION_STUB_MODE);
   } else {
@@ -160,7 +160,7 @@ static void InitializeArrayConstructorDescriptor(
         Representation::Tagged(),
         Representation::Tagged(),
         Representation::Integer32() };
-    descriptor->Initialize(major, ARRAY_SIZE(registers), registers, r0,
+    descriptor->Initialize(major, arraysize(registers), registers, r0,
                            deopt_handler, representations,
                            constant_stack_parameter_count,
                            JS_FUNCTION_STUB_MODE, PASS_ARGUMENTS);
@@ -180,7 +180,7 @@ static void InitializeInternalArrayConstructorDescriptor(
 
   if (constant_stack_parameter_count == 0) {
     Register registers[] = { cp, r1 };
-    descriptor->Initialize(major, ARRAY_SIZE(registers), registers,
+    descriptor->Initialize(major, arraysize(registers), registers,
                            deopt_handler, NULL, constant_stack_parameter_count,
                            JS_FUNCTION_STUB_MODE);
   } else {
@@ -190,7 +190,7 @@ static void InitializeInternalArrayConstructorDescriptor(
         Representation::Tagged(),
         Representation::Tagged(),
         Representation::Integer32() };
-    descriptor->Initialize(major, ARRAY_SIZE(registers), registers, r0,
+    descriptor->Initialize(major, arraysize(registers), registers, r0,
                            deopt_handler, representations,
                            constant_stack_parameter_count,
                            JS_FUNCTION_STUB_MODE, PASS_ARGUMENTS);
@@ -219,7 +219,7 @@ void ArrayNArgumentsConstructorStub::InitializeInterfaceDescriptor(
 void ToBooleanStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   Register registers[] = { cp, r0 };
-  descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers,
+  descriptor->Initialize(MajorKey(), arraysize(registers), registers,
                          FUNCTION_ADDR(ToBooleanIC_Miss));
   descriptor->SetMissHandler(
       ExternalReference(IC_Utility(IC::kToBooleanIC_Miss), isolate()));
@@ -247,7 +247,7 @@ void InternalArrayNArgumentsConstructorStub::InitializeInterfaceDescriptor(
 void BinaryOpICStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   Register registers[] = { cp, r1, r0 };
-  descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers,
+  descriptor->Initialize(MajorKey(), arraysize(registers), registers,
                          FUNCTION_ADDR(BinaryOpIC_Miss));
   descriptor->SetMissHandler(
       ExternalReference(IC_Utility(IC::kBinaryOpIC_Miss), isolate()));
@@ -257,7 +257,7 @@ void BinaryOpICStub::InitializeInterfaceDescriptor(
 void BinaryOpWithAllocationSiteStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   Register registers[] = { cp, r2, r1, r0 };
-  descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers,
+  descriptor->Initialize(MajorKey(), arraysize(registers), registers,
                          FUNCTION_ADDR(BinaryOpIC_MissWithAllocationSite));
 }
 
@@ -265,7 +265,7 @@ void BinaryOpWithAllocationSiteStub::InitializeInterfaceDescriptor(
 void StringAddStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   Register registers[] = { cp, r1, r0 };
-  descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers,
+  descriptor->Initialize(MajorKey(), arraysize(registers), registers,
                          Runtime::FunctionForId(Runtime::kStringAdd)->entry);
 }
 
@@ -291,7 +291,7 @@ void CallDescriptors::InitializeForIsolate(Isolate* isolate) {
         Representation::Integer32(),  // actual number of arguments
         Representation::Integer32(),  // expected number of arguments
     };
-    descriptor->Initialize(ARRAY_SIZE(registers), registers,
+    descriptor->Initialize(arraysize(registers), registers,
                            representations, &default_descriptor);
   }
   {
@@ -304,7 +304,7 @@ void CallDescriptors::InitializeForIsolate(Isolate* isolate) {
         Representation::Tagged(),     // context
         Representation::Tagged(),     // key
     };
-    descriptor->Initialize(ARRAY_SIZE(registers), registers,
+    descriptor->Initialize(arraysize(registers), registers,
                            representations, &noInlineDescriptor);
   }
   {
@@ -317,7 +317,7 @@ void CallDescriptors::InitializeForIsolate(Isolate* isolate) {
         Representation::Tagged(),     // context
         Representation::Tagged(),     // name
     };
-    descriptor->Initialize(ARRAY_SIZE(registers), registers,
+    descriptor->Initialize(arraysize(registers), registers,
                            representations, &noInlineDescriptor);
   }
   {
@@ -330,7 +330,7 @@ void CallDescriptors::InitializeForIsolate(Isolate* isolate) {
         Representation::Tagged(),  // context
         Representation::Tagged(),  // receiver
     };
-    descriptor->Initialize(ARRAY_SIZE(registers), registers,
+    descriptor->Initialize(arraysize(registers), registers,
                            representations, &default_descriptor);
   }
   {
@@ -349,7 +349,7 @@ void CallDescriptors::InitializeForIsolate(Isolate* isolate) {
         Representation::Tagged(),    // holder
         Representation::External(),  // api_function_address
     };
-    descriptor->Initialize(ARRAY_SIZE(registers), registers,
+    descriptor->Initialize(arraysize(registers), registers,
                            representations, &default_descriptor);
   }
 }
index 7f86e14..9d804db 100644 (file)
@@ -227,7 +227,7 @@ bool AreAliased(const CPURegister& reg1, const CPURegister& reg2,
 
   const CPURegister regs[] = {reg1, reg2, reg3, reg4, reg5, reg6, reg7, reg8};
 
-  for (unsigned i = 0; i < ARRAY_SIZE(regs); i++) {
+  for (unsigned i = 0; i < arraysize(regs); i++) {
     if (regs[i].IsRegister()) {
       number_of_valid_regs++;
       unique_regs |= regs[i].Bit();
@@ -2664,7 +2664,7 @@ bool Assembler::IsImmLogical(uint64_t value,
   int multiplier_idx = CountLeadingZeros(d, kXRegSizeInBits) - 57;
   // Ensure that the index to the multipliers array is within bounds.
   DCHECK((multiplier_idx >= 0) &&
-         (static_cast<size_t>(multiplier_idx) < ARRAY_SIZE(multipliers)));
+         (static_cast<size_t>(multiplier_idx) < arraysize(multipliers)));
   uint64_t multiplier = multipliers[multiplier_idx];
   uint64_t candidate = (b - a) * multiplier;
 
index c00b572..b57748a 100644 (file)
@@ -24,7 +24,7 @@ void FastNewClosureStub::InitializeInterfaceDescriptor(
   // x2: function info
   Register registers[] = { cp, x2 };
   descriptor->Initialize(
-      MajorKey(), ARRAY_SIZE(registers), registers,
+      MajorKey(), arraysize(registers), registers,
       Runtime::FunctionForId(Runtime::kNewClosureFromStubFailure)->entry);
 }
 
@@ -34,7 +34,7 @@ void FastNewContextStub::InitializeInterfaceDescriptor(
   // cp: context
   // x1: function
   Register registers[] = { cp, x1 };
-  descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers);
+  descriptor->Initialize(MajorKey(), arraysize(registers), registers);
 }
 
 
@@ -43,7 +43,7 @@ void ToNumberStub::InitializeInterfaceDescriptor(
   // cp: context
   // x0: value
   Register registers[] = { cp, x0 };
-  descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers);
+  descriptor->Initialize(MajorKey(), arraysize(registers), registers);
 }
 
 
@@ -53,7 +53,7 @@ void NumberToStringStub::InitializeInterfaceDescriptor(
   // x0: value
   Register registers[] = { cp, x0 };
   descriptor->Initialize(
-      MajorKey(), ARRAY_SIZE(registers), registers,
+      MajorKey(), arraysize(registers), registers,
       Runtime::FunctionForId(Runtime::kNumberToStringRT)->entry);
 }
 
@@ -71,7 +71,7 @@ void FastCloneShallowArrayStub::InitializeInterfaceDescriptor(
     Representation::Smi(),
     Representation::Tagged() };
   descriptor->Initialize(
-      MajorKey(), ARRAY_SIZE(registers), registers,
+      MajorKey(), arraysize(registers), registers,
       Runtime::FunctionForId(Runtime::kCreateArrayLiteralStubBailout)->entry,
       representations);
 }
@@ -86,7 +86,7 @@ void FastCloneShallowObjectStub::InitializeInterfaceDescriptor(
   // x0: object literal flags
   Register registers[] = { cp, x3, x2, x1, x0 };
   descriptor->Initialize(
-      MajorKey(), ARRAY_SIZE(registers), registers,
+      MajorKey(), arraysize(registers), registers,
       Runtime::FunctionForId(Runtime::kCreateObjectLiteral)->entry);
 }
 
@@ -97,7 +97,7 @@ void CreateAllocationSiteStub::InitializeInterfaceDescriptor(
   // x2: feedback vector
   // x3: call feedback slot
   Register registers[] = { cp, x2, x3 };
-  descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers);
+  descriptor->Initialize(MajorKey(), arraysize(registers), registers);
 }
 
 
@@ -105,7 +105,7 @@ void CallFunctionStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   // x1  function    the function to call
   Register registers[] = {cp, x1};
-  descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers);
+  descriptor->Initialize(MajorKey(), arraysize(registers), registers);
 }
 
 
@@ -118,7 +118,7 @@ void CallConstructStub::InitializeInterfaceDescriptor(
   // TODO(turbofan): So far we don't gather type feedback and hence skip the
   // slot parameter, but ArrayConstructStub needs the vector to be undefined.
   Register registers[] = {cp, x0, x1, x2};
-  descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers);
+  descriptor->Initialize(MajorKey(), arraysize(registers), registers);
 }
 
 
@@ -130,7 +130,7 @@ void RegExpConstructResultStub::InitializeInterfaceDescriptor(
   // x0: string
   Register registers[] = { cp, x2, x1, x0 };
   descriptor->Initialize(
-      MajorKey(), ARRAY_SIZE(registers), registers,
+      MajorKey(), arraysize(registers), registers,
       Runtime::FunctionForId(Runtime::kRegExpConstructResult)->entry);
 }
 
@@ -143,7 +143,7 @@ void TransitionElementsKindStub::InitializeInterfaceDescriptor(
   Register registers[] = { cp, x0, x1 };
   Address entry =
       Runtime::FunctionForId(Runtime::kTransitionElementsKind)->entry;
-  descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers,
+  descriptor->Initialize(MajorKey(), arraysize(registers), registers,
                          FUNCTION_ADDR(entry));
 }
 
@@ -153,7 +153,7 @@ void CompareNilICStub::InitializeInterfaceDescriptor(
   // cp: context
   // x0: value to compare
   Register registers[] = { cp, x0 };
-  descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers,
+  descriptor->Initialize(MajorKey(), arraysize(registers), registers,
                          FUNCTION_ADDR(CompareNilIC_Miss));
   descriptor->SetMissHandler(
       ExternalReference(IC_Utility(IC::kCompareNilIC_Miss), isolate()));
@@ -175,7 +175,7 @@ static void InitializeArrayConstructorDescriptor(
 
   if (constant_stack_parameter_count == 0) {
     Register registers[] = { cp, x1, x2 };
-    descriptor->Initialize(major, ARRAY_SIZE(registers), registers,
+    descriptor->Initialize(major, arraysize(registers), registers,
                            deopt_handler, NULL, constant_stack_parameter_count,
                            JS_FUNCTION_STUB_MODE);
   } else {
@@ -186,7 +186,7 @@ static void InitializeArrayConstructorDescriptor(
         Representation::Tagged(),
         Representation::Tagged(),
         Representation::Integer32() };
-    descriptor->Initialize(major, ARRAY_SIZE(registers), registers, x0,
+    descriptor->Initialize(major, arraysize(registers), registers, x0,
                            deopt_handler, representations,
                            constant_stack_parameter_count,
                            JS_FUNCTION_STUB_MODE, PASS_ARGUMENTS);
@@ -223,7 +223,7 @@ static void InitializeInternalArrayConstructorDescriptor(
 
   if (constant_stack_parameter_count == 0) {
     Register registers[] = { cp, x1 };
-    descriptor->Initialize(major, ARRAY_SIZE(registers), registers,
+    descriptor->Initialize(major, arraysize(registers), registers,
                            deopt_handler, NULL, constant_stack_parameter_count,
                            JS_FUNCTION_STUB_MODE);
   } else {
@@ -233,7 +233,7 @@ static void InitializeInternalArrayConstructorDescriptor(
         Representation::Tagged(),
         Representation::Tagged(),
         Representation::Integer32() };
-    descriptor->Initialize(major, ARRAY_SIZE(registers), registers, x0,
+    descriptor->Initialize(major, arraysize(registers), registers, x0,
                            deopt_handler, representations,
                            constant_stack_parameter_count,
                            JS_FUNCTION_STUB_MODE, PASS_ARGUMENTS);
@@ -264,7 +264,7 @@ void ToBooleanStub::InitializeInterfaceDescriptor(
   // cp: context
   // x0: value
   Register registers[] = { cp, x0 };
-  descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers,
+  descriptor->Initialize(MajorKey(), arraysize(registers), registers,
                          FUNCTION_ADDR(ToBooleanIC_Miss));
   descriptor->SetMissHandler(
       ExternalReference(IC_Utility(IC::kToBooleanIC_Miss), isolate()));
@@ -277,7 +277,7 @@ void BinaryOpICStub::InitializeInterfaceDescriptor(
   // x1: left operand
   // x0: right operand
   Register registers[] = { cp, x1, x0 };
-  descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers,
+  descriptor->Initialize(MajorKey(), arraysize(registers), registers,
                          FUNCTION_ADDR(BinaryOpIC_Miss));
   descriptor->SetMissHandler(
       ExternalReference(IC_Utility(IC::kBinaryOpIC_Miss), isolate()));
@@ -291,7 +291,7 @@ void BinaryOpWithAllocationSiteStub::InitializeInterfaceDescriptor(
   // x1: left operand
   // x0: right operand
   Register registers[] = { cp, x2, x1, x0 };
-  descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers,
+  descriptor->Initialize(MajorKey(), arraysize(registers), registers,
                          FUNCTION_ADDR(BinaryOpIC_MissWithAllocationSite));
 }
 
@@ -302,7 +302,7 @@ void StringAddStub::InitializeInterfaceDescriptor(
   // x1: left operand
   // x0: right operand
   Register registers[] = { cp, x1, x0 };
-  descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers,
+  descriptor->Initialize(MajorKey(), arraysize(registers), registers,
                          Runtime::FunctionForId(Runtime::kStringAdd)->entry);
 }
 
@@ -328,7 +328,7 @@ void CallDescriptors::InitializeForIsolate(Isolate* isolate) {
         Representation::Integer32(),  // actual number of arguments
         Representation::Integer32(),  // expected number of arguments
     };
-    descriptor->Initialize(ARRAY_SIZE(registers), registers,
+    descriptor->Initialize(arraysize(registers), registers,
                            representations, &default_descriptor);
   }
   {
@@ -341,7 +341,7 @@ void CallDescriptors::InitializeForIsolate(Isolate* isolate) {
         Representation::Tagged(),     // context
         Representation::Tagged(),     // key
     };
-    descriptor->Initialize(ARRAY_SIZE(registers), registers,
+    descriptor->Initialize(arraysize(registers), registers,
                            representations, &noInlineDescriptor);
   }
   {
@@ -354,7 +354,7 @@ void CallDescriptors::InitializeForIsolate(Isolate* isolate) {
         Representation::Tagged(),     // context
         Representation::Tagged(),     // name
     };
-    descriptor->Initialize(ARRAY_SIZE(registers), registers,
+    descriptor->Initialize(arraysize(registers), registers,
                            representations, &noInlineDescriptor);
   }
   {
@@ -367,7 +367,7 @@ void CallDescriptors::InitializeForIsolate(Isolate* isolate) {
         Representation::Tagged(),  // context
         Representation::Tagged(),  // receiver
     };
-    descriptor->Initialize(ARRAY_SIZE(registers), registers,
+    descriptor->Initialize(arraysize(registers), registers,
                            representations, &default_descriptor);
   }
   {
@@ -386,7 +386,7 @@ void CallDescriptors::InitializeForIsolate(Isolate* isolate) {
         Representation::Tagged(),    // holder
         Representation::External(),  // api_function_address
     };
-    descriptor->Initialize(ARRAY_SIZE(registers), registers,
+    descriptor->Initialize(arraysize(registers), registers,
                            representations, &default_descriptor);
   }
 }
index 59982d9..da505ff 100644 (file)
@@ -107,7 +107,7 @@ Instrument::Instrument(const char* datafile, uint64_t sample_period)
     }
   }
 
-  static const int num_counters = ARRAY_SIZE(kCounterList);
+  static const int num_counters = arraysize(kCounterList);
 
   // Dump an instrumentation description comment at the top of the file.
   fprintf(output_stream_, "# counters=%d\n", num_counters);
index 9d4f781..de911bf 100644 (file)
@@ -1065,7 +1065,7 @@ void Simulator::PrintSystemRegisters(bool print_all) {
       "0b10 (Round towards Minus Infinity)",
       "0b11 (Round towards Zero)"
     };
-    DCHECK(fpcr().RMode() < ARRAY_SIZE(rmode));
+    DCHECK(fpcr().RMode() < arraysize(rmode));
     fprintf(stream_, "# %sFPCR: %sAHP:%d DN:%d FZ:%d RMode:%s%s\n",
             clr_flag_name,
             clr_flag_value,
index 02ca2c7..e683bf2 100644 (file)
@@ -1119,7 +1119,7 @@ Handle<String> Literal::ToString() {
   if (value_->IsString()) return value_->AsString()->string();
   DCHECK(value_->IsNumber());
   char arr[100];
-  Vector<char> buffer(arr, ARRAY_SIZE(arr));
+  Vector<char> buffer(arr, arraysize(arr));
   const char* str;
   if (value()->IsSmi()) {
     // Optimization only, the heap number case would subsume this.
index 4f62ac4..c3f609f 100644 (file)
@@ -22,7 +22,7 @@ namespace base {
 void DumpBacktrace() {
 #if V8_LIBC_GLIBC || V8_OS_BSD
   void* trace[100];
-  int size = backtrace(trace, ARRAY_SIZE(trace));
+  int size = backtrace(trace, arraysize(trace));
   char** symbols = backtrace_symbols(trace, size);
   OS::PrintError("\n==== C stack trace ===============================\n\n");
   if (size == 0) {
@@ -54,7 +54,7 @@ void DumpBacktrace() {
   bt_sprn_memmap(&memmap, out, sizeof(out));
   OS::PrintError(out);
   bt_addr_t trace[100];
-  int size = bt_get_backtrace(&acc, trace, ARRAY_SIZE(trace));
+  int size = bt_get_backtrace(&acc, trace, arraysize(trace));
   OS::PrintError("\n==== C stack trace ===============================\n\n");
   if (size == 0) {
     OS::PrintError("(empty)\n");
index 50828db..c8a1408 100644 (file)
   (reinterpret_cast<intptr_t>(&(reinterpret_cast<type*>(4)->field)) - 4)
 
 
-// The expression ARRAY_SIZE(a) is a compile-time constant of type
-// size_t which represents the number of elements of the given
-// array. You should only use ARRAY_SIZE on statically allocated
-// arrays.
-#define ARRAY_SIZE(a)                                   \
-  ((sizeof(a) / sizeof(*(a))) /                         \
-  static_cast<size_t>(!(sizeof(a) % sizeof(*(a)))))
+// The arraysize(arr) macro returns the # of elements in an array arr.
+// The expression is a compile-time constant, and therefore can be
+// used in defining new arrays, for example.  If you use arraysize on
+// a pointer by mistake, you will get a compile-time error.
+//
+// One caveat is that arraysize() doesn't accept any array of an
+// anonymous type or a type defined inside a function.  In these rare
+// cases, you have to use the unsafe ARRAYSIZE_UNSAFE() macro below.  This is
+// due to a limitation in C++'s template system.  The limitation might
+// eventually be removed, but it hasn't happened yet.
+#define arraysize(array) (sizeof(ArraySizeHelper(array)))
+
+
+// This template function declaration is used in defining arraysize.
+// Note that the function doesn't need an implementation, as we only
+// use its type.
+template <typename T, size_t N>
+char (&ArraySizeHelper(T (&array)[N]))[N];
+
+
+#if V8_CC_GNU
+// That gcc wants both of these prototypes seems mysterious. VC, for
+// its part, can't decide which to use (another mystery). Matching of
+// template overloads: the final frontier.
+template <typename T, size_t N>
+char (&ArraySizeHelper(const T (&array)[N]))[N];
+#endif
+
+
+// ARRAYSIZE_UNSAFE performs essentially the same calculation as arraysize,
+// but can be used on anonymous types or types defined inside
+// functions.  It's less safe than arraysize as it accepts some
+// (although not all) pointers.  Therefore, you should use arraysize
+// whenever possible.
+//
+// The expression ARRAYSIZE_UNSAFE(a) is a compile-time constant of type
+// size_t.
+//
+// ARRAYSIZE_UNSAFE catches a few type errors.  If you see a compiler error
+//
+//   "warning: division by zero in ..."
+//
+// when using ARRAYSIZE_UNSAFE, you are (wrongfully) giving it a pointer.
+// You should only use ARRAYSIZE_UNSAFE on statically allocated arrays.
+//
+// The following comments are on the implementation details, and can
+// be ignored by the users.
+//
+// ARRAYSIZE_UNSAFE(arr) works by inspecting sizeof(arr) (the # of bytes in
+// the array) and sizeof(*(arr)) (the # of bytes in one array
+// element).  If the former is divisible by the latter, perhaps arr is
+// indeed an array, in which case the division result is the # of
+// elements in the array.  Otherwise, arr cannot possibly be an array,
+// and we generate a compiler error to prevent the code from
+// compiling.
+//
+// Since the size of bool is implementation-defined, we need to cast
+// !(sizeof(a) & sizeof(*(a))) to size_t in order to ensure the final
+// result has type size_t.
+//
+// This macro is not perfect as it wrongfully accepts certain
+// pointers, namely where the pointer size is divisible by the pointee
+// size.  Since all our code has to go through a 32-bit compiler,
+// where a pointer is 4 bytes, this means all pointers to a type whose
+// size is 3 or greater than 4 will be (righteously) rejected.
+#define ARRAYSIZE_UNSAFE(a)     \
+  ((sizeof(a) / sizeof(*(a))) / \
+   static_cast<size_t>(!(sizeof(a) % sizeof(*(a)))))  // NOLINT
 
 
 // A macro to disallow the evil copy constructor and operator= functions
index e0e90b3..09e56d9 100644 (file)
@@ -2682,7 +2682,7 @@ Genesis::Genesis(Isolate* isolate,
                                   NONE).Assert();
 
     // Initialize trigonometric lookup tables and constants.
-    const int constants_size = ARRAY_SIZE(fdlibm::MathConstants::constants);
+    const int constants_size = arraysize(fdlibm::MathConstants::constants);
     const int table_num_bytes = constants_size * kDoubleSize;
     v8::Local<v8::ArrayBuffer> trig_buffer = v8::ArrayBuffer::New(
         reinterpret_cast<v8::Isolate*>(isolate),
index 5726c49..dd9e3b4 100644 (file)
@@ -111,7 +111,7 @@ static const CachedPower kCachedPowers[] = {
 };
 
 #ifdef DEBUG
-static const int kCachedPowersLength = ARRAY_SIZE(kCachedPowers);
+static const int kCachedPowersLength = arraysize(kCachedPowers);
 #endif
 
 static const int kCachedPowersOffset = 348;  // -1 * the first decimal_exponent.
index 9b84122..7506608 100644 (file)
@@ -585,7 +585,7 @@ void LoadFastElementStub::InitializeInterfaceDescriptor(
                            LoadIC::ReceiverRegister(),
                            LoadIC::NameRegister() };
   STATIC_ASSERT(LoadIC::kParameterCount == 2);
-  descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers,
+  descriptor->Initialize(MajorKey(), arraysize(registers), registers,
                          FUNCTION_ADDR(KeyedLoadIC_MissFromStubFailure));
 }
 
@@ -596,7 +596,7 @@ void LoadDictionaryElementStub::InitializeInterfaceDescriptor(
                            LoadIC::ReceiverRegister(),
                            LoadIC::NameRegister() };
   STATIC_ASSERT(LoadIC::kParameterCount == 2);
-  descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers,
+  descriptor->Initialize(MajorKey(), arraysize(registers), registers,
                          FUNCTION_ADDR(KeyedLoadIC_MissFromStubFailure));
 }
 
@@ -608,7 +608,7 @@ void KeyedLoadGenericStub::InitializeInterfaceDescriptor(
                            LoadIC::NameRegister() };
   STATIC_ASSERT(LoadIC::kParameterCount == 2);
   descriptor->Initialize(
-      MajorKey(), ARRAY_SIZE(registers), registers,
+      MajorKey(), arraysize(registers), registers,
       Runtime::FunctionForId(Runtime::kKeyedGetProperty)->entry);
 }
 
@@ -618,13 +618,13 @@ void HandlerStub::InitializeInterfaceDescriptor(
   if (kind() == Code::LOAD_IC) {
     Register registers[] = {InterfaceDescriptor::ContextRegister(),
                             LoadIC::ReceiverRegister(), LoadIC::NameRegister()};
-    descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers);
+    descriptor->Initialize(MajorKey(), arraysize(registers), registers);
   } else {
     DCHECK_EQ(Code::STORE_IC, kind());
     Register registers[] = {InterfaceDescriptor::ContextRegister(),
                             StoreIC::ReceiverRegister(),
                             StoreIC::NameRegister(), StoreIC::ValueRegister()};
-    descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers,
+    descriptor->Initialize(MajorKey(), arraysize(registers), registers,
                            FUNCTION_ADDR(StoreIC_MissFromStubFailure));
   }
 }
@@ -636,7 +636,7 @@ void StoreFastElementStub::InitializeInterfaceDescriptor(
                            KeyedStoreIC::ReceiverRegister(),
                            KeyedStoreIC::NameRegister(),
                            KeyedStoreIC::ValueRegister() };
-  descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers,
+  descriptor->Initialize(MajorKey(), arraysize(registers), registers,
                          FUNCTION_ADDR(KeyedStoreIC_MissFromStubFailure));
 }
 
@@ -648,7 +648,7 @@ void ElementsTransitionAndStoreStub::InitializeInterfaceDescriptor(
                            MapRegister(),
                            KeyRegister(),
                            ObjectRegister() };
-  descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers,
+  descriptor->Initialize(MajorKey(), arraysize(registers), registers,
                          FUNCTION_ADDR(ElementsTransitionAndStoreIC_Miss));
 }
 
@@ -658,7 +658,7 @@ void InstanceofStub::InitializeInterfaceDescriptor(
   Register registers[] = { InterfaceDescriptor::ContextRegister(),
                            InstanceofStub::left(),
                            InstanceofStub::right() };
-  descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers);
+  descriptor->Initialize(MajorKey(), arraysize(registers), registers);
 }
 
 
index a234e5a..96f95e9 100644 (file)
@@ -272,8 +272,8 @@ static void VisitBinop(InstructionSelector* selector, Node* node,
 
   DCHECK_NE(0, input_count);
   DCHECK_NE(0, output_count);
-  DCHECK_GE(ARRAY_SIZE(inputs), input_count);
-  DCHECK_GE(ARRAY_SIZE(outputs), output_count);
+  DCHECK_GE(arraysize(inputs), input_count);
+  DCHECK_GE(arraysize(outputs), output_count);
   DCHECK_NE(kMode_None, AddressingModeField::decode(opcode));
 
   Instruction* instr = selector->Emit(cont->Encode(opcode), output_count,
@@ -345,7 +345,7 @@ void InstructionSelector::VisitStore(Node* node) {
     // TODO(dcarney): handle immediate indices.
     InstructionOperand* temps[] = {g.TempRegister(r5), g.TempRegister(r6)};
     Emit(kArmStoreWriteBarrier, NULL, g.UseFixed(base, r4),
-         g.UseFixed(index, r5), g.UseFixed(value, r6), ARRAY_SIZE(temps),
+         g.UseFixed(index, r5), g.UseFixed(value, r6), arraysize(temps),
          temps);
     return;
   }
@@ -502,8 +502,8 @@ static inline void VisitShift(InstructionSelector* selector, Node* node,
 
   DCHECK_NE(0, input_count);
   DCHECK_NE(0, output_count);
-  DCHECK_GE(ARRAY_SIZE(inputs), input_count);
-  DCHECK_GE(ARRAY_SIZE(outputs), output_count);
+  DCHECK_GE(arraysize(inputs), input_count);
+  DCHECK_GE(arraysize(outputs), output_count);
   DCHECK_NE(kMode_None, AddressingModeField::decode(opcode));
 
   Instruction* instr = selector->Emit(cont->Encode(opcode), output_count,
@@ -890,8 +890,8 @@ static void VisitWordCompare(InstructionSelector* selector, Node* node,
   }
 
   DCHECK_NE(0, input_count);
-  DCHECK_GE(ARRAY_SIZE(inputs), input_count);
-  DCHECK_GE(ARRAY_SIZE(outputs), output_count);
+  DCHECK_GE(arraysize(inputs), input_count);
+  DCHECK_GE(arraysize(outputs), output_count);
 
   Instruction* instr = selector->Emit(cont->Encode(opcode), output_count,
                                       outputs, input_count, inputs);
index e7381b5..8445e9f 100644 (file)
@@ -124,8 +124,8 @@ static void VisitBinop(InstructionSelector* selector, Node* node,
 
   DCHECK_NE(0, input_count);
   DCHECK_NE(0, output_count);
-  DCHECK_GE(ARRAY_SIZE(inputs), input_count);
-  DCHECK_GE(ARRAY_SIZE(outputs), output_count);
+  DCHECK_GE(arraysize(inputs), input_count);
+  DCHECK_GE(arraysize(outputs), output_count);
 
   Instruction* instr = selector->Emit(cont->Encode(opcode), output_count,
                                       outputs, input_count, inputs);
@@ -198,7 +198,7 @@ void InstructionSelector::VisitStore(Node* node) {
     // TODO(dcarney): handle immediate indices.
     InstructionOperand* temps[] = {g.TempRegister(x11), g.TempRegister(x12)};
     Emit(kArm64StoreWriteBarrier, NULL, g.UseFixed(base, x10),
-         g.UseFixed(index, x11), g.UseFixed(value, x12), ARRAY_SIZE(temps),
+         g.UseFixed(index, x11), g.UseFixed(value, x12), arraysize(temps),
          temps);
     return;
   }
index fc90008..dfa79b8 100644 (file)
@@ -32,29 +32,29 @@ class GraphBuilder {
 
   Node* NewNode(Operator* op, Node* n1, Node* n2) {
     Node* buffer[] = {n1, n2};
-    return MakeNode(op, ARRAY_SIZE(buffer), buffer);
+    return MakeNode(op, arraysize(buffer), buffer);
   }
 
   Node* NewNode(Operator* op, Node* n1, Node* n2, Node* n3) {
     Node* buffer[] = {n1, n2, n3};
-    return MakeNode(op, ARRAY_SIZE(buffer), buffer);
+    return MakeNode(op, arraysize(buffer), buffer);
   }
 
   Node* NewNode(Operator* op, Node* n1, Node* n2, Node* n3, Node* n4) {
     Node* buffer[] = {n1, n2, n3, n4};
-    return MakeNode(op, ARRAY_SIZE(buffer), buffer);
+    return MakeNode(op, arraysize(buffer), buffer);
   }
 
   Node* NewNode(Operator* op, Node* n1, Node* n2, Node* n3, Node* n4,
                 Node* n5) {
     Node* buffer[] = {n1, n2, n3, n4, n5};
-    return MakeNode(op, ARRAY_SIZE(buffer), buffer);
+    return MakeNode(op, arraysize(buffer), buffer);
   }
 
   Node* NewNode(Operator* op, Node* n1, Node* n2, Node* n3, Node* n4, Node* n5,
                 Node* n6) {
     Node* nodes[] = {n1, n2, n3, n4, n5, n6};
-    return MakeNode(op, ARRAY_SIZE(nodes), nodes);
+    return MakeNode(op, arraysize(nodes), nodes);
   }
 
   Node* NewNode(Operator* op, int value_input_count, Node** value_inputs) {
index 65ea3b3..64d297f 100644 (file)
@@ -34,25 +34,25 @@ class Graph : public GenericGraph<Node> {
   Node* NewNode(Operator* op, Node* n1) { return NewNode(op, 1, &n1); }
   Node* NewNode(Operator* op, Node* n1, Node* n2) {
     Node* nodes[] = {n1, n2};
-    return NewNode(op, ARRAY_SIZE(nodes), nodes);
+    return NewNode(op, arraysize(nodes), nodes);
   }
   Node* NewNode(Operator* op, Node* n1, Node* n2, Node* n3) {
     Node* nodes[] = {n1, n2, n3};
-    return NewNode(op, ARRAY_SIZE(nodes), nodes);
+    return NewNode(op, arraysize(nodes), nodes);
   }
   Node* NewNode(Operator* op, Node* n1, Node* n2, Node* n3, Node* n4) {
     Node* nodes[] = {n1, n2, n3, n4};
-    return NewNode(op, ARRAY_SIZE(nodes), nodes);
+    return NewNode(op, arraysize(nodes), nodes);
   }
   Node* NewNode(Operator* op, Node* n1, Node* n2, Node* n3, Node* n4,
                 Node* n5) {
     Node* nodes[] = {n1, n2, n3, n4, n5};
-    return NewNode(op, ARRAY_SIZE(nodes), nodes);
+    return NewNode(op, arraysize(nodes), nodes);
   }
   Node* NewNode(Operator* op, Node* n1, Node* n2, Node* n3, Node* n4, Node* n5,
                 Node* n6) {
     Node* nodes[] = {n1, n2, n3, n4, n5, n6};
-    return NewNode(op, ARRAY_SIZE(nodes), nodes);
+    return NewNode(op, arraysize(nodes), nodes);
   }
 
   void ChangeOperator(Node* node, Operator* op);
index 4184bbd..0b20903 100644 (file)
@@ -106,7 +106,7 @@ void InstructionSelector::VisitStore(Node* node) {
     // TODO(dcarney): handle immediate indices.
     InstructionOperand* temps[] = {g.TempRegister(ecx), g.TempRegister(edx)};
     Emit(kIA32StoreWriteBarrier, NULL, g.UseFixed(base, ebx),
-         g.UseFixed(index, ecx), g.UseFixed(value, edx), ARRAY_SIZE(temps),
+         g.UseFixed(index, ecx), g.UseFixed(value, edx), arraysize(temps),
          temps);
     return;
   }
@@ -195,8 +195,8 @@ static void VisitBinop(InstructionSelector* selector, Node* node,
 
   DCHECK_NE(0, input_count);
   DCHECK_NE(0, output_count);
-  DCHECK_GE(ARRAY_SIZE(inputs), input_count);
-  DCHECK_GE(ARRAY_SIZE(outputs), output_count);
+  DCHECK_GE(arraysize(inputs), input_count);
+  DCHECK_GE(arraysize(outputs), output_count);
 
   Instruction* instr = selector->Emit(cont->Encode(opcode), output_count,
                                       outputs, input_count, inputs);
@@ -316,7 +316,7 @@ static inline void VisitDiv(InstructionSelector* selector, Node* node,
                             ArchOpcode opcode) {
   IA32OperandGenerator g(selector);
   InstructionOperand* temps[] = {g.TempRegister(edx)};
-  size_t temp_count = ARRAY_SIZE(temps);
+  size_t temp_count = arraysize(temps);
   selector->Emit(opcode, g.DefineAsFixed(node, eax),
                  g.UseFixed(node->InputAt(0), eax),
                  g.UseUnique(node->InputAt(1)), temp_count, temps);
@@ -337,7 +337,7 @@ static inline void VisitMod(InstructionSelector* selector, Node* node,
                             ArchOpcode opcode) {
   IA32OperandGenerator g(selector);
   InstructionOperand* temps[] = {g.TempRegister(eax), g.TempRegister(edx)};
-  size_t temp_count = ARRAY_SIZE(temps);
+  size_t temp_count = arraysize(temps);
   selector->Emit(opcode, g.DefineAsFixed(node, edx),
                  g.UseFixed(node->InputAt(0), eax),
                  g.UseUnique(node->InputAt(1)), temp_count, temps);
index 6db5542..e65b85b 100644 (file)
@@ -91,7 +91,7 @@ Instruction* InstructionSelector::Emit(InstructionCode opcode,
                                        InstructionOperand** temps) {
   size_t output_count = output == NULL ? 0 : 1;
   InstructionOperand* inputs[] = {a, b};
-  size_t input_count = ARRAY_SIZE(inputs);
+  size_t input_count = arraysize(inputs);
   return Emit(opcode, output_count, &output, input_count, inputs, temp_count,
               temps);
 }
@@ -105,7 +105,7 @@ Instruction* InstructionSelector::Emit(InstructionCode opcode,
                                        InstructionOperand** temps) {
   size_t output_count = output == NULL ? 0 : 1;
   InstructionOperand* inputs[] = {a, b, c};
-  size_t input_count = ARRAY_SIZE(inputs);
+  size_t input_count = arraysize(inputs);
   return Emit(opcode, output_count, &output, input_count, inputs, temp_count,
               temps);
 }
@@ -117,7 +117,7 @@ Instruction* InstructionSelector::Emit(
     size_t temp_count, InstructionOperand** temps) {
   size_t output_count = output == NULL ? 0 : 1;
   InstructionOperand* inputs[] = {a, b, c, d};
-  size_t input_count = ARRAY_SIZE(inputs);
+  size_t input_count = arraysize(inputs);
   return Emit(opcode, output_count, &output, input_count, inputs, temp_count,
               temps);
 }
index 77cb929..16dcbf8 100644 (file)
@@ -49,7 +49,7 @@ class LoadICStubShim : public HydrogenCodeStub {
     Register registers[] = { InterfaceDescriptor::ContextRegister(),
                              LoadIC::ReceiverRegister(),
                              LoadIC::NameRegister() };
-    descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers);
+    descriptor->Initialize(MajorKey(), arraysize(registers), registers);
   }
 
  private:
@@ -79,7 +79,7 @@ class KeyedLoadICStubShim : public HydrogenCodeStub {
     Register registers[] = { InterfaceDescriptor::ContextRegister(),
                              KeyedLoadIC::ReceiverRegister(),
                              KeyedLoadIC::NameRegister() };
-    descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers);
+    descriptor->Initialize(MajorKey(), arraysize(registers), registers);
   }
 
  private:
@@ -109,7 +109,7 @@ class StoreICStubShim : public HydrogenCodeStub {
                              StoreIC::ReceiverRegister(),
                              StoreIC::NameRegister(),
                              StoreIC::ValueRegister() };
-    descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers);
+    descriptor->Initialize(MajorKey(), arraysize(registers), registers);
   }
 
  private:
@@ -143,7 +143,7 @@ class KeyedStoreICStubShim : public HydrogenCodeStub {
                              KeyedStoreIC::ReceiverRegister(),
                              KeyedStoreIC::NameRegister(),
                              KeyedStoreIC::ValueRegister() };
-    descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers);
+    descriptor->Initialize(MajorKey(), arraysize(registers), registers);
   }
 
  private:
index e3ef747..3334922 100644 (file)
@@ -119,7 +119,7 @@ void InstructionSelector::VisitStore(Node* node) {
     // TODO(dcarney): handle immediate indices.
     InstructionOperand* temps[] = {g.TempRegister(rcx), g.TempRegister(rdx)};
     Emit(kX64StoreWriteBarrier, NULL, g.UseFixed(base, rbx),
-         g.UseFixed(index, rcx), g.UseFixed(value, rdx), ARRAY_SIZE(temps),
+         g.UseFixed(index, rcx), g.UseFixed(value, rdx), arraysize(temps),
          temps);
     return;
   }
@@ -206,8 +206,8 @@ static void VisitBinop(InstructionSelector* selector, Node* node,
 
   DCHECK_NE(0, input_count);
   DCHECK_NE(0, output_count);
-  DCHECK_GE(ARRAY_SIZE(inputs), input_count);
-  DCHECK_GE(ARRAY_SIZE(outputs), output_count);
+  DCHECK_GE(arraysize(inputs), input_count);
+  DCHECK_GE(arraysize(outputs), output_count);
 
   Instruction* instr = selector->Emit(cont->Encode(opcode), output_count,
                                       outputs, input_count, inputs);
@@ -428,7 +428,7 @@ static void VisitDiv(InstructionSelector* selector, Node* node,
   InstructionOperand* temps[] = {g.TempRegister(rdx)};
   selector->Emit(
       opcode, g.DefineAsFixed(node, rax), g.UseFixed(node->InputAt(0), rax),
-      g.UseUniqueRegister(node->InputAt(1)), ARRAY_SIZE(temps), temps);
+      g.UseUniqueRegister(node->InputAt(1)), arraysize(temps), temps);
 }
 
 
@@ -458,7 +458,7 @@ static void VisitMod(InstructionSelector* selector, Node* node,
   InstructionOperand* temps[] = {g.TempRegister(rax), g.TempRegister(rdx)};
   selector->Emit(
       opcode, g.DefineAsFixed(node, rdx), g.UseFixed(node->InputAt(0), rax),
-      g.UseUniqueRegister(node->InputAt(1)), ARRAY_SIZE(temps), temps);
+      g.UseUniqueRegister(node->InputAt(1)), arraysize(temps), temps);
 }
 
 
index 4b41d5e..69272b5 100644 (file)
@@ -211,7 +211,7 @@ char* DoubleToFixedCString(double value, int f) {
   // use the non-fixed conversion routine.
   if (abs_value >= kFirstNonFixed) {
     char arr[100];
-    Vector<char> buffer(arr, ARRAY_SIZE(arr));
+    Vector<char> buffer(arr, arraysize(arr));
     return StrDup(DoubleToCString(value, buffer));
   }
 
index 6b983ce..f4ab115 100644 (file)
@@ -1051,7 +1051,7 @@ bool Debug::CheckBreakPoint(Handle<Object> break_point_object) {
   Handle<Object> result;
   if (!Execution::TryCall(check_break_point,
                           isolate_->js_builtins_object(),
-                          ARRAY_SIZE(argv),
+                          arraysize(argv),
                           argv).ToHandle(&result)) {
     return false;
   }
@@ -2458,7 +2458,7 @@ MaybeHandle<Object> Debug::MakeJSObject(const char* constructor_name,
 MaybeHandle<Object> Debug::MakeExecutionState() {
   // Create the execution state object.
   Handle<Object> argv[] = { isolate_->factory()->NewNumberFromInt(break_id()) };
-  return MakeJSObject("MakeExecutionState", ARRAY_SIZE(argv), argv);
+  return MakeJSObject("MakeExecutionState", arraysize(argv), argv);
 }
 
 
@@ -2466,7 +2466,7 @@ MaybeHandle<Object> Debug::MakeBreakEvent(Handle<Object> break_points_hit) {
   // Create the new break event object.
   Handle<Object> argv[] = { isolate_->factory()->NewNumberFromInt(break_id()),
                             break_points_hit };
-  return MakeJSObject("MakeBreakEvent", ARRAY_SIZE(argv), argv);
+  return MakeJSObject("MakeBreakEvent", arraysize(argv), argv);
 }
 
 
@@ -2478,7 +2478,7 @@ MaybeHandle<Object> Debug::MakeExceptionEvent(Handle<Object> exception,
                             exception,
                             isolate_->factory()->ToBoolean(uncaught),
                             promise };
-  return MakeJSObject("MakeExceptionEvent", ARRAY_SIZE(argv), argv);
+  return MakeJSObject("MakeExceptionEvent", arraysize(argv), argv);
 }
 
 
@@ -2488,21 +2488,21 @@ MaybeHandle<Object> Debug::MakeCompileEvent(Handle<Script> script,
   Handle<Object> script_wrapper = Script::GetWrapper(script);
   Handle<Object> argv[] = { script_wrapper,
                             isolate_->factory()->NewNumberFromInt(type) };
-  return MakeJSObject("MakeCompileEvent", ARRAY_SIZE(argv), argv);
+  return MakeJSObject("MakeCompileEvent", arraysize(argv), argv);
 }
 
 
 MaybeHandle<Object> Debug::MakePromiseEvent(Handle<JSObject> event_data) {
   // Create the promise event object.
   Handle<Object> argv[] = { event_data };
-  return MakeJSObject("MakePromiseEvent", ARRAY_SIZE(argv), argv);
+  return MakeJSObject("MakePromiseEvent", arraysize(argv), argv);
 }
 
 
 MaybeHandle<Object> Debug::MakeAsyncTaskEvent(Handle<JSObject> task_event) {
   // Create the async task event object.
   Handle<Object> argv[] = { task_event };
-  return MakeJSObject("MakeAsyncTaskEvent", ARRAY_SIZE(argv), argv);
+  return MakeJSObject("MakeAsyncTaskEvent", arraysize(argv), argv);
 }
 
 
@@ -2648,7 +2648,7 @@ void Debug::OnAfterCompile(Handle<Script> script) {
   Handle<Object> argv[] = { wrapper };
   if (Execution::TryCall(Handle<JSFunction>::cast(update_script_break_points),
                          isolate_->js_builtins_object(),
-                         ARRAY_SIZE(argv),
+                         arraysize(argv),
                          argv).is_null()) {
     return;
   }
@@ -2765,7 +2765,7 @@ void Debug::CallEventCallback(v8::DebugEvent event,
                               event_listener_data_ };
     Handle<JSReceiver> global(isolate_->global_proxy());
     Execution::TryCall(Handle<JSFunction>::cast(event_listener_),
-                       global, ARRAY_SIZE(argv), argv);
+                       global, arraysize(argv), argv);
   }
 }
 
@@ -3004,7 +3004,7 @@ MaybeHandle<Object> Debug::Call(Handle<JSFunction> fun, Handle<Object> data) {
       isolate_,
       fun,
       Handle<Object>(debug_context()->global_proxy(), isolate_),
-      ARRAY_SIZE(argv),
+      arraysize(argv),
       argv);
 }
 
index a0cc697..c509483 100644 (file)
@@ -494,7 +494,7 @@ class FrameDescription {
     // This convoluted DCHECK is needed to work around a gcc problem that
     // improperly detects an array bounds overflow in optimized debug builds
     // when using a plain DCHECK.
-    if (n >= ARRAY_SIZE(registers_)) {
+    if (n >= arraysize(registers_)) {
       DCHECK(false);
       return 0;
     }
@@ -503,17 +503,17 @@ class FrameDescription {
   }
 
   double GetDoubleRegister(unsigned n) const {
-    DCHECK(n < ARRAY_SIZE(double_registers_));
+    DCHECK(n < arraysize(double_registers_));
     return double_registers_[n];
   }
 
   void SetRegister(unsigned n, intptr_t value) {
-    DCHECK(n < ARRAY_SIZE(registers_));
+    DCHECK(n < arraysize(registers_));
     registers_[n] = value;
   }
 
   void SetDoubleRegister(unsigned n, double value) {
-    DCHECK(n < ARRAY_SIZE(double_registers_));
+    DCHECK(n < arraysize(double_registers_));
     double_registers_[n] = value;
   }
 
index f146c30..12dd862 100644 (file)
@@ -484,7 +484,7 @@ void StackGuard::InitThread(const ExecutionAccess& lock) {
     return Call(isolate,                                                \
                 isolate->name##_fun(),                                  \
                 isolate->js_builtins_object(),                          \
-                ARRAY_SIZE(argv), argv);                                \
+                arraysize(argv), argv);                                \
   } while (false)
 
 
@@ -575,7 +575,7 @@ Handle<Object> Execution::CharAt(Handle<String> string, uint32_t index) {
   Handle<Object> result;
   if (!TryCall(Handle<JSFunction>::cast(char_at),
                string,
-               ARRAY_SIZE(index_arg),
+               arraysize(index_arg),
                index_arg).ToHandle(&result)) {
     return factory->undefined_value();
   }
@@ -602,7 +602,7 @@ MaybeHandle<JSFunction> Execution::InstantiateFunction(
       Call(isolate,
            isolate->instantiate_fun(),
            isolate->js_builtins_object(),
-           ARRAY_SIZE(args),
+           arraysize(args),
            args),
       JSFunction);
   return Handle<JSFunction>::cast(result);
@@ -629,7 +629,7 @@ MaybeHandle<JSObject> Execution::InstantiateObject(
         Call(isolate,
              isolate->instantiate_fun(),
              isolate->js_builtins_object(),
-             ARRAY_SIZE(args),
+             arraysize(args),
              args),
         JSObject);
   }
@@ -645,7 +645,7 @@ MaybeHandle<Object> Execution::ConfigureInstance(
   return Execution::Call(isolate,
                          isolate->configure_instance_fun(),
                          isolate->js_builtins_object(),
-                         ARRAY_SIZE(args),
+                         arraysize(args),
                          args);
 }
 
@@ -659,7 +659,7 @@ Handle<String> Execution::GetStackTraceLine(Handle<Object> recv,
   MaybeHandle<Object> maybe_result =
       TryCall(isolate->get_stack_trace_line_fun(),
               isolate->js_builtins_object(),
-              ARRAY_SIZE(args),
+              arraysize(args),
               args);
   Handle<Object> result;
   if (!maybe_result.ToHandle(&result) || !result->IsString()) {
index 70fa986..643329c 100644 (file)
@@ -1139,7 +1139,7 @@ Handle<String> Factory::EmergencyNewError(const char* message,
   space -= Min(space, strlen(message));
   p = &buffer[kBufferSize] - space;
 
-  for (unsigned i = 0; i < ARRAY_SIZE(args); i++) {
+  for (int i = 0; i < Smi::cast(args->length())->value(); i++) {
     if (space > 0) {
       *p++ = ' ';
       space--;
@@ -1184,7 +1184,7 @@ Handle<Object> Factory::NewError(const char* maker,
   Handle<Object> exception;
   if (!Execution::TryCall(fun,
                           isolate()->js_builtins_object(),
-                          ARRAY_SIZE(argv),
+                          arraysize(argv),
                           argv,
                           &exception).ToHandle(&result)) {
     return exception;
@@ -1211,7 +1211,7 @@ Handle<Object> Factory::NewError(const char* constructor,
   Handle<Object> exception;
   if (!Execution::TryCall(fun,
                           isolate()->js_builtins_object(),
-                          ARRAY_SIZE(argv),
+                          arraysize(argv),
                           argv,
                           &exception).ToHandle(&result)) {
     return exception;
@@ -2039,7 +2039,7 @@ Handle<String> Factory::NumberToString(Handle<Object> number,
   }
 
   char arr[100];
-  Vector<char> buffer(arr, ARRAY_SIZE(arr));
+  Vector<char> buffer(arr, arraysize(arr));
   const char* str;
   if (number->IsSmi()) {
     int num = Handle<Smi>::cast(number)->value();
index 98ddae8..cfbef49 100644 (file)
@@ -878,7 +878,7 @@ FullCodeGenerator::InlineFunctionGenerator
         static_cast<int>(id) - static_cast<int>(Runtime::kFirstInlineFunction);
     DCHECK(lookup_index >= 0);
     DCHECK(static_cast<size_t>(lookup_index) <
-           ARRAY_SIZE(kInlineFunctionGenerators));
+           arraysize(kInlineFunctionGenerators));
     return kInlineFunctionGenerators[lookup_index];
 }
 
index 940d53b..f5560a9 100644 (file)
@@ -1007,7 +1007,7 @@ void GlobalHandles::ComputeObjectGroupsAndImplicitReferences() {
 
 
 EternalHandles::EternalHandles() : size_(0) {
-  for (unsigned i = 0; i < ARRAY_SIZE(singleton_handles_); i++) {
+  for (unsigned i = 0; i < arraysize(singleton_handles_); i++) {
     singleton_handles_[i] = kInvalidIndex;
   }
 }
index a3d653d..e31a281 100644 (file)
@@ -2500,7 +2500,7 @@ bool Heap::CreateInitialMaps() {
     ALLOCATE_MAP(ODDBALL_TYPE, Oddball::kSize, exception);
     ALLOCATE_MAP(ODDBALL_TYPE, Oddball::kSize, termination_exception);
 
-    for (unsigned i = 0; i < ARRAY_SIZE(string_type_table); i++) {
+    for (unsigned i = 0; i < arraysize(string_type_table); i++) {
       const StringTypeTable& entry = string_type_table[i];
       {
         AllocationResult allocation = AllocateMap(entry.type, entry.size);
@@ -2546,7 +2546,7 @@ bool Heap::CreateInitialMaps() {
     ALLOCATE_MAP(FILLER_TYPE, 2 * kPointerSize, two_pointer_filler)
 
 
-    for (unsigned i = 0; i < ARRAY_SIZE(struct_table); i++) {
+    for (unsigned i = 0; i < arraysize(struct_table); i++) {
       const StructTable& entry = struct_table[i];
       Map* map;
       if (!AllocateMap(entry.type, entry.size).To(&map)) return false;
@@ -2791,7 +2791,7 @@ void Heap::CreateInitialObjects() {
                                      handle(Smi::FromInt(-5), isolate()),
                                      Oddball::kException));
 
-  for (unsigned i = 0; i < ARRAY_SIZE(constant_string_table); i++) {
+  for (unsigned i = 0; i < arraysize(constant_string_table); i++) {
     Handle<String> str =
         factory->InternalizeUtf8String(constant_string_table[i].contents);
     roots_[constant_string_table[i].index] = *str;
@@ -2921,7 +2921,7 @@ bool Heap::RootCanBeWrittenAfterInitialization(Heap::RootListIndex root_index) {
       kStringTableRootIndex,
   };
 
-  for (unsigned int i = 0; i < ARRAY_SIZE(writable_roots); i++) {
+  for (unsigned int i = 0; i < arraysize(writable_roots); i++) {
     if (root_index == writable_roots[i]) return true;
   }
   return false;
index 16d91c4..b43dc51 100644 (file)
@@ -9767,7 +9767,7 @@ void HOptimizedGraphBuilder::VisitCallRuntime(CallRuntime* expr) {
         static_cast<int>(Runtime::kFirstInlineFunction);
     DCHECK(lookup_index >= 0);
     DCHECK(static_cast<size_t>(lookup_index) <
-           ARRAY_SIZE(kInlineFunctionGenerators));
+           arraysize(kInlineFunctionGenerators));
     InlineFunctionGenerator generator = kInlineFunctionGenerators[lookup_index];
 
     // Call the inline code generator using the pointer-to-member.
index 1714e4a..973030c 100644 (file)
@@ -23,7 +23,7 @@ void FastNewClosureStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   Register registers[] = { esi, ebx };
   descriptor->Initialize(
-      MajorKey(), ARRAY_SIZE(registers), registers,
+      MajorKey(), arraysize(registers), registers,
       Runtime::FunctionForId(Runtime::kNewClosureFromStubFailure)->entry);
 }
 
@@ -31,7 +31,7 @@ void FastNewClosureStub::InitializeInterfaceDescriptor(
 void FastNewContextStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   Register registers[] = { esi, edi };
-  descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers);
+  descriptor->Initialize(MajorKey(), arraysize(registers), registers);
 }
 
 
@@ -39,7 +39,7 @@ void ToNumberStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   // ToNumberStub invokes a function, and therefore needs a context.
   Register registers[] = { esi, eax };
-  descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers);
+  descriptor->Initialize(MajorKey(), arraysize(registers), registers);
 }
 
 
@@ -47,7 +47,7 @@ void NumberToStringStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   Register registers[] = { esi, eax };
   descriptor->Initialize(
-      MajorKey(), ARRAY_SIZE(registers), registers,
+      MajorKey(), arraysize(registers), registers,
       Runtime::FunctionForId(Runtime::kNumberToStringRT)->entry);
 }
 
@@ -62,7 +62,7 @@ void FastCloneShallowArrayStub::InitializeInterfaceDescriptor(
     Representation::Tagged() };
 
   descriptor->Initialize(
-      MajorKey(), ARRAY_SIZE(registers), registers,
+      MajorKey(), arraysize(registers), registers,
       Runtime::FunctionForId(Runtime::kCreateArrayLiteralStubBailout)->entry,
       representations);
 }
@@ -72,7 +72,7 @@ void FastCloneShallowObjectStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   Register registers[] = { esi, eax, ebx, ecx, edx };
   descriptor->Initialize(
-      MajorKey(), ARRAY_SIZE(registers), registers,
+      MajorKey(), arraysize(registers), registers,
       Runtime::FunctionForId(Runtime::kCreateObjectLiteral)->entry);
 }
 
@@ -80,14 +80,14 @@ void FastCloneShallowObjectStub::InitializeInterfaceDescriptor(
 void CreateAllocationSiteStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   Register registers[] = { esi, ebx, edx };
-  descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers);
+  descriptor->Initialize(MajorKey(), arraysize(registers), registers);
 }
 
 
 void CallFunctionStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   Register registers[] = {esi, edi};
-  descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers);
+  descriptor->Initialize(MajorKey(), arraysize(registers), registers);
 }
 
 
@@ -101,7 +101,7 @@ void CallConstructStub::InitializeInterfaceDescriptor(
   // TODO(turbofan): So far we don't gather type feedback and hence skip the
   // slot parameter, but ArrayConstructStub needs the vector to be undefined.
   Register registers[] = {esi, eax, edi, ebx};
-  descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers);
+  descriptor->Initialize(MajorKey(), arraysize(registers), registers);
 }
 
 
@@ -109,7 +109,7 @@ void RegExpConstructResultStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   Register registers[] = { esi, ecx, ebx, eax };
   descriptor->Initialize(
-      MajorKey(), ARRAY_SIZE(registers), registers,
+      MajorKey(), arraysize(registers), registers,
       Runtime::FunctionForId(Runtime::kRegExpConstructResult)->entry);
 }
 
@@ -118,7 +118,7 @@ void TransitionElementsKindStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   Register registers[] = { esi, eax, ebx };
   descriptor->Initialize(
-      MajorKey(), ARRAY_SIZE(registers), registers,
+      MajorKey(), arraysize(registers), registers,
       Runtime::FunctionForId(Runtime::kTransitionElementsKind)->entry);
 }
 
@@ -139,7 +139,7 @@ static void InitializeArrayConstructorDescriptor(
 
   if (constant_stack_parameter_count == 0) {
     Register registers[] = { esi, edi, ebx };
-    descriptor->Initialize(major, ARRAY_SIZE(registers), registers,
+    descriptor->Initialize(major, arraysize(registers), registers,
                            deopt_handler, NULL, constant_stack_parameter_count,
                            JS_FUNCTION_STUB_MODE);
   } else {
@@ -150,7 +150,7 @@ static void InitializeArrayConstructorDescriptor(
         Representation::Tagged(),
         Representation::Tagged(),
         Representation::Integer32() };
-    descriptor->Initialize(major, ARRAY_SIZE(registers), registers, eax,
+    descriptor->Initialize(major, arraysize(registers), registers, eax,
                            deopt_handler, representations,
                            constant_stack_parameter_count,
                            JS_FUNCTION_STUB_MODE, PASS_ARGUMENTS);
@@ -169,7 +169,7 @@ static void InitializeInternalArrayConstructorDescriptor(
 
   if (constant_stack_parameter_count == 0) {
     Register registers[] = { esi, edi };
-    descriptor->Initialize(major, ARRAY_SIZE(registers), registers,
+    descriptor->Initialize(major, arraysize(registers), registers,
                            deopt_handler, NULL, constant_stack_parameter_count,
                            JS_FUNCTION_STUB_MODE);
   } else {
@@ -179,7 +179,7 @@ static void InitializeInternalArrayConstructorDescriptor(
         Representation::Tagged(),
         Representation::Tagged(),
         Representation::Integer32() };
-    descriptor->Initialize(major, ARRAY_SIZE(registers), registers, eax,
+    descriptor->Initialize(major, arraysize(registers), registers, eax,
                            deopt_handler, representations,
                            constant_stack_parameter_count,
                            JS_FUNCTION_STUB_MODE, PASS_ARGUMENTS);
@@ -226,7 +226,7 @@ void InternalArrayNArgumentsConstructorStub::InitializeInterfaceDescriptor(
 void CompareNilICStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   Register registers[] = { esi, eax };
-  descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers,
+  descriptor->Initialize(MajorKey(), arraysize(registers), registers,
                          FUNCTION_ADDR(CompareNilIC_Miss));
   descriptor->SetMissHandler(
       ExternalReference(IC_Utility(IC::kCompareNilIC_Miss), isolate()));
@@ -235,7 +235,7 @@ void CompareNilICStub::InitializeInterfaceDescriptor(
 void ToBooleanStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   Register registers[] = { esi, eax };
-  descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers,
+  descriptor->Initialize(MajorKey(), arraysize(registers), registers,
                          FUNCTION_ADDR(ToBooleanIC_Miss));
   descriptor->SetMissHandler(
       ExternalReference(IC_Utility(IC::kToBooleanIC_Miss), isolate()));
@@ -245,7 +245,7 @@ void ToBooleanStub::InitializeInterfaceDescriptor(
 void BinaryOpICStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   Register registers[] = { esi, edx, eax };
-  descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers,
+  descriptor->Initialize(MajorKey(), arraysize(registers), registers,
                          FUNCTION_ADDR(BinaryOpIC_Miss));
   descriptor->SetMissHandler(
       ExternalReference(IC_Utility(IC::kBinaryOpIC_Miss), isolate()));
@@ -255,7 +255,7 @@ void BinaryOpICStub::InitializeInterfaceDescriptor(
 void BinaryOpWithAllocationSiteStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   Register registers[] = { esi, ecx, edx, eax };
-  descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers,
+  descriptor->Initialize(MajorKey(), arraysize(registers), registers,
                          FUNCTION_ADDR(BinaryOpIC_MissWithAllocationSite));
 }
 
@@ -263,7 +263,7 @@ void BinaryOpWithAllocationSiteStub::InitializeInterfaceDescriptor(
 void StringAddStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   Register registers[] = { esi, edx, eax };
-  descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers,
+  descriptor->Initialize(MajorKey(), arraysize(registers), registers,
                          Runtime::FunctionForId(Runtime::kStringAdd)->entry);
 }
 
@@ -283,7 +283,7 @@ void CallDescriptors::InitializeForIsolate(Isolate* isolate) {
         Representation::Integer32(),  // actual number of arguments
         Representation::Integer32(),  // expected number of arguments
     };
-    descriptor->Initialize(ARRAY_SIZE(registers), registers, representations);
+    descriptor->Initialize(arraysize(registers), registers, representations);
   }
   {
     CallInterfaceDescriptor* descriptor =
@@ -295,7 +295,7 @@ void CallDescriptors::InitializeForIsolate(Isolate* isolate) {
         Representation::Tagged(),     // context
         Representation::Tagged(),     // key
     };
-    descriptor->Initialize(ARRAY_SIZE(registers), registers, representations);
+    descriptor->Initialize(arraysize(registers), registers, representations);
   }
   {
     CallInterfaceDescriptor* descriptor =
@@ -307,7 +307,7 @@ void CallDescriptors::InitializeForIsolate(Isolate* isolate) {
         Representation::Tagged(),     // context
         Representation::Tagged(),     // name
     };
-    descriptor->Initialize(ARRAY_SIZE(registers), registers, representations);
+    descriptor->Initialize(arraysize(registers), registers, representations);
   }
   {
     CallInterfaceDescriptor* descriptor =
@@ -319,7 +319,7 @@ void CallDescriptors::InitializeForIsolate(Isolate* isolate) {
         Representation::Tagged(),     // context
         Representation::Tagged(),     // receiver
     };
-    descriptor->Initialize(ARRAY_SIZE(registers), registers, representations);
+    descriptor->Initialize(arraysize(registers), registers, representations);
   }
   {
     CallInterfaceDescriptor* descriptor =
@@ -337,7 +337,7 @@ void CallDescriptors::InitializeForIsolate(Isolate* isolate) {
         Representation::Tagged(),    // holder
         Representation::External(),  // api_function_address
     };
-    descriptor->Initialize(ARRAY_SIZE(registers), registers, representations);
+    descriptor->Initialize(arraysize(registers), registers, representations);
   }
 }
 
index 0f1f702..abd2e34 100644 (file)
@@ -2269,7 +2269,7 @@ Handle<JSObject> Isolate::GetSymbolRegistry() {
     static const char* nested[] = {
       "for", "for_api", "for_intern", "keyFor", "private_api", "private_intern"
     };
-    for (unsigned i = 0; i < ARRAY_SIZE(nested); ++i) {
+    for (unsigned i = 0; i < arraysize(nested); ++i) {
       Handle<String> name = factory()->InternalizeUtf8String(nested[i]);
       Handle<JSObject> obj = factory()->NewJSObjectFromMap(map);
       JSObject::NormalizeProperties(obj, KEEP_INOBJECT_PROPERTIES, 8);
index 27b8699..3853197 100644 (file)
@@ -53,7 +53,7 @@ MaybeHandle<Object> RegExpImpl::CreateRegExpLiteral(
     Handle<String> flags) {
   // Call the construct code with 2 arguments.
   Handle<Object> argv[] = { pattern, flags };
-  return Execution::New(constructor, ARRAY_SIZE(argv), argv);
+  return Execution::New(constructor, arraysize(argv), argv);
 }
 
 
@@ -3588,18 +3588,18 @@ static const int kSpaceRanges[] = { '\t', '\r' + 1, ' ', ' ' + 1,
     0x00A0, 0x00A1, 0x1680, 0x1681, 0x180E, 0x180F, 0x2000, 0x200B,
     0x2028, 0x202A, 0x202F, 0x2030, 0x205F, 0x2060, 0x3000, 0x3001,
     0xFEFF, 0xFF00, 0x10000 };
-static const int kSpaceRangeCount = ARRAY_SIZE(kSpaceRanges);
+static const int kSpaceRangeCount = arraysize(kSpaceRanges);
 
 static const int kWordRanges[] = {
     '0', '9' + 1, 'A', 'Z' + 1, '_', '_' + 1, 'a', 'z' + 1, 0x10000 };
-static const int kWordRangeCount = ARRAY_SIZE(kWordRanges);
+static const int kWordRangeCount = arraysize(kWordRanges);
 static const int kDigitRanges[] = { '0', '9' + 1, 0x10000 };
-static const int kDigitRangeCount = ARRAY_SIZE(kDigitRanges);
+static const int kDigitRangeCount = arraysize(kDigitRanges);
 static const int kSurrogateRanges[] = { 0xd800, 0xe000, 0x10000 };
-static const int kSurrogateRangeCount = ARRAY_SIZE(kSurrogateRanges);
+static const int kSurrogateRangeCount = arraysize(kSurrogateRanges);
 static const int kLineTerminatorRanges[] = { 0x000A, 0x000B, 0x000D, 0x000E,
     0x2028, 0x202A, 0x10000 };
-static const int kLineTerminatorRangeCount = ARRAY_SIZE(kLineTerminatorRanges);
+static const int kLineTerminatorRangeCount = arraysize(kLineTerminatorRanges);
 
 
 void BoyerMoorePositionInfo::Set(int character) {
index 8b6444d..90efa53 100644 (file)
@@ -132,7 +132,7 @@ void LCodeGenBase::CheckEnvironmentUsage() {
 void LCodeGenBase::Comment(const char* format, ...) {
   if (!FLAG_code_comments) return;
   char buffer[4 * KB];
-  StringBuilder builder(buffer, ARRAY_SIZE(buffer));
+  StringBuilder builder(buffer, arraysize(buffer));
   va_list arguments;
   va_start(arguments, format);
   builder.AddFormattedList(format, arguments);
index 865bdca..50b204a 100644 (file)
@@ -138,7 +138,7 @@ Handle<String> MessageHandler::GetMessage(Isolate* isolate,
                             Handle<Object>(message->arguments(), isolate) };
 
   MaybeHandle<Object> maybe_result = Execution::TryCall(
-      fun, isolate->js_builtins_object(), ARRAY_SIZE(argv), argv);
+      fun, isolate->js_builtins_object(), arraysize(argv), argv);
   Handle<Object> result;
   if (!maybe_result.ToHandle(&result) || !result->IsString()) {
     return factory->InternalizeOneByteString(STATIC_ASCII_VECTOR("<error>"));
index 0b844a5..325a7b0 100644 (file)
@@ -23,7 +23,7 @@ void FastNewClosureStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   Register registers[] = { cp, a2 };
   descriptor->Initialize(
-      MajorKey(), ARRAY_SIZE(registers), registers,
+      MajorKey(), arraysize(registers), registers,
       Runtime::FunctionForId(Runtime::kNewClosureFromStubFailure)->entry);
 }
 
@@ -31,14 +31,14 @@ void FastNewClosureStub::InitializeInterfaceDescriptor(
 void FastNewContextStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   Register registers[] = { cp, a1 };
-  descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers);
+  descriptor->Initialize(MajorKey(), arraysize(registers), registers);
 }
 
 
 void ToNumberStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   Register registers[] = { cp, a0 };
-  descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers);
+  descriptor->Initialize(MajorKey(), arraysize(registers), registers);
 }
 
 
@@ -46,7 +46,7 @@ void NumberToStringStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   Register registers[] = { cp, a0 };
   descriptor->Initialize(
-      MajorKey(), ARRAY_SIZE(registers), registers,
+      MajorKey(), arraysize(registers), registers,
       Runtime::FunctionForId(Runtime::kNumberToStringRT)->entry);
 }
 
@@ -60,7 +60,7 @@ void FastCloneShallowArrayStub::InitializeInterfaceDescriptor(
     Representation::Smi(),
     Representation::Tagged() };
   descriptor->Initialize(
-      MajorKey(), ARRAY_SIZE(registers), registers,
+      MajorKey(), arraysize(registers), registers,
       Runtime::FunctionForId(Runtime::kCreateArrayLiteralStubBailout)->entry,
       representations);
 }
@@ -70,7 +70,7 @@ void FastCloneShallowObjectStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   Register registers[] = { cp, a3, a2, a1, a0 };
   descriptor->Initialize(
-      MajorKey(), ARRAY_SIZE(registers), registers,
+      MajorKey(), arraysize(registers), registers,
       Runtime::FunctionForId(Runtime::kCreateObjectLiteral)->entry);
 }
 
@@ -78,7 +78,7 @@ void FastCloneShallowObjectStub::InitializeInterfaceDescriptor(
 void CreateAllocationSiteStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   Register registers[] = { cp, a2, a3 };
-  descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers);
+  descriptor->Initialize(MajorKey(), arraysize(registers), registers);
 }
 
 
@@ -98,7 +98,7 @@ void RegExpConstructResultStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   Register registers[] = { cp, a2, a1, a0 };
   descriptor->Initialize(
-      MajorKey(), ARRAY_SIZE(registers), registers,
+      MajorKey(), arraysize(registers), registers,
       Runtime::FunctionForId(Runtime::kRegExpConstructResult)->entry);
 }
 
@@ -108,7 +108,7 @@ void TransitionElementsKindStub::InitializeInterfaceDescriptor(
   Register registers[] = { cp, a0, a1 };
   Address entry =
       Runtime::FunctionForId(Runtime::kTransitionElementsKind)->entry;
-  descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers,
+  descriptor->Initialize(MajorKey(), arraysize(registers), registers,
                          FUNCTION_ADDR(entry));
 }
 
@@ -116,7 +116,7 @@ void TransitionElementsKindStub::InitializeInterfaceDescriptor(
 void CompareNilICStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   Register registers[] = { cp, a0 };
-  descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers,
+  descriptor->Initialize(MajorKey(), arraysize(registers), registers,
                          FUNCTION_ADDR(CompareNilIC_Miss));
   descriptor->SetMissHandler(
       ExternalReference(IC_Utility(IC::kCompareNilIC_Miss), isolate()));
@@ -139,7 +139,7 @@ static void InitializeArrayConstructorDescriptor(
 
   if (constant_stack_parameter_count == 0) {
     Register registers[] = { cp, a1, a2 };
-    descriptor->Initialize(major, ARRAY_SIZE(registers), registers,
+    descriptor->Initialize(major, arraysize(registers), registers,
                            deopt_handler, NULL, constant_stack_parameter_count,
                            JS_FUNCTION_STUB_MODE);
   } else {
@@ -150,7 +150,7 @@ static void InitializeArrayConstructorDescriptor(
         Representation::Tagged(),
         Representation::Tagged(),
         Representation::Integer32() };
-    descriptor->Initialize(major, ARRAY_SIZE(registers), registers, a0,
+    descriptor->Initialize(major, arraysize(registers), registers, a0,
                            deopt_handler, representations,
                            constant_stack_parameter_count,
                            JS_FUNCTION_STUB_MODE, PASS_ARGUMENTS);
@@ -170,7 +170,7 @@ static void InitializeInternalArrayConstructorDescriptor(
 
   if (constant_stack_parameter_count == 0) {
     Register registers[] = { cp, a1 };
-    descriptor->Initialize(major, ARRAY_SIZE(registers), registers,
+    descriptor->Initialize(major, arraysize(registers), registers,
                            deopt_handler, NULL, constant_stack_parameter_count,
                            JS_FUNCTION_STUB_MODE);
   } else {
@@ -180,7 +180,7 @@ static void InitializeInternalArrayConstructorDescriptor(
         Representation::Tagged(),
         Representation::Tagged(),
         Representation::Integer32() };
-    descriptor->Initialize(major, ARRAY_SIZE(registers), registers, a0,
+    descriptor->Initialize(major, arraysize(registers), registers, a0,
                            deopt_handler, representations,
                            constant_stack_parameter_count,
                            JS_FUNCTION_STUB_MODE, PASS_ARGUMENTS);
@@ -209,7 +209,7 @@ void ArrayNArgumentsConstructorStub::InitializeInterfaceDescriptor(
 void ToBooleanStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   Register registers[] = { cp, a0 };
-  descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers,
+  descriptor->Initialize(MajorKey(), arraysize(registers), registers,
                          FUNCTION_ADDR(ToBooleanIC_Miss));
   descriptor->SetMissHandler(
       ExternalReference(IC_Utility(IC::kToBooleanIC_Miss), isolate()));
@@ -237,7 +237,7 @@ void InternalArrayNArgumentsConstructorStub::InitializeInterfaceDescriptor(
 void BinaryOpICStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   Register registers[] = { cp, a1, a0 };
-  descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers,
+  descriptor->Initialize(MajorKey(), arraysize(registers), registers,
                          FUNCTION_ADDR(BinaryOpIC_Miss));
   descriptor->SetMissHandler(
       ExternalReference(IC_Utility(IC::kBinaryOpIC_Miss), isolate()));
@@ -247,7 +247,7 @@ void BinaryOpICStub::InitializeInterfaceDescriptor(
 void BinaryOpWithAllocationSiteStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   Register registers[] = { cp, a2, a1, a0 };
-  descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers,
+  descriptor->Initialize(MajorKey(), arraysize(registers), registers,
                          FUNCTION_ADDR(BinaryOpIC_MissWithAllocationSite));
 }
 
@@ -255,7 +255,7 @@ void BinaryOpWithAllocationSiteStub::InitializeInterfaceDescriptor(
 void StringAddStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   Register registers[] = { cp, a1, a0 };
-  descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers,
+  descriptor->Initialize(MajorKey(), arraysize(registers), registers,
                          Runtime::FunctionForId(Runtime::kStringAdd)->entry);
 }
 
@@ -275,7 +275,7 @@ void CallDescriptors::InitializeForIsolate(Isolate* isolate) {
         Representation::Integer32(),  // actual number of arguments
         Representation::Integer32(),  // expected number of arguments
     };
-    descriptor->Initialize(ARRAY_SIZE(registers), registers, representations);
+    descriptor->Initialize(arraysize(registers), registers, representations);
   }
   {
     CallInterfaceDescriptor* descriptor =
@@ -287,7 +287,7 @@ void CallDescriptors::InitializeForIsolate(Isolate* isolate) {
         Representation::Tagged(),     // context
         Representation::Tagged(),     // key
     };
-    descriptor->Initialize(ARRAY_SIZE(registers), registers, representations);
+    descriptor->Initialize(arraysize(registers), registers, representations);
   }
   {
     CallInterfaceDescriptor* descriptor =
@@ -299,7 +299,7 @@ void CallDescriptors::InitializeForIsolate(Isolate* isolate) {
         Representation::Tagged(),     // context
         Representation::Tagged(),     // name
     };
-    descriptor->Initialize(ARRAY_SIZE(registers), registers, representations);
+    descriptor->Initialize(arraysize(registers), registers, representations);
   }
   {
     CallInterfaceDescriptor* descriptor =
@@ -311,7 +311,7 @@ void CallDescriptors::InitializeForIsolate(Isolate* isolate) {
         Representation::Tagged(),  // context
         Representation::Tagged(),  // receiver
     };
-    descriptor->Initialize(ARRAY_SIZE(registers), registers, representations);
+    descriptor->Initialize(arraysize(registers), registers, representations);
   }
   {
     CallInterfaceDescriptor* descriptor =
@@ -329,7 +329,7 @@ void CallDescriptors::InitializeForIsolate(Isolate* isolate) {
         Representation::Tagged(),    // holder
         Representation::External(),  // api_function_address
     };
-    descriptor->Initialize(ARRAY_SIZE(registers), registers, representations);
+    descriptor->Initialize(arraysize(registers), registers, representations);
   }
 }
 
index 78a169c..ba3ee62 100644 (file)
@@ -23,7 +23,7 @@ void FastNewClosureStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   Register registers[] = { cp, a2 };
   descriptor->Initialize(
-      MajorKey(), ARRAY_SIZE(registers), registers,
+      MajorKey(), arraysize(registers), registers,
       Runtime::FunctionForId(Runtime::kNewClosureFromStubFailure)->entry);
 }
 
@@ -31,14 +31,14 @@ void FastNewClosureStub::InitializeInterfaceDescriptor(
 void FastNewContextStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   Register registers[] = { cp, a1 };
-  descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers);
+  descriptor->Initialize(MajorKey(), arraysize(registers), registers);
 }
 
 
 void ToNumberStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   Register registers[] = { cp, a0 };
-  descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers);
+  descriptor->Initialize(MajorKey(), arraysize(registers), registers);
 }
 
 
@@ -46,7 +46,7 @@ void NumberToStringStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   Register registers[] = { cp, a0 };
   descriptor->Initialize(
-      MajorKey(), ARRAY_SIZE(registers), registers,
+      MajorKey(), arraysize(registers), registers,
       Runtime::FunctionForId(Runtime::kNumberToStringRT)->entry);
 }
 
@@ -60,7 +60,7 @@ void FastCloneShallowArrayStub::InitializeInterfaceDescriptor(
     Representation::Smi(),
     Representation::Tagged() };
   descriptor->Initialize(
-      MajorKey(), ARRAY_SIZE(registers), registers,
+      MajorKey(), arraysize(registers), registers,
       Runtime::FunctionForId(Runtime::kCreateArrayLiteralStubBailout)->entry,
       representations);
 }
@@ -70,7 +70,7 @@ void FastCloneShallowObjectStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   Register registers[] = { cp, a3, a2, a1, a0 };
   descriptor->Initialize(
-      MajorKey(), ARRAY_SIZE(registers), registers,
+      MajorKey(), arraysize(registers), registers,
       Runtime::FunctionForId(Runtime::kCreateObjectLiteral)->entry);
 }
 
@@ -90,7 +90,7 @@ void CallConstructStub::InitializeInterfaceDescriptor(
 void CreateAllocationSiteStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   Register registers[] = { cp, a2, a3 };
-  descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers);
+  descriptor->Initialize(MajorKey(), arraysize(registers), registers);
 }
 
 
@@ -98,7 +98,7 @@ void RegExpConstructResultStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   Register registers[] = { cp, a2, a1, a0 };
   descriptor->Initialize(
-      MajorKey(), ARRAY_SIZE(registers), registers,
+      MajorKey(), arraysize(registers), registers,
       Runtime::FunctionForId(Runtime::kRegExpConstructResult)->entry);
 }
 
@@ -108,7 +108,7 @@ void TransitionElementsKindStub::InitializeInterfaceDescriptor(
   Register registers[] = { cp, a0, a1 };
   Address entry =
       Runtime::FunctionForId(Runtime::kTransitionElementsKind)->entry;
-  descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers,
+  descriptor->Initialize(MajorKey(), arraysize(registers), registers,
                          FUNCTION_ADDR(entry));
 }
 
@@ -116,7 +116,7 @@ void TransitionElementsKindStub::InitializeInterfaceDescriptor(
 void CompareNilICStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   Register registers[] = { cp, a0 };
-  descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers,
+  descriptor->Initialize(MajorKey(), arraysize(registers), registers,
                          FUNCTION_ADDR(CompareNilIC_Miss));
   descriptor->SetMissHandler(
       ExternalReference(IC_Utility(IC::kCompareNilIC_Miss), isolate()));
@@ -139,7 +139,7 @@ static void InitializeArrayConstructorDescriptor(
 
   if (constant_stack_parameter_count == 0) {
     Register registers[] = { cp, a1, a2 };
-    descriptor->Initialize(major, ARRAY_SIZE(registers), registers,
+    descriptor->Initialize(major, arraysize(registers), registers,
                            deopt_handler, NULL, constant_stack_parameter_count,
                            JS_FUNCTION_STUB_MODE);
   } else {
@@ -150,7 +150,7 @@ static void InitializeArrayConstructorDescriptor(
         Representation::Tagged(),
         Representation::Tagged(),
         Representation::Integer32() };
-    descriptor->Initialize(major, ARRAY_SIZE(registers), registers, a0,
+    descriptor->Initialize(major, arraysize(registers), registers, a0,
                            deopt_handler, representations,
                            constant_stack_parameter_count,
                            JS_FUNCTION_STUB_MODE, PASS_ARGUMENTS);
@@ -170,7 +170,7 @@ static void InitializeInternalArrayConstructorDescriptor(
 
   if (constant_stack_parameter_count == 0) {
     Register registers[] = { cp, a1 };
-    descriptor->Initialize(major, ARRAY_SIZE(registers), registers,
+    descriptor->Initialize(major, arraysize(registers), registers,
                            deopt_handler, NULL, constant_stack_parameter_count,
                            JS_FUNCTION_STUB_MODE);
   } else {
@@ -180,7 +180,7 @@ static void InitializeInternalArrayConstructorDescriptor(
         Representation::Tagged(),
         Representation::Tagged(),
         Representation::Integer32() };
-    descriptor->Initialize(major, ARRAY_SIZE(registers), registers, a0,
+    descriptor->Initialize(major, arraysize(registers), registers, a0,
                            deopt_handler, representations,
                            constant_stack_parameter_count,
                            JS_FUNCTION_STUB_MODE, PASS_ARGUMENTS);
@@ -209,7 +209,7 @@ void ArrayNArgumentsConstructorStub::InitializeInterfaceDescriptor(
 void ToBooleanStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   Register registers[] = { cp, a0 };
-  descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers,
+  descriptor->Initialize(MajorKey(), arraysize(registers), registers,
                          FUNCTION_ADDR(ToBooleanIC_Miss));
   descriptor->SetMissHandler(
       ExternalReference(IC_Utility(IC::kToBooleanIC_Miss), isolate()));
@@ -237,7 +237,7 @@ void InternalArrayNArgumentsConstructorStub::InitializeInterfaceDescriptor(
 void BinaryOpICStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   Register registers[] = { cp, a1, a0 };
-  descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers,
+  descriptor->Initialize(MajorKey(), arraysize(registers), registers,
                          FUNCTION_ADDR(BinaryOpIC_Miss));
   descriptor->SetMissHandler(
       ExternalReference(IC_Utility(IC::kBinaryOpIC_Miss), isolate()));
@@ -247,7 +247,7 @@ void BinaryOpICStub::InitializeInterfaceDescriptor(
 void BinaryOpWithAllocationSiteStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   Register registers[] = { cp, a2, a1, a0 };
-  descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers,
+  descriptor->Initialize(MajorKey(), arraysize(registers), registers,
                          FUNCTION_ADDR(BinaryOpIC_MissWithAllocationSite));
 }
 
@@ -255,7 +255,7 @@ void BinaryOpWithAllocationSiteStub::InitializeInterfaceDescriptor(
 void StringAddStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   Register registers[] = { cp, a1, a0 };
-  descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers,
+  descriptor->Initialize(MajorKey(), arraysize(registers), registers,
                          Runtime::FunctionForId(Runtime::kStringAdd)->entry);
 }
 
@@ -275,7 +275,7 @@ void CallDescriptors::InitializeForIsolate(Isolate* isolate) {
         Representation::Integer32(),  // actual number of arguments
         Representation::Integer32(),  // expected number of arguments
     };
-    descriptor->Initialize(ARRAY_SIZE(registers), registers, representations);
+    descriptor->Initialize(arraysize(registers), registers, representations);
   }
   {
     CallInterfaceDescriptor* descriptor =
@@ -287,7 +287,7 @@ void CallDescriptors::InitializeForIsolate(Isolate* isolate) {
         Representation::Tagged(),     // context
         Representation::Tagged(),     // key
     };
-    descriptor->Initialize(ARRAY_SIZE(registers), registers, representations);
+    descriptor->Initialize(arraysize(registers), registers, representations);
   }
   {
     CallInterfaceDescriptor* descriptor =
@@ -299,7 +299,7 @@ void CallDescriptors::InitializeForIsolate(Isolate* isolate) {
         Representation::Tagged(),     // context
         Representation::Tagged(),     // name
     };
-    descriptor->Initialize(ARRAY_SIZE(registers), registers, representations);
+    descriptor->Initialize(arraysize(registers), registers, representations);
   }
   {
     CallInterfaceDescriptor* descriptor =
@@ -311,7 +311,7 @@ void CallDescriptors::InitializeForIsolate(Isolate* isolate) {
         Representation::Tagged(),  // context
         Representation::Tagged(),  // receiver
     };
-    descriptor->Initialize(ARRAY_SIZE(registers), registers, representations);
+    descriptor->Initialize(arraysize(registers), registers, representations);
   }
   {
     CallInterfaceDescriptor* descriptor =
@@ -329,7 +329,7 @@ void CallDescriptors::InitializeForIsolate(Isolate* isolate) {
         Representation::Tagged(),    // holder
         Representation::External(),  // api_function_address
     };
-    descriptor->Initialize(ARRAY_SIZE(registers), registers, representations);
+    descriptor->Initialize(arraysize(registers), registers, representations);
   }
 }
 
index 37b174e..71a78a9 100644 (file)
@@ -91,12 +91,12 @@ class SnapshotWriter {
 
     i::byte* snapshot_bytes = snapshot_data.begin();
     sink.PutBlob(snapshot_bytes, snapshot_data.length(), "snapshot");
-    for (size_t i = 0; i < ARRAY_SIZE(spaces); ++i)
+    for (size_t i = 0; i < arraysize(spaces); ++i)
       sink.PutInt(serializer.CurrentAllocationAddress(spaces[i]), "spaces");
 
     i::byte* context_bytes = context_snapshot_data.begin();
     sink.PutBlob(context_bytes, context_snapshot_data.length(), "context");
-    for (size_t i = 0; i < ARRAY_SIZE(spaces); ++i)
+    for (size_t i = 0; i < arraysize(spaces); ++i)
       sink.PutInt(context_serializer.CurrentAllocationAddress(spaces[i]),
                   "spaces");
 
index e3c45c4..3f1bdc6 100644 (file)
@@ -409,7 +409,7 @@ MaybeHandle<Object> JSProxy::GetPropertyWithHandler(Handle<JSProxy> proxy,
 
   Handle<Object> args[] = { receiver, name };
   return CallTrap(
-      proxy, "get",  isolate->derived_get_trap(), ARRAY_SIZE(args), args);
+      proxy, "get",  isolate->derived_get_trap(), arraysize(args), args);
 }
 
 
@@ -427,7 +427,7 @@ MaybeHandle<Object> Object::GetPropertyWithAccessor(Handle<Object> receiver,
       Handle<Object> error =
           isolate->factory()->NewTypeError("incompatible_method_receiver",
                                            HandleVector(args,
-                                                        ARRAY_SIZE(args)));
+                                                        arraysize(args)));
       return isolate->Throw<Object>(error);
     }
     if (structure->IsDeclaredAccessorInfo()) {
@@ -499,7 +499,7 @@ MaybeHandle<Object> Object::SetPropertyWithAccessor(
       Handle<Object> error =
           isolate->factory()->NewTypeError("incompatible_method_receiver",
                                            HandleVector(args,
-                                                        ARRAY_SIZE(args)));
+                                                        arraysize(args)));
       return isolate->Throw<Object>(error);
     }
     Object* call_obj = info->setter();
@@ -573,7 +573,7 @@ MaybeHandle<Object> Object::SetPropertyWithDefinedSetter(
 
   Handle<Object> argv[] = { value };
   RETURN_ON_EXCEPTION(isolate, Execution::Call(isolate, setter, receiver,
-                                               ARRAY_SIZE(argv), argv, true),
+                                               arraysize(argv), argv, true),
                       Object);
   return value;
 }
@@ -2927,7 +2927,7 @@ MaybeHandle<Object> Object::WriteToReadOnlyProperty(LookupIterator* it,
 
   Handle<Object> args[] = {it->name(), it->GetReceiver()};
   Handle<Object> error = it->factory()->NewTypeError(
-      "strict_read_only_property", HandleVector(args, ARRAY_SIZE(args)));
+      "strict_read_only_property", HandleVector(args, arraysize(args)));
   return it->isolate()->Throw<Object>(error);
 }
 
@@ -2992,7 +2992,7 @@ MaybeHandle<Object> Object::AddDataProperty(LookupIterator* it,
 
     Handle<Object> args[1] = {it->name()};
     Handle<Object> error = it->factory()->NewTypeError(
-        "object_not_extensible", HandleVector(args, ARRAY_SIZE(args)));
+        "object_not_extensible", HandleVector(args, arraysize(args)));
     return it->isolate()->Throw<Object>(error);
   }
   it->ApplyTransitionToDataProperty();
@@ -3401,7 +3401,7 @@ Maybe<bool> JSProxy::HasPropertyWithHandler(Handle<JSProxy> proxy,
   Handle<Object> result;
   ASSIGN_RETURN_ON_EXCEPTION_VALUE(
       isolate, result, CallTrap(proxy, "has", isolate->derived_has_trap(),
-                                ARRAY_SIZE(args), args),
+                                arraysize(args), args),
       Maybe<bool>());
 
   return maybe(result->BooleanValue());
@@ -3424,7 +3424,7 @@ MaybeHandle<Object> JSProxy::SetPropertyWithHandler(Handle<JSProxy> proxy,
       CallTrap(proxy,
                "set",
                isolate->derived_set_trap(),
-               ARRAY_SIZE(args),
+               arraysize(args),
                args),
       Object);
 
@@ -3452,7 +3452,7 @@ MaybeHandle<Object> JSProxy::SetPropertyViaPrototypesWithHandler(
       CallTrap(proxy,
                "getPropertyDescriptor",
                Handle<Object>(),
-               ARRAY_SIZE(args),
+               arraysize(args),
                args),
       Object);
 
@@ -3469,7 +3469,7 @@ MaybeHandle<Object> JSProxy::SetPropertyViaPrototypesWithHandler(
       Execution::Call(isolate,
                       isolate->to_complete_property_descriptor(),
                       result,
-                      ARRAY_SIZE(argv),
+                      arraysize(argv),
                       argv),
       Object);
 
@@ -3486,7 +3486,7 @@ MaybeHandle<Object> JSProxy::SetPropertyViaPrototypesWithHandler(
             STATIC_ASCII_VECTOR("getPropertyDescriptor"));
     Handle<Object> args[] = { handler, trap, name };
     Handle<Object> error = isolate->factory()->NewTypeError(
-        "proxy_prop_not_configurable", HandleVector(args, ARRAY_SIZE(args)));
+        "proxy_prop_not_configurable", HandleVector(args, arraysize(args)));
     return isolate->Throw<Object>(error);
   }
   DCHECK(configurable->IsTrue());
@@ -3510,7 +3510,7 @@ MaybeHandle<Object> JSProxy::SetPropertyViaPrototypesWithHandler(
     if (strict_mode == SLOPPY) return value;
     Handle<Object> args[] = { name, receiver };
     Handle<Object> error = isolate->factory()->NewTypeError(
-        "strict_read_only_property", HandleVector(args, ARRAY_SIZE(args)));
+        "strict_read_only_property", HandleVector(args, arraysize(args)));
     return isolate->Throw<Object>(error);
   }
 
@@ -3527,7 +3527,7 @@ MaybeHandle<Object> JSProxy::SetPropertyViaPrototypesWithHandler(
   if (strict_mode == SLOPPY) return value;
   Handle<Object> args2[] = { name, proxy };
   Handle<Object> error = isolate->factory()->NewTypeError(
-      "no_setter_in_callback", HandleVector(args2, ARRAY_SIZE(args2)));
+      "no_setter_in_callback", HandleVector(args2, arraysize(args2)));
   return isolate->Throw<Object>(error);
 }
 
@@ -3546,7 +3546,7 @@ MaybeHandle<Object> JSProxy::DeletePropertyWithHandler(
       CallTrap(proxy,
                "delete",
                Handle<Object>(),
-               ARRAY_SIZE(args),
+               arraysize(args),
                args),
       Object);
 
@@ -3557,7 +3557,7 @@ MaybeHandle<Object> JSProxy::DeletePropertyWithHandler(
         STATIC_ASCII_VECTOR("delete"));
     Handle<Object> args[] = { handler, trap_name };
     Handle<Object> error = isolate->factory()->NewTypeError(
-        "handler_failed", HandleVector(args, ARRAY_SIZE(args)));
+        "handler_failed", HandleVector(args, arraysize(args)));
     return isolate->Throw<Object>(error);
   }
   return isolate->factory()->ToBoolean(result_bool);
@@ -3585,7 +3585,7 @@ Maybe<PropertyAttributes> JSProxy::GetPropertyAttributesWithHandler(
   ASSIGN_RETURN_ON_EXCEPTION_VALUE(
       isolate, result,
       proxy->CallTrap(proxy, "getPropertyDescriptor", Handle<Object>(),
-                      ARRAY_SIZE(args), args),
+                      arraysize(args), args),
       Maybe<PropertyAttributes>());
 
   if (result->IsUndefined()) return maybe(ABSENT);
@@ -3595,7 +3595,7 @@ Maybe<PropertyAttributes> JSProxy::GetPropertyAttributesWithHandler(
   ASSIGN_RETURN_ON_EXCEPTION_VALUE(
       isolate, desc,
       Execution::Call(isolate, isolate->to_complete_property_descriptor(),
-                      result, ARRAY_SIZE(argv), argv),
+                      result, arraysize(argv), argv),
       Maybe<PropertyAttributes>());
 
   // Convert result to PropertyAttributes.
@@ -3633,7 +3633,7 @@ Maybe<PropertyAttributes> JSProxy::GetPropertyAttributesWithHandler(
         STATIC_ASCII_VECTOR("getPropertyDescriptor"));
     Handle<Object> args[] = { handler, trap, name };
     Handle<Object> error = isolate->factory()->NewTypeError(
-        "proxy_prop_not_configurable", HandleVector(args, ARRAY_SIZE(args)));
+        "proxy_prop_not_configurable", HandleVector(args, arraysize(args)));
     isolate->Throw(*error);
     return maybe(NONE);
   }
@@ -3695,7 +3695,7 @@ MaybeHandle<Object> JSProxy::CallTrap(Handle<JSProxy> proxy,
     if (derived.is_null()) {
       Handle<Object> args[] = { handler, trap_name };
       Handle<Object> error = isolate->factory()->NewTypeError(
-        "handler_trap_missing", HandleVector(args, ARRAY_SIZE(args)));
+        "handler_trap_missing", HandleVector(args, arraysize(args)));
       return isolate->Throw<Object>(error);
     }
     trap = Handle<Object>(derived);
@@ -4958,7 +4958,7 @@ MaybeHandle<Object> JSObject::DeleteProperty(Handle<JSObject> object,
           if (delete_mode == STRICT_DELETION) {
             Handle<Object> args[2] = {name, object};
             Handle<Object> error = it.isolate()->factory()->NewTypeError(
-                "strict_delete_property", HandleVector(args, ARRAY_SIZE(args)));
+                "strict_delete_property", HandleVector(args, arraysize(args)));
             it.isolate()->Throw(*error);
             return Handle<Object>();
           }
@@ -5823,7 +5823,7 @@ MaybeHandle<FixedArray> JSReceiver::GetKeys(Handle<JSReceiver> object,
           Execution::Call(isolate,
                           isolate->proxy_enumerate(),
                           object,
-                          ARRAY_SIZE(args),
+                          arraysize(args),
                           args),
           FixedArray);
       ASSIGN_RETURN_ON_EXCEPTION(
@@ -11168,7 +11168,7 @@ static void EnqueueSpliceRecord(Handle<JSArray> object,
   Execution::Call(isolate,
                   Handle<JSFunction>(isolate->observers_enqueue_splice()),
                   isolate->factory()->undefined_value(),
-                  ARRAY_SIZE(args),
+                  arraysize(args),
                   args).Assert();
 }
 
@@ -11181,7 +11181,7 @@ static void BeginPerformSplice(Handle<JSArray> object) {
   Execution::Call(isolate,
                   Handle<JSFunction>(isolate->observers_begin_perform_splice()),
                   isolate->factory()->undefined_value(),
-                  ARRAY_SIZE(args),
+                  arraysize(args),
                   args).Assert();
 }
 
@@ -11194,7 +11194,7 @@ static void EndPerformSplice(Handle<JSArray> object) {
   Execution::Call(isolate,
                   Handle<JSFunction>(isolate->observers_end_perform_splice()),
                   isolate->factory()->undefined_value(),
-                  ARRAY_SIZE(args),
+                  arraysize(args),
                   args).Assert();
 }
 
@@ -11714,7 +11714,7 @@ MaybeHandle<Object> JSObject::SetPrototype(Handle<JSObject> object,
   if (!object->map()->is_extensible()) {
     Handle<Object> args[] = { object };
     Handle<Object> error = isolate->factory()->NewTypeError(
-        "non_extensible_proto", HandleVector(args, ARRAY_SIZE(args)));
+        "non_extensible_proto", HandleVector(args, arraysize(args)));
     return isolate->Throw<Object>(error);
   }
 
@@ -12413,7 +12413,7 @@ MaybeHandle<Object> JSObject::SetElement(Handle<JSObject> object,
     Handle<Object> number = isolate->factory()->NewNumberFromUint(index);
     Handle<Object> args[] = { object, number };
     Handle<Object> error = isolate->factory()->NewTypeError(
-        "redef_external_array_element", HandleVector(args, ARRAY_SIZE(args)));
+        "redef_external_array_element", HandleVector(args, arraysize(args)));
     return isolate->Throw<Object>(error);
   }
 
@@ -12867,7 +12867,7 @@ MaybeHandle<Object> JSArray::ReadOnlyLengthError(Handle<JSArray> array) {
   Handle<Name> length = isolate->factory()->length_string();
   Handle<Object> args[2] = { length, array };
   Handle<Object> error = isolate->factory()->NewTypeError(
-      "strict_read_only_property", HandleVector(args, ARRAY_SIZE(args)));
+      "strict_read_only_property", HandleVector(args, arraysize(args)));
   return isolate->Throw<Object>(error);
 }
 
index 00a1b16..a3061dc 100644 (file)
@@ -632,7 +632,7 @@ const AstRawString* ParserTraits::GetNumberAsSymbol(Scanner* scanner) {
   double double_value = parser_->scanner()->DoubleValue();
   char array[100];
   const char* string =
-      DoubleToCString(double_value, Vector<char>(array, ARRAY_SIZE(array)));
+      DoubleToCString(double_value, Vector<char>(array, arraysize(array)));
   return ast_value_factory()->GetOneByteString(string);
 }
 
index 63a57e9..0628ce4 100644 (file)
@@ -290,7 +290,7 @@ MUST_USE_RESULT static MaybeHandle<Object> CreateObjectLiteralBoilerplate(
       DCHECK(key->IsNumber());
       double num = key->Number();
       char arr[100];
-      Vector<char> buffer(arr, ARRAY_SIZE(arr));
+      Vector<char> buffer(arr, arraysize(arr));
       const char* str = DoubleToCString(num, buffer);
       Handle<String> name = isolate->factory()->NewStringFromAsciiChecked(str);
       maybe_result = JSObject::SetOwnPropertyIgnoreAttributes(boilerplate, name,
@@ -14333,7 +14333,7 @@ RUNTIME_FUNCTION(Runtime_StringNormalize) {
   CONVERT_ARG_HANDLE_CHECKED(String, stringValue, 0);
   CONVERT_NUMBER_CHECKED(int, form_id, Int32, args[1]);
   RUNTIME_ASSERT(form_id >= 0 &&
-                 static_cast<size_t>(form_id) < ARRAY_SIZE(normalizationForms));
+                 static_cast<size_t>(form_id) < arraysize(normalizationForms));
 
   v8::String::Value string_value(v8::Utils::ToLocal(stringValue));
   const UChar* u_value = reinterpret_cast<const UChar*>(*string_value);
@@ -14719,7 +14719,7 @@ RUNTIME_FUNCTION(Runtime_GetFromCache) {
     Handle<Object> argv[] = { key_handle };
     ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
         isolate, value,
-        Execution::Call(isolate, factory, receiver, ARRAY_SIZE(argv), argv));
+        Execution::Call(isolate, factory, receiver, arraysize(argv), argv));
   }
 
 #ifdef VERIFY_HEAP
@@ -15643,7 +15643,7 @@ const Runtime::Function* Runtime::FunctionForName(Handle<String> name) {
 
 
 const Runtime::Function* Runtime::FunctionForEntry(Address entry) {
-  for (size_t i = 0; i < ARRAY_SIZE(kIntrinsicFunctions); ++i) {
+  for (size_t i = 0; i < arraysize(kIntrinsicFunctions); ++i) {
     if (entry == kIntrinsicFunctions[i].entry) {
       return &(kIntrinsicFunctions[i]);
     }
index 4cb05fa..d13b00c 100644 (file)
@@ -314,7 +314,7 @@ void ExternalReferenceTable::PopulateTable(Isolate* isolate) {
 #undef IC_ENTRY
   };  // end of ref_table[].
 
-  for (size_t i = 0; i < ARRAY_SIZE(ref_table); ++i) {
+  for (size_t i = 0; i < arraysize(ref_table); ++i) {
     AddFromId(ref_table[i].type,
               ref_table[i].id,
               ref_table[i].name,
@@ -340,7 +340,7 @@ void ExternalReferenceTable::PopulateTable(Isolate* isolate) {
   };  // end of stats_ref_table[].
 
   Counters* counters = isolate->counters();
-  for (size_t i = 0; i < ARRAY_SIZE(stats_ref_table); ++i) {
+  for (size_t i = 0; i < arraysize(stats_ref_table); ++i) {
     Add(reinterpret_cast<Address>(GetInternalPointer(
             (counters->*(stats_ref_table[i].counter))())),
         STATS_COUNTER,
index 64b7a29..2b48af3 100644 (file)
@@ -63,7 +63,7 @@ static const double exact_powers_of_ten[] = {
   // 10^22 = 0x21e19e0c9bab2400000 = 0x878678326eac9 * 2^22
   10000000000000000000000.0
 };
-static const int kExactPowersOfTenSize = ARRAY_SIZE(exact_powers_of_ten);
+static const int kExactPowersOfTenSize = arraysize(exact_powers_of_ten);
 
 // Maximum number of significant digits in the decimal representation.
 // In fact the value is 772 (see conversions.cc), but to give us some margin
index db92f30..7d51982 100644 (file)
@@ -882,7 +882,7 @@ void TypeImpl<Config>::BitsetType::Print(OStream& os,  // NOLINT
 
   bool is_first = true;
   os << "(";
-  for (int i(ARRAY_SIZE(named_bitsets) - 1); bitset != 0 && i >= 0; --i) {
+  for (int i(arraysize(named_bitsets) - 1); bitset != 0 && i >= 0; --i) {
     int subset = named_bitsets[i];
     if ((bitset & subset) == subset) {
       if (!is_first) os << " | ";
index e12b916..a23f9e6 100644 (file)
@@ -153,7 +153,7 @@ inline int StrLength(const char* string) {
 
 #define STATIC_ASCII_VECTOR(x)                        \
   v8::internal::Vector<const uint8_t>(reinterpret_cast<const uint8_t*>(x), \
-                                      ARRAY_SIZE(x)-1)
+                                      arraysize(x)-1)
 
 inline Vector<const char> CStrVector(const char* data) {
   return Vector<const char>(data, StrLength(data));
index 55eede6..396a3a3 100644 (file)
@@ -23,7 +23,7 @@ void FastNewClosureStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   Register registers[] = { rsi, rbx };
   descriptor->Initialize(
-      MajorKey(), ARRAY_SIZE(registers), registers,
+      MajorKey(), arraysize(registers), registers,
       Runtime::FunctionForId(Runtime::kNewClosureFromStubFailure)->entry);
 }
 
@@ -31,14 +31,14 @@ void FastNewClosureStub::InitializeInterfaceDescriptor(
 void FastNewContextStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   Register registers[] = { rsi, rdi };
-  descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers);
+  descriptor->Initialize(MajorKey(), arraysize(registers), registers);
 }
 
 
 void ToNumberStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   Register registers[] = { rsi, rax };
-  descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers);
+  descriptor->Initialize(MajorKey(), arraysize(registers), registers);
 }
 
 
@@ -46,7 +46,7 @@ void NumberToStringStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   Register registers[] = { rsi, rax };
   descriptor->Initialize(
-      MajorKey(), ARRAY_SIZE(registers), registers,
+      MajorKey(), arraysize(registers), registers,
       Runtime::FunctionForId(Runtime::kNumberToStringRT)->entry);
 }
 
@@ -61,7 +61,7 @@ void FastCloneShallowArrayStub::InitializeInterfaceDescriptor(
     Representation::Tagged() };
 
   descriptor->Initialize(
-      MajorKey(), ARRAY_SIZE(registers), registers,
+      MajorKey(), arraysize(registers), registers,
       Runtime::FunctionForId(Runtime::kCreateArrayLiteralStubBailout)->entry,
       representations);
 }
@@ -71,7 +71,7 @@ void FastCloneShallowObjectStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   Register registers[] = { rsi, rax, rbx, rcx, rdx };
   descriptor->Initialize(
-      MajorKey(), ARRAY_SIZE(registers), registers,
+      MajorKey(), arraysize(registers), registers,
       Runtime::FunctionForId(Runtime::kCreateObjectLiteral)->entry);
 }
 
@@ -79,14 +79,14 @@ void FastCloneShallowObjectStub::InitializeInterfaceDescriptor(
 void CreateAllocationSiteStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   Register registers[] = { rsi, rbx, rdx };
-  descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers);
+  descriptor->Initialize(MajorKey(), arraysize(registers), registers);
 }
 
 
 void CallFunctionStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   Register registers[] = {rsi, rdi};
-  descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers);
+  descriptor->Initialize(MajorKey(), arraysize(registers), registers);
 }
 
 
@@ -100,7 +100,7 @@ void CallConstructStub::InitializeInterfaceDescriptor(
   // TODO(turbofan): So far we don't gather type feedback and hence skip the
   // slot parameter, but ArrayConstructStub needs the vector to be undefined.
   Register registers[] = {rsi, rax, rdi, rbx};
-  descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers);
+  descriptor->Initialize(MajorKey(), arraysize(registers), registers);
 }
 
 
@@ -108,7 +108,7 @@ void RegExpConstructResultStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   Register registers[] = { rsi, rcx, rbx, rax };
   descriptor->Initialize(
-      MajorKey(), ARRAY_SIZE(registers), registers,
+      MajorKey(), arraysize(registers), registers,
       Runtime::FunctionForId(Runtime::kRegExpConstructResult)->entry);
 }
 
@@ -117,7 +117,7 @@ void TransitionElementsKindStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   Register registers[] = { rsi, rax, rbx };
   descriptor->Initialize(
-      MajorKey(), ARRAY_SIZE(registers), registers,
+      MajorKey(), arraysize(registers), registers,
       Runtime::FunctionForId(Runtime::kTransitionElementsKind)->entry);
 }
 
@@ -137,7 +137,7 @@ static void InitializeArrayConstructorDescriptor(
 
   if (constant_stack_parameter_count == 0) {
     Register registers[] = { rsi, rdi, rbx };
-    descriptor->Initialize(major, ARRAY_SIZE(registers), registers,
+    descriptor->Initialize(major, arraysize(registers), registers,
                            deopt_handler, NULL, constant_stack_parameter_count,
                            JS_FUNCTION_STUB_MODE);
   } else {
@@ -148,7 +148,7 @@ static void InitializeArrayConstructorDescriptor(
         Representation::Tagged(),
         Representation::Tagged(),
         Representation::Integer32() };
-    descriptor->Initialize(major, ARRAY_SIZE(registers), registers, rax,
+    descriptor->Initialize(major, arraysize(registers), registers, rax,
                            deopt_handler, representations,
                            constant_stack_parameter_count,
                            JS_FUNCTION_STUB_MODE, PASS_ARGUMENTS);
@@ -168,7 +168,7 @@ static void InitializeInternalArrayConstructorDescriptor(
 
   if (constant_stack_parameter_count == 0) {
     Register registers[] = { rsi, rdi };
-    descriptor->Initialize(major, ARRAY_SIZE(registers), registers,
+    descriptor->Initialize(major, arraysize(registers), registers,
                            deopt_handler, NULL, constant_stack_parameter_count,
                            JS_FUNCTION_STUB_MODE);
   } else {
@@ -178,7 +178,7 @@ static void InitializeInternalArrayConstructorDescriptor(
         Representation::Tagged(),
         Representation::Tagged(),
         Representation::Integer32() };
-    descriptor->Initialize(major, ARRAY_SIZE(registers), registers, rax,
+    descriptor->Initialize(major, arraysize(registers), registers, rax,
                            deopt_handler, representations,
                            constant_stack_parameter_count,
                            JS_FUNCTION_STUB_MODE, PASS_ARGUMENTS);
@@ -225,7 +225,7 @@ void InternalArrayNArgumentsConstructorStub::InitializeInterfaceDescriptor(
 void CompareNilICStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   Register registers[] = { rsi, rax };
-  descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers,
+  descriptor->Initialize(MajorKey(), arraysize(registers), registers,
                          FUNCTION_ADDR(CompareNilIC_Miss));
   descriptor->SetMissHandler(
       ExternalReference(IC_Utility(IC::kCompareNilIC_Miss), isolate()));
@@ -235,7 +235,7 @@ void CompareNilICStub::InitializeInterfaceDescriptor(
 void ToBooleanStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   Register registers[] = { rsi, rax };
-  descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers,
+  descriptor->Initialize(MajorKey(), arraysize(registers), registers,
                          FUNCTION_ADDR(ToBooleanIC_Miss));
   descriptor->SetMissHandler(
       ExternalReference(IC_Utility(IC::kToBooleanIC_Miss), isolate()));
@@ -245,7 +245,7 @@ void ToBooleanStub::InitializeInterfaceDescriptor(
 void BinaryOpICStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   Register registers[] = { rsi, rdx, rax };
-  descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers,
+  descriptor->Initialize(MajorKey(), arraysize(registers), registers,
                          FUNCTION_ADDR(BinaryOpIC_Miss));
   descriptor->SetMissHandler(
       ExternalReference(IC_Utility(IC::kBinaryOpIC_Miss), isolate()));
@@ -255,7 +255,7 @@ void BinaryOpICStub::InitializeInterfaceDescriptor(
 void BinaryOpWithAllocationSiteStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   Register registers[] = { rsi, rcx, rdx, rax };
-  descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers,
+  descriptor->Initialize(MajorKey(), arraysize(registers), registers,
                          FUNCTION_ADDR(BinaryOpIC_MissWithAllocationSite));
 }
 
@@ -263,7 +263,7 @@ void BinaryOpWithAllocationSiteStub::InitializeInterfaceDescriptor(
 void StringAddStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   Register registers[] = { rsi, rdx, rax };
-  descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers,
+  descriptor->Initialize(MajorKey(), arraysize(registers), registers,
                          Runtime::FunctionForId(Runtime::kStringAdd)->entry);
 }
 
@@ -283,7 +283,7 @@ void CallDescriptors::InitializeForIsolate(Isolate* isolate) {
         Representation::Integer32(),  // actual number of arguments
         Representation::Integer32(),  // expected number of arguments
     };
-    descriptor->Initialize(ARRAY_SIZE(registers), registers, representations);
+    descriptor->Initialize(arraysize(registers), registers, representations);
   }
   {
     CallInterfaceDescriptor* descriptor =
@@ -295,7 +295,7 @@ void CallDescriptors::InitializeForIsolate(Isolate* isolate) {
         Representation::Tagged(),     // context
         Representation::Tagged(),     // key
     };
-    descriptor->Initialize(ARRAY_SIZE(registers), registers, representations);
+    descriptor->Initialize(arraysize(registers), registers, representations);
   }
   {
     CallInterfaceDescriptor* descriptor =
@@ -307,7 +307,7 @@ void CallDescriptors::InitializeForIsolate(Isolate* isolate) {
         Representation::Tagged(),     // context
         Representation::Tagged(),     // name
     };
-    descriptor->Initialize(ARRAY_SIZE(registers), registers, representations);
+    descriptor->Initialize(arraysize(registers), registers, representations);
   }
   {
     CallInterfaceDescriptor* descriptor =
@@ -319,7 +319,7 @@ void CallDescriptors::InitializeForIsolate(Isolate* isolate) {
         Representation::Tagged(),  // context
         Representation::Tagged(),  // receiver
     };
-    descriptor->Initialize(ARRAY_SIZE(registers), registers, representations);
+    descriptor->Initialize(arraysize(registers), registers, representations);
   }
   {
     CallInterfaceDescriptor* descriptor =
@@ -337,7 +337,7 @@ void CallDescriptors::InitializeForIsolate(Isolate* isolate) {
         Representation::Tagged(),    // holder
         Representation::External(),  // api_function_address
     };
-    descriptor->Initialize(ARRAY_SIZE(registers), registers, representations);
+    descriptor->Initialize(arraysize(registers), registers, representations);
   }
 }
 
index 7832c11..8777174 100644 (file)
@@ -23,7 +23,7 @@ void FastNewClosureStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   Register registers[] = { esi, ebx };
   descriptor->Initialize(
-      MajorKey(), ARRAY_SIZE(registers), registers,
+      MajorKey(), arraysize(registers), registers,
       Runtime::FunctionForId(Runtime::kNewClosureFromStubFailure)->entry);
 }
 
@@ -31,7 +31,7 @@ void FastNewClosureStub::InitializeInterfaceDescriptor(
 void FastNewContextStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   Register registers[] = { esi, edi };
-  descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers);
+  descriptor->Initialize(MajorKey(), arraysize(registers), registers);
 }
 
 
@@ -39,7 +39,7 @@ void ToNumberStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   // ToNumberStub invokes a function, and therefore needs a context.
   Register registers[] = { esi, eax };
-  descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers);
+  descriptor->Initialize(MajorKey(), arraysize(registers), registers);
 }
 
 
@@ -47,7 +47,7 @@ void NumberToStringStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   Register registers[] = { esi, eax };
   descriptor->Initialize(
-      MajorKey(), ARRAY_SIZE(registers), registers,
+      MajorKey(), arraysize(registers), registers,
       Runtime::FunctionForId(Runtime::kNumberToStringRT)->entry);
 }
 
@@ -62,7 +62,7 @@ void FastCloneShallowArrayStub::InitializeInterfaceDescriptor(
     Representation::Tagged() };
 
   descriptor->Initialize(
-      MajorKey(), ARRAY_SIZE(registers), registers,
+      MajorKey(), arraysize(registers), registers,
       Runtime::FunctionForId(Runtime::kCreateArrayLiteralStubBailout)->entry,
       representations);
 }
@@ -72,7 +72,7 @@ void FastCloneShallowObjectStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   Register registers[] = { esi, eax, ebx, ecx, edx };
   descriptor->Initialize(
-      MajorKey(), ARRAY_SIZE(registers), registers,
+      MajorKey(), arraysize(registers), registers,
       Runtime::FunctionForId(Runtime::kCreateObjectLiteral)->entry);
 }
 
@@ -80,14 +80,14 @@ void FastCloneShallowObjectStub::InitializeInterfaceDescriptor(
 void CreateAllocationSiteStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   Register registers[] = { esi, ebx, edx };
-  descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers);
+  descriptor->Initialize(MajorKey(), arraysize(registers), registers);
 }
 
 
 void CallFunctionStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   Register registers[] = {esi, edi};
-  descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers);
+  descriptor->Initialize(MajorKey(), arraysize(registers), registers);
 }
 
 
@@ -101,7 +101,7 @@ void CallConstructStub::InitializeInterfaceDescriptor(
   // TODO(turbofan): So far we don't gather type feedback and hence skip the
   // slot parameter, but ArrayConstructStub needs the vector to be undefined.
   Register registers[] = {esi, eax, edi, ebx};
-  descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers);
+  descriptor->Initialize(MajorKey(), arraysize(registers), registers);
 }
 
 
@@ -109,7 +109,7 @@ void RegExpConstructResultStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   Register registers[] = { esi, ecx, ebx, eax };
   descriptor->Initialize(
-      MajorKey(), ARRAY_SIZE(registers), registers,
+      MajorKey(), arraysize(registers), registers,
       Runtime::FunctionForId(Runtime::kRegExpConstructResult)->entry);
 }
 
@@ -118,7 +118,7 @@ void TransitionElementsKindStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   Register registers[] = { esi, eax, ebx };
   descriptor->Initialize(
-      MajorKey(), ARRAY_SIZE(registers), registers,
+      MajorKey(), arraysize(registers), registers,
       Runtime::FunctionForId(Runtime::kTransitionElementsKind)->entry);
 }
 
@@ -139,7 +139,7 @@ static void InitializeArrayConstructorDescriptor(
 
   if (constant_stack_parameter_count == 0) {
     Register registers[] = { esi, edi, ebx };
-    descriptor->Initialize(major, ARRAY_SIZE(registers), registers,
+    descriptor->Initialize(major, arraysize(registers), registers,
                            deopt_handler, NULL, constant_stack_parameter_count,
                            JS_FUNCTION_STUB_MODE);
   } else {
@@ -150,7 +150,7 @@ static void InitializeArrayConstructorDescriptor(
         Representation::Tagged(),
         Representation::Tagged(),
         Representation::Integer32() };
-    descriptor->Initialize(major, ARRAY_SIZE(registers), registers, eax,
+    descriptor->Initialize(major, arraysize(registers), registers, eax,
                            deopt_handler, representations,
                            constant_stack_parameter_count,
                            JS_FUNCTION_STUB_MODE, PASS_ARGUMENTS);
@@ -169,7 +169,7 @@ static void InitializeInternalArrayConstructorDescriptor(
 
   if (constant_stack_parameter_count == 0) {
     Register registers[] = { esi, edi };
-    descriptor->Initialize(major, ARRAY_SIZE(registers), registers,
+    descriptor->Initialize(major, arraysize(registers), registers,
                            deopt_handler, NULL, constant_stack_parameter_count,
                            JS_FUNCTION_STUB_MODE);
   } else {
@@ -179,7 +179,7 @@ static void InitializeInternalArrayConstructorDescriptor(
         Representation::Tagged(),
         Representation::Tagged(),
         Representation::Integer32() };
-    descriptor->Initialize(major, ARRAY_SIZE(registers), registers, eax,
+    descriptor->Initialize(major, arraysize(registers), registers, eax,
                            deopt_handler, representations,
                            constant_stack_parameter_count,
                            JS_FUNCTION_STUB_MODE, PASS_ARGUMENTS);
@@ -226,7 +226,7 @@ void InternalArrayNArgumentsConstructorStub::InitializeInterfaceDescriptor(
 void CompareNilICStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   Register registers[] = { esi, eax };
-  descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers,
+  descriptor->Initialize(MajorKey(), arraysize(registers), registers,
                          FUNCTION_ADDR(CompareNilIC_Miss));
   descriptor->SetMissHandler(
       ExternalReference(IC_Utility(IC::kCompareNilIC_Miss), isolate()));
@@ -235,7 +235,7 @@ void CompareNilICStub::InitializeInterfaceDescriptor(
 void ToBooleanStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   Register registers[] = { esi, eax };
-  descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers,
+  descriptor->Initialize(MajorKey(), arraysize(registers), registers,
                          FUNCTION_ADDR(ToBooleanIC_Miss));
   descriptor->SetMissHandler(
       ExternalReference(IC_Utility(IC::kToBooleanIC_Miss), isolate()));
@@ -245,7 +245,7 @@ void ToBooleanStub::InitializeInterfaceDescriptor(
 void BinaryOpICStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   Register registers[] = { esi, edx, eax };
-  descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers,
+  descriptor->Initialize(MajorKey(), arraysize(registers), registers,
                          FUNCTION_ADDR(BinaryOpIC_Miss));
   descriptor->SetMissHandler(
       ExternalReference(IC_Utility(IC::kBinaryOpIC_Miss), isolate()));
@@ -255,7 +255,7 @@ void BinaryOpICStub::InitializeInterfaceDescriptor(
 void BinaryOpWithAllocationSiteStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   Register registers[] = { esi, ecx, edx, eax };
-  descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers,
+  descriptor->Initialize(MajorKey(), arraysize(registers), registers,
                          FUNCTION_ADDR(BinaryOpIC_MissWithAllocationSite));
 }
 
@@ -263,7 +263,7 @@ void BinaryOpWithAllocationSiteStub::InitializeInterfaceDescriptor(
 void StringAddStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
   Register registers[] = { esi, edx, eax };
-  descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers,
+  descriptor->Initialize(MajorKey(), arraysize(registers), registers,
                          Runtime::FunctionForId(Runtime::kStringAdd)->entry);
 }
 
@@ -283,7 +283,7 @@ void CallDescriptors::InitializeForIsolate(Isolate* isolate) {
         Representation::Integer32(),  // actual number of arguments
         Representation::Integer32(),  // expected number of arguments
     };
-    descriptor->Initialize(ARRAY_SIZE(registers), registers, representations);
+    descriptor->Initialize(arraysize(registers), registers, representations);
   }
   {
     CallInterfaceDescriptor* descriptor =
@@ -295,7 +295,7 @@ void CallDescriptors::InitializeForIsolate(Isolate* isolate) {
         Representation::Tagged(),     // context
         Representation::Tagged(),     // key
     };
-    descriptor->Initialize(ARRAY_SIZE(registers), registers, representations);
+    descriptor->Initialize(arraysize(registers), registers, representations);
   }
   {
     CallInterfaceDescriptor* descriptor =
@@ -307,7 +307,7 @@ void CallDescriptors::InitializeForIsolate(Isolate* isolate) {
         Representation::Tagged(),     // context
         Representation::Tagged(),     // name
     };
-    descriptor->Initialize(ARRAY_SIZE(registers), registers, representations);
+    descriptor->Initialize(arraysize(registers), registers, representations);
   }
   {
     CallInterfaceDescriptor* descriptor =
@@ -319,7 +319,7 @@ void CallDescriptors::InitializeForIsolate(Isolate* isolate) {
         Representation::Tagged(),     // context
         Representation::Tagged(),     // receiver
     };
-    descriptor->Initialize(ARRAY_SIZE(registers), registers, representations);
+    descriptor->Initialize(arraysize(registers), registers, representations);
   }
   {
     CallInterfaceDescriptor* descriptor =
@@ -337,7 +337,7 @@ void CallDescriptors::InitializeForIsolate(Isolate* isolate) {
         Representation::Tagged(),    // holder
         Representation::External(),  // api_function_address
     };
-    descriptor->Initialize(ARRAY_SIZE(registers), registers, representations);
+    descriptor->Initialize(arraysize(registers), registers, representations);
   }
 }
 
index 3530ff8..38b1eb9 100644 (file)
@@ -56,40 +56,40 @@ namespace {
 class ThreadLocalStorageTest : public Thread, public ::testing::Test {
  public:
   ThreadLocalStorageTest() : Thread(Options("ThreadLocalStorageTest")) {
-    for (size_t i = 0; i < ARRAY_SIZE(keys_); ++i) {
+    for (size_t i = 0; i < arraysize(keys_); ++i) {
       keys_[i] = Thread::CreateThreadLocalKey();
     }
   }
   ~ThreadLocalStorageTest() {
-    for (size_t i = 0; i < ARRAY_SIZE(keys_); ++i) {
+    for (size_t i = 0; i < arraysize(keys_); ++i) {
       Thread::DeleteThreadLocalKey(keys_[i]);
     }
   }
 
   virtual void Run() V8_FINAL V8_OVERRIDE {
-    for (size_t i = 0; i < ARRAY_SIZE(keys_); i++) {
+    for (size_t i = 0; i < arraysize(keys_); i++) {
       CHECK(!Thread::HasThreadLocal(keys_[i]));
     }
-    for (size_t i = 0; i < ARRAY_SIZE(keys_); i++) {
+    for (size_t i = 0; i < arraysize(keys_); i++) {
       Thread::SetThreadLocal(keys_[i], GetValue(i));
     }
-    for (size_t i = 0; i < ARRAY_SIZE(keys_); i++) {
+    for (size_t i = 0; i < arraysize(keys_); i++) {
       CHECK(Thread::HasThreadLocal(keys_[i]));
     }
-    for (size_t i = 0; i < ARRAY_SIZE(keys_); i++) {
+    for (size_t i = 0; i < arraysize(keys_); i++) {
       CHECK_EQ(GetValue(i), Thread::GetThreadLocal(keys_[i]));
       CHECK_EQ(GetValue(i), Thread::GetExistingThreadLocal(keys_[i]));
     }
-    for (size_t i = 0; i < ARRAY_SIZE(keys_); i++) {
-      Thread::SetThreadLocal(keys_[i], GetValue(ARRAY_SIZE(keys_) - i - 1));
+    for (size_t i = 0; i < arraysize(keys_); i++) {
+      Thread::SetThreadLocal(keys_[i], GetValue(arraysize(keys_) - i - 1));
     }
-    for (size_t i = 0; i < ARRAY_SIZE(keys_); i++) {
+    for (size_t i = 0; i < arraysize(keys_); i++) {
       CHECK(Thread::HasThreadLocal(keys_[i]));
     }
-    for (size_t i = 0; i < ARRAY_SIZE(keys_); i++) {
-      CHECK_EQ(GetValue(ARRAY_SIZE(keys_) - i - 1),
+    for (size_t i = 0; i < arraysize(keys_); i++) {
+      CHECK_EQ(GetValue(arraysize(keys_) - i - 1),
                Thread::GetThreadLocal(keys_[i]));
-      CHECK_EQ(GetValue(ARRAY_SIZE(keys_) - i - 1),
+      CHECK_EQ(GetValue(arraysize(keys_) - i - 1),
                Thread::GetExistingThreadLocal(keys_[i]));
     }
   }
index 1dbed16..72fafa2 100644 (file)
@@ -280,14 +280,14 @@ class CallHelper {
   template <typename P1>
   void VerifyParameters1() {
     MachineType parameters[] = {ReturnValueTraits<P1>::Representation()};
-    VerifyParameters(ARRAY_SIZE(parameters), parameters);
+    VerifyParameters(arraysize(parameters), parameters);
   }
 
   template <typename P1, typename P2>
   void VerifyParameters2() {
     MachineType parameters[] = {ReturnValueTraits<P1>::Representation(),
                                 ReturnValueTraits<P2>::Representation()};
-    VerifyParameters(ARRAY_SIZE(parameters), parameters);
+    VerifyParameters(arraysize(parameters), parameters);
   }
 
   template <typename P1, typename P2, typename P3>
@@ -295,7 +295,7 @@ class CallHelper {
     MachineType parameters[] = {ReturnValueTraits<P1>::Representation(),
                                 ReturnValueTraits<P2>::Representation(),
                                 ReturnValueTraits<P3>::Representation()};
-    VerifyParameters(ARRAY_SIZE(parameters), parameters);
+    VerifyParameters(arraysize(parameters), parameters);
   }
 
   template <typename P1, typename P2, typename P3, typename P4>
@@ -304,7 +304,7 @@ class CallHelper {
                                 ReturnValueTraits<P2>::Representation(),
                                 ReturnValueTraits<P3>::Representation(),
                                 ReturnValueTraits<P4>::Representation()};
-    VerifyParameters(ARRAY_SIZE(parameters), parameters);
+    VerifyParameters(arraysize(parameters), parameters);
   }
 #endif
 
index 6710342..cd3472d 100644 (file)
@@ -360,7 +360,7 @@ class CmpBranchGen : public BinopGen<int32_t> {
 
 
 TEST(BranchCombineInt32CmpAllInputShapes_materialized) {
-  for (size_t i = 0; i < ARRAY_SIZE(int32cmp_opcodes); i++) {
+  for (size_t i = 0; i < arraysize(int32cmp_opcodes); i++) {
     CmpMaterializeBoolGen gen(int32cmp_opcodes[i], false);
     Int32BinopInputShapeTester tester(&gen);
     tester.TestAllInputShapes();
@@ -369,7 +369,7 @@ TEST(BranchCombineInt32CmpAllInputShapes_materialized) {
 
 
 TEST(BranchCombineInt32CmpAllInputShapes_inverted_materialized) {
-  for (size_t i = 0; i < ARRAY_SIZE(int32cmp_opcodes); i++) {
+  for (size_t i = 0; i < arraysize(int32cmp_opcodes); i++) {
     CmpMaterializeBoolGen gen(int32cmp_opcodes[i], true);
     Int32BinopInputShapeTester tester(&gen);
     tester.TestAllInputShapes();
@@ -378,7 +378,7 @@ TEST(BranchCombineInt32CmpAllInputShapes_inverted_materialized) {
 
 
 TEST(BranchCombineInt32CmpAllInputShapes_branch_true) {
-  for (int i = 0; i < static_cast<int>(ARRAY_SIZE(int32cmp_opcodes)); i++) {
+  for (int i = 0; i < static_cast<int>(arraysize(int32cmp_opcodes)); i++) {
     CmpBranchGen gen(int32cmp_opcodes[i], false, false, 995 + i, -1011 - i);
     Int32BinopInputShapeTester tester(&gen);
     tester.TestAllInputShapes();
@@ -387,7 +387,7 @@ TEST(BranchCombineInt32CmpAllInputShapes_branch_true) {
 
 
 TEST(BranchCombineInt32CmpAllInputShapes_branch_false) {
-  for (int i = 0; i < static_cast<int>(ARRAY_SIZE(int32cmp_opcodes)); i++) {
+  for (int i = 0; i < static_cast<int>(arraysize(int32cmp_opcodes)); i++) {
     CmpBranchGen gen(int32cmp_opcodes[i], false, true, 795 + i, -2011 - i);
     Int32BinopInputShapeTester tester(&gen);
     tester.TestAllInputShapes();
@@ -396,7 +396,7 @@ TEST(BranchCombineInt32CmpAllInputShapes_branch_false) {
 
 
 TEST(BranchCombineInt32CmpAllInputShapes_inverse_branch_true) {
-  for (int i = 0; i < static_cast<int>(ARRAY_SIZE(int32cmp_opcodes)); i++) {
+  for (int i = 0; i < static_cast<int>(arraysize(int32cmp_opcodes)); i++) {
     CmpBranchGen gen(int32cmp_opcodes[i], true, false, 695 + i, -3011 - i);
     Int32BinopInputShapeTester tester(&gen);
     tester.TestAllInputShapes();
@@ -405,7 +405,7 @@ TEST(BranchCombineInt32CmpAllInputShapes_inverse_branch_true) {
 
 
 TEST(BranchCombineInt32CmpAllInputShapes_inverse_branch_false) {
-  for (int i = 0; i < static_cast<int>(ARRAY_SIZE(int32cmp_opcodes)); i++) {
+  for (int i = 0; i < static_cast<int>(arraysize(int32cmp_opcodes)); i++) {
     CmpBranchGen gen(int32cmp_opcodes[i], true, true, 595 + i, -4011 - i);
     Int32BinopInputShapeTester tester(&gen);
     tester.TestAllInputShapes();
@@ -428,7 +428,7 @@ TEST(BranchCombineFloat64Compares) {
                            CompareWrapper(IrOpcode::kFloat64LessThan),
                            CompareWrapper(IrOpcode::kFloat64LessThanOrEqual)};
 
-  for (size_t c = 0; c < ARRAY_SIZE(cmps); c++) {
+  for (size_t c = 0; c < arraysize(cmps); c++) {
     CompareWrapper cmp = cmps[c];
     for (int invert = 0; invert < 2; invert++) {
       RawMachineAssemblerTester<int32_t> m;
@@ -444,8 +444,8 @@ TEST(BranchCombineFloat64Compares) {
       m.Bind(&blockb);
       m.Return(m.Int32Constant(ne_constant));
 
-      for (size_t i = 0; i < ARRAY_SIZE(inputs); i++) {
-        for (size_t j = 0; j < ARRAY_SIZE(inputs); j += 2) {
+      for (size_t i = 0; i < arraysize(inputs); i++) {
+        for (size_t j = 0; j < arraysize(inputs); j += 2) {
           input_a = inputs[i];
           input_b = inputs[i];
           int32_t expected =
index a773f10..e071d23 100644 (file)
@@ -324,9 +324,9 @@ TEST(InstructionOperands) {
       new (&zone) UnallocatedOperand(UnallocatedOperand::MUST_HAVE_REGISTER),
       new (&zone) UnallocatedOperand(UnallocatedOperand::MUST_HAVE_REGISTER)};
 
-  for (size_t i = 0; i < ARRAY_SIZE(outputs); i++) {
-    for (size_t j = 0; j < ARRAY_SIZE(inputs); j++) {
-      for (size_t k = 0; k < ARRAY_SIZE(temps); k++) {
+  for (size_t i = 0; i < arraysize(outputs); i++) {
+    for (size_t j = 0; j < arraysize(inputs); j++) {
+      for (size_t k = 0; k < arraysize(temps); k++) {
         TestInstr* m =
             TestInstr::New(&zone, 101, i, outputs, j, inputs, k, temps);
         CHECK(i == m->OutputCount());
index 42a606d..57a15a5 100644 (file)
@@ -194,8 +194,8 @@ TEST(NoAliasing) {
                    T.OneConstant(),       T.NaNConstant(),     T.Constant(21),
                    T.Constant(22.2)};
 
-  for (size_t i = 0; i < ARRAY_SIZE(nodes); i++) {
-    for (size_t j = 0; j < ARRAY_SIZE(nodes); j++) {
+  for (size_t i = 0; i < arraysize(nodes); i++) {
+    for (size_t j = 0; j < arraysize(nodes); j++) {
       if (i != j) CHECK_NE(nodes[i], nodes[j]);
     }
   }
index 248e4b4..6e9cb30 100644 (file)
@@ -172,10 +172,10 @@ static IrOpcode::Value NumberToI32(bool is_signed) {
 TEST(StringBinops) {
   JSTypedLoweringTester R;
 
-  for (size_t i = 0; i < ARRAY_SIZE(kStringTypes); ++i) {
+  for (size_t i = 0; i < arraysize(kStringTypes); ++i) {
     Node* p0 = R.Parameter(kStringTypes[i], 0);
 
-    for (size_t j = 0; j < ARRAY_SIZE(kStringTypes); ++j) {
+    for (size_t j = 0; j < arraysize(kStringTypes); ++j) {
       Node* p1 = R.Parameter(kStringTypes[j], 1);
 
       Node* add = R.Binop(R.javascript.Add(), p0, p1);
@@ -191,7 +191,7 @@ TEST(StringBinops) {
 
 TEST(AddNumber1) {
   JSTypedLoweringTester R;
-  for (size_t i = 0; i < ARRAY_SIZE(kNumberTypes); ++i) {
+  for (size_t i = 0; i < arraysize(kNumberTypes); ++i) {
     Node* p0 = R.Parameter(kNumberTypes[i], 0);
     Node* p1 = R.Parameter(kNumberTypes[i], 1);
     Node* add = R.Binop(R.javascript.Add(), p0, p1);
@@ -214,13 +214,13 @@ TEST(NumberBinops) {
       R.javascript.Modulus(),  R.simplified.NumberModulus(),
   };
 
-  for (size_t i = 0; i < ARRAY_SIZE(kNumberTypes); ++i) {
+  for (size_t i = 0; i < arraysize(kNumberTypes); ++i) {
     Node* p0 = R.Parameter(kNumberTypes[i], 0);
 
-    for (size_t j = 0; j < ARRAY_SIZE(kNumberTypes); ++j) {
+    for (size_t j = 0; j < arraysize(kNumberTypes); ++j) {
       Node* p1 = R.Parameter(kNumberTypes[j], 1);
 
-      for (size_t k = 0; k < ARRAY_SIZE(ops); k += 2) {
+      for (size_t k = 0; k < arraysize(ops); k += 2) {
         Node* add = R.Binop(ops[k], p0, p1);
         Node* r = R.reduce(add);
 
@@ -284,10 +284,10 @@ TEST(Int32BitwiseShifts) {
       Type::Null(),        Type::Boolean(),       Type::Number(),
       Type::String(),      Type::Object()};
 
-  for (size_t i = 0; i < ARRAY_SIZE(types); ++i) {
+  for (size_t i = 0; i < arraysize(types); ++i) {
     Node* p0 = R.Parameter(types[i], 0);
 
-    for (size_t j = 0; j < ARRAY_SIZE(types); ++j) {
+    for (size_t j = 0; j < arraysize(types); ++j) {
       Node* p1 = R.Parameter(types[j], 1);
 
       for (int k = 0; k < R.kNumberOps; k += 2) {
@@ -344,10 +344,10 @@ TEST(Int32BitwiseBinops) {
       Type::Null(),        Type::Boolean(),       Type::Number(),
       Type::String(),      Type::Object()};
 
-  for (size_t i = 0; i < ARRAY_SIZE(types); ++i) {
+  for (size_t i = 0; i < arraysize(types); ++i) {
     Node* p0 = R.Parameter(types[i], 0);
 
-    for (size_t j = 0; j < ARRAY_SIZE(types); ++j) {
+    for (size_t j = 0; j < arraysize(types); ++j) {
       Node* p1 = R.Parameter(types[j], 1);
 
       for (int k = 0; k < R.kNumberOps; k += 2) {
@@ -368,7 +368,7 @@ TEST(JSToNumber1) {
   JSTypedLoweringTester R;
   Operator* ton = R.javascript.ToNumber();
 
-  for (size_t i = 0; i < ARRAY_SIZE(kNumberTypes); i++) {  // ToNumber(number)
+  for (size_t i = 0; i < arraysize(kNumberTypes); i++) {  // ToNumber(number)
     Node* r = R.ReduceUnop(ton, kNumberTypes[i]);
     CHECK_EQ(IrOpcode::kParameter, r->opcode());
   }
@@ -390,7 +390,7 @@ TEST(JSToNumber_replacement) {
 
   Type* types[] = {Type::Null(), Type::Undefined(), Type::Number()};
 
-  for (size_t i = 0; i < ARRAY_SIZE(types); i++) {
+  for (size_t i = 0; i < arraysize(types); i++) {
     Node* n = R.Parameter(types[i]);
     Node* c = R.graph.NewNode(R.javascript.ToNumber(), n, R.context(),
                               R.start(), R.start());
@@ -420,7 +420,7 @@ TEST(JSToNumberOfConstant) {
                      R.common.NumberConstant(0.1), R.common.Int32Constant(1177),
                      R.common.Float64Constant(0.99)};
 
-  for (size_t i = 0; i < ARRAY_SIZE(ops); i++) {
+  for (size_t i = 0; i < arraysize(ops); i++) {
     Node* n = R.graph.NewNode(ops[i]);
     Node* convert = R.Unop(R.javascript.ToNumber(), n);
     Node* r = R.reduce(convert);
@@ -445,7 +445,7 @@ TEST(JSToNumberOfNumberOrOtherPrimitive) {
   Type* others[] = {Type::Undefined(), Type::Null(), Type::Boolean(),
                     Type::String()};
 
-  for (size_t i = 0; i < ARRAY_SIZE(others); i++) {
+  for (size_t i = 0; i < arraysize(others); i++) {
     Type* t = Type::Union(Type::Number(), others[i], R.main_zone());
     Node* r = R.ReduceUnop(R.javascript.ToNumber(), t);
     CHECK_EQ(IrOpcode::kJSToNumber, r->opcode());
@@ -509,7 +509,7 @@ TEST(JSToBoolean_replacement) {
   Type* types[] = {Type::Null(), Type::Undefined(), Type::Boolean(),
                    Type::DetectableObject(), Type::Undetectable()};
 
-  for (size_t i = 0; i < ARRAY_SIZE(types); i++) {
+  for (size_t i = 0; i < arraysize(types); i++) {
     Node* n = R.Parameter(types[i]);
     Node* c = R.graph.NewNode(R.javascript.ToBoolean(), n, R.context(),
                               R.start(), R.start());
@@ -535,7 +535,7 @@ TEST(JSToBoolean_replacement) {
 TEST(JSToString1) {
   JSTypedLoweringTester R;
 
-  for (size_t i = 0; i < ARRAY_SIZE(kStringTypes); i++) {
+  for (size_t i = 0; i < arraysize(kStringTypes); i++) {
     Node* r = R.ReduceUnop(R.javascript.ToString(), kStringTypes[i]);
     CHECK_EQ(IrOpcode::kParameter, r->opcode());
   }
@@ -581,7 +581,7 @@ TEST(JSToString_replacement) {
 
   Type* types[] = {Type::Null(), Type::Undefined(), Type::String()};
 
-  for (size_t i = 0; i < ARRAY_SIZE(types); i++) {
+  for (size_t i = 0; i < arraysize(types); i++) {
     Node* n = R.Parameter(types[i]);
     Node* c = R.graph.NewNode(R.javascript.ToString(), n, R.context(),
                               R.start(), R.start());
@@ -613,12 +613,12 @@ TEST(StringComparison) {
       R.javascript.GreaterThan(),        R.simplified.StringLessThan(),
       R.javascript.GreaterThanOrEqual(), R.simplified.StringLessThanOrEqual()};
 
-  for (size_t i = 0; i < ARRAY_SIZE(kStringTypes); i++) {
+  for (size_t i = 0; i < arraysize(kStringTypes); i++) {
     Node* p0 = R.Parameter(kStringTypes[i], 0);
-    for (size_t j = 0; j < ARRAY_SIZE(kStringTypes); j++) {
+    for (size_t j = 0; j < arraysize(kStringTypes); j++) {
       Node* p1 = R.Parameter(kStringTypes[j], 1);
 
-      for (size_t k = 0; k < ARRAY_SIZE(ops); k += 2) {
+      for (size_t k = 0; k < arraysize(ops); k += 2) {
         Node* cmp = R.Binop(ops[k], p0, p1);
         Node* r = R.reduce(cmp);
 
@@ -658,17 +658,17 @@ TEST(NumberComparison) {
       R.javascript.GreaterThan(),        R.simplified.NumberLessThan(),
       R.javascript.GreaterThanOrEqual(), R.simplified.NumberLessThanOrEqual()};
 
-  for (size_t i = 0; i < ARRAY_SIZE(kJSTypes); i++) {
+  for (size_t i = 0; i < arraysize(kJSTypes); i++) {
     Type* t0 = kJSTypes[i];
     if (t0->Is(Type::String())) continue;  // skip Type::String
     Node* p0 = R.Parameter(t0, 0);
 
-    for (size_t j = 0; j < ARRAY_SIZE(kJSTypes); j++) {
+    for (size_t j = 0; j < arraysize(kJSTypes); j++) {
       Type* t1 = kJSTypes[j];
       if (t1->Is(Type::String())) continue;  // skip Type::String
       Node* p1 = R.Parameter(t1, 1);
 
-      for (size_t k = 0; k < ARRAY_SIZE(ops); k += 2) {
+      for (size_t k = 0; k < arraysize(ops); k += 2) {
         Node* cmp = R.Binop(ops[k], p0, p1);
         Node* r = R.reduce(cmp);
 
@@ -694,10 +694,10 @@ TEST(MixedComparison1) {
   Type* types[] = {Type::Number(), Type::String(),
                    Type::Union(Type::Number(), Type::String(), R.main_zone())};
 
-  for (size_t i = 0; i < ARRAY_SIZE(types); i++) {
+  for (size_t i = 0; i < arraysize(types); i++) {
     Node* p0 = R.Parameter(types[i], 0);
 
-    for (size_t j = 0; j < ARRAY_SIZE(types); j++) {
+    for (size_t j = 0; j < arraysize(types); j++) {
       Node* p1 = R.Parameter(types[j], 1);
       {
         Node* cmp = R.Binop(R.javascript.LessThan(), p0, p1);
@@ -754,7 +754,7 @@ TEST(UnaryNot) {
   JSTypedLoweringTester R;
   Operator* opnot = R.javascript.UnaryNot();
 
-  for (size_t i = 0; i < ARRAY_SIZE(kJSTypes); i++) {
+  for (size_t i = 0; i < arraysize(kJSTypes); i++) {
     Node* r = R.ReduceUnop(opnot, kJSTypes[i]);
     // TODO(titzer): test will break if/when js-typed-lowering constant folds.
     CHECK_EQ(IrOpcode::kBooleanNot, r->opcode());
@@ -908,10 +908,10 @@ TEST(EqualityForNumbers) {
                                  Type::Number()};
 
 
-  for (size_t i = 0; i < ARRAY_SIZE(simple_number_types); ++i) {
+  for (size_t i = 0; i < arraysize(simple_number_types); ++i) {
     Node* p0 = R.Parameter(simple_number_types[i], 0);
 
-    for (size_t j = 0; j < ARRAY_SIZE(simple_number_types); ++j) {
+    for (size_t j = 0; j < arraysize(simple_number_types); ++j) {
       Node* p1 = R.Parameter(simple_number_types[j], 1);
 
       CheckEqualityReduction(&R, true, p0, p1, IrOpcode::kNumberEqual);
@@ -928,7 +928,7 @@ TEST(StrictEqualityForRefEqualTypes) {
                    Type::Object(), Type::Receiver()};
 
   Node* p0 = R.Parameter(Type::Any());
-  for (size_t i = 0; i < ARRAY_SIZE(types); i++) {
+  for (size_t i = 0; i < arraysize(types); i++) {
     Node* p1 = R.Parameter(types[i]);
     CheckEqualityReduction(&R, true, p0, p1, IrOpcode::kReferenceEqual);
   }
@@ -960,7 +960,7 @@ TEST(RemovePureNumberBinopEffects) {
       R.javascript.LessThanOrEqual(), R.simplified.NumberLessThanOrEqual(),
   };
 
-  for (size_t j = 0; j < ARRAY_SIZE(ops); j += 2) {
+  for (size_t j = 0; j < arraysize(ops); j += 2) {
     BinopEffectsTester B(ops[j], Type::Number(), Type::Number());
     CHECK_EQ(ops[j + 1]->opcode(), B.result->op()->opcode());
 
@@ -984,7 +984,7 @@ TEST(OrderNumberBinopEffects1) {
       R.javascript.Modulus(),  R.simplified.NumberModulus(),
   };
 
-  for (size_t j = 0; j < ARRAY_SIZE(ops); j += 2) {
+  for (size_t j = 0; j < arraysize(ops); j += 2) {
     BinopEffectsTester B(ops[j], Type::Object(), Type::String());
     CHECK_EQ(ops[j + 1]->opcode(), B.result->op()->opcode());
 
@@ -1011,7 +1011,7 @@ TEST(OrderNumberBinopEffects2) {
       R.javascript.Modulus(),  R.simplified.NumberModulus(),
   };
 
-  for (size_t j = 0; j < ARRAY_SIZE(ops); j += 2) {
+  for (size_t j = 0; j < arraysize(ops); j += 2) {
     BinopEffectsTester B(ops[j], Type::Number(), Type::Object());
 
     Node* i0 = B.CheckNoOp(0);
@@ -1024,7 +1024,7 @@ TEST(OrderNumberBinopEffects2) {
     B.CheckEffectOrdering(i1);
   }
 
-  for (size_t j = 0; j < ARRAY_SIZE(ops); j += 2) {
+  for (size_t j = 0; j < arraysize(ops); j += 2) {
     BinopEffectsTester B(ops[j], Type::Object(), Type::Number());
 
     Node* i0 = B.CheckConvertedInput(IrOpcode::kJSToNumber, 0, true);
@@ -1047,7 +1047,7 @@ TEST(OrderCompareEffects) {
       R.javascript.GreaterThanOrEqual(), R.simplified.NumberLessThanOrEqual(),
   };
 
-  for (size_t j = 0; j < ARRAY_SIZE(ops); j += 2) {
+  for (size_t j = 0; j < arraysize(ops); j += 2) {
     BinopEffectsTester B(ops[j], Type::Object(), Type::String());
     CHECK_EQ(ops[j + 1]->opcode(), B.result->op()->opcode());
 
@@ -1062,7 +1062,7 @@ TEST(OrderCompareEffects) {
     B.CheckEffectOrdering(i1, i0);
   }
 
-  for (size_t j = 0; j < ARRAY_SIZE(ops); j += 2) {
+  for (size_t j = 0; j < arraysize(ops); j += 2) {
     BinopEffectsTester B(ops[j], Type::Number(), Type::Object());
 
     Node* i0 = B.CheckConvertedInput(IrOpcode::kJSToNumber, 0, true);
@@ -1075,7 +1075,7 @@ TEST(OrderCompareEffects) {
     B.CheckEffectOrdering(i0);
   }
 
-  for (size_t j = 0; j < ARRAY_SIZE(ops); j += 2) {
+  for (size_t j = 0; j < arraysize(ops); j += 2) {
     BinopEffectsTester B(ops[j], Type::Object(), Type::Number());
 
     Node* i0 = B.result->InputAt(0);
@@ -1177,7 +1177,7 @@ TEST(UnaryNotEffects) {
   JSTypedLoweringTester R;
   Operator* opnot = R.javascript.UnaryNot();
 
-  for (size_t i = 0; i < ARRAY_SIZE(kJSTypes); i++) {
+  for (size_t i = 0; i < arraysize(kJSTypes); i++) {
     Node* p0 = R.Parameter(kJSTypes[i], 0);
     Node* orig = R.Unop(opnot, p0);
     Node* effect_use = R.UseForEffect(orig);
@@ -1205,9 +1205,9 @@ TEST(Int32AddNarrowing) {
     JSBitwiseTypedLoweringTester R;
 
     for (int o = 0; o < R.kNumberOps; o += 2) {
-      for (size_t i = 0; i < ARRAY_SIZE(kInt32Types); i++) {
+      for (size_t i = 0; i < arraysize(kInt32Types); i++) {
         Node* n0 = R.Parameter(kInt32Types[i]);
-        for (size_t j = 0; j < ARRAY_SIZE(kInt32Types); j++) {
+        for (size_t j = 0; j < arraysize(kInt32Types); j++) {
           Node* n1 = R.Parameter(kInt32Types[j]);
           Node* one = R.graph.NewNode(R.common.NumberConstant(1));
 
@@ -1232,9 +1232,9 @@ TEST(Int32AddNarrowing) {
     JSBitwiseShiftTypedLoweringTester R;
 
     for (int o = 0; o < R.kNumberOps; o += 2) {
-      for (size_t i = 0; i < ARRAY_SIZE(kInt32Types); i++) {
+      for (size_t i = 0; i < arraysize(kInt32Types); i++) {
         Node* n0 = R.Parameter(kInt32Types[i]);
-        for (size_t j = 0; j < ARRAY_SIZE(kInt32Types); j++) {
+        for (size_t j = 0; j < arraysize(kInt32Types); j++) {
           Node* n1 = R.Parameter(kInt32Types[j]);
           Node* one = R.graph.NewNode(R.common.NumberConstant(1));
 
@@ -1306,12 +1306,12 @@ TEST(Int32Comparisons) {
        R.machine.Int32LessThanOrEqual(), R.simplified.NumberLessThanOrEqual(),
        true}};
 
-  for (size_t o = 0; o < ARRAY_SIZE(ops); o++) {
-    for (size_t i = 0; i < ARRAY_SIZE(kNumberTypes); i++) {
+  for (size_t o = 0; o < arraysize(ops); o++) {
+    for (size_t i = 0; i < arraysize(kNumberTypes); i++) {
       Type* t0 = kNumberTypes[i];
       Node* p0 = R.Parameter(t0, 0);
 
-      for (size_t j = 0; j < ARRAY_SIZE(kNumberTypes); j++) {
+      for (size_t j = 0; j < arraysize(kNumberTypes); j++) {
         Type* t1 = kNumberTypes[j];
         Node* p1 = R.Parameter(t1, 1);
 
index 23909a5..3569386 100644 (file)
@@ -33,15 +33,15 @@ TEST(Int32Constant_five) {
 
   int32_t constants[] = {static_cast<int32_t>(0x80000000), -77, 0, 1, -1};
 
-  Node* nodes[ARRAY_SIZE(constants)];
+  Node* nodes[arraysize(constants)];
 
-  for (size_t i = 0; i < ARRAY_SIZE(constants); i++) {
+  for (size_t i = 0; i < arraysize(constants); i++) {
     int32_t k = constants[i];
     Node* node = graph.NewNode(common.Int32Constant(k));
     *cache.Find(graph.zone(), k) = nodes[i] = node;
   }
 
-  for (size_t i = 0; i < ARRAY_SIZE(constants); i++) {
+  for (size_t i = 0; i < arraysize(constants); i++) {
     int32_t k = constants[i];
     CHECK_EQ(nodes[i], *cache.Find(graph.zone(), k));
   }
@@ -121,7 +121,7 @@ TEST(PtrConstant_back_to_back) {
   int32_t buffer[50];
 
   for (int32_t* p = buffer;
-       (p - buffer) < static_cast<ptrdiff_t>(ARRAY_SIZE(buffer)); p++) {
+       (p - buffer) < static_cast<ptrdiff_t>(arraysize(buffer)); p++) {
     Node** pos = cache.Find(graph.zone(), p);
     CHECK_NE(NULL, pos);
     for (int j = 0; j < 3; j++) {
@@ -140,7 +140,7 @@ TEST(PtrConstant_hits) {
   Node* nodes[kSize];
   CommonOperatorBuilder common(graph.zone());
 
-  for (size_t i = 0; i < ARRAY_SIZE(buffer); i++) {
+  for (size_t i = 0; i < arraysize(buffer); i++) {
     int k = static_cast<int>(i);
     int32_t* p = &buffer[i];
     nodes[i] = graph.NewNode(common.Int32Constant(k));
@@ -148,7 +148,7 @@ TEST(PtrConstant_hits) {
   }
 
   int hits = 0;
-  for (size_t i = 0; i < ARRAY_SIZE(buffer); i++) {
+  for (size_t i = 0; i < arraysize(buffer); i++) {
     int32_t* p = &buffer[i];
     Node** pos = cache.Find(graph.zone(), p);
     if (*pos != NULL) {
index 00e250d..a0550f0 100644 (file)
@@ -96,7 +96,7 @@ TEST(PhiReduce1) {
   Node* param = R.Parameter();
 
   Node* singles[] = {zero, one, oneish, param};
-  for (size_t i = 0; i < ARRAY_SIZE(singles); i++) {
+  for (size_t i = 0; i < arraysize(singles); i++) {
     R.CheckReduce(singles[i], R.Phi(singles[i]));
   }
 }
@@ -110,18 +110,18 @@ TEST(PhiReduce2) {
   Node* param = R.Parameter();
 
   Node* singles[] = {zero, one, oneish, param};
-  for (size_t i = 0; i < ARRAY_SIZE(singles); i++) {
+  for (size_t i = 0; i < arraysize(singles); i++) {
     Node* a = singles[i];
     R.CheckReduce(a, R.Phi(a, a));
   }
 
-  for (size_t i = 0; i < ARRAY_SIZE(singles); i++) {
+  for (size_t i = 0; i < arraysize(singles); i++) {
     Node* a = singles[i];
     R.CheckReduce(a, R.Phi(R.self, a));
     R.CheckReduce(a, R.Phi(a, R.self));
   }
 
-  for (size_t i = 1; i < ARRAY_SIZE(singles); i++) {
+  for (size_t i = 1; i < arraysize(singles); i++) {
     Node* a = singles[i], *b = singles[0];
     Node* phi1 = R.Phi(b, a);
     R.CheckReduce(phi1, phi1);
@@ -140,19 +140,19 @@ TEST(PhiReduce3) {
   Node* param = R.Parameter();
 
   Node* singles[] = {zero, one, oneish, param};
-  for (size_t i = 0; i < ARRAY_SIZE(singles); i++) {
+  for (size_t i = 0; i < arraysize(singles); i++) {
     Node* a = singles[i];
     R.CheckReduce(a, R.Phi(a, a, a));
   }
 
-  for (size_t i = 0; i < ARRAY_SIZE(singles); i++) {
+  for (size_t i = 0; i < arraysize(singles); i++) {
     Node* a = singles[i];
     R.CheckReduce(a, R.Phi(R.self, a, a));
     R.CheckReduce(a, R.Phi(a, R.self, a));
     R.CheckReduce(a, R.Phi(a, a, R.self));
   }
 
-  for (size_t i = 1; i < ARRAY_SIZE(singles); i++) {
+  for (size_t i = 1; i < arraysize(singles); i++) {
     Node* a = singles[i], *b = singles[0];
     Node* phi1 = R.Phi(b, a, a);
     R.CheckReduce(phi1, phi1);
@@ -174,12 +174,12 @@ TEST(PhiReduce4) {
   Node* param = R.Parameter();
 
   Node* singles[] = {zero, one, oneish, param};
-  for (size_t i = 0; i < ARRAY_SIZE(singles); i++) {
+  for (size_t i = 0; i < arraysize(singles); i++) {
     Node* a = singles[i];
     R.CheckReduce(a, R.Phi(a, a, a, a));
   }
 
-  for (size_t i = 0; i < ARRAY_SIZE(singles); i++) {
+  for (size_t i = 0; i < arraysize(singles); i++) {
     Node* a = singles[i];
     R.CheckReduce(a, R.Phi(R.self, a, a, a));
     R.CheckReduce(a, R.Phi(a, R.self, a, a));
@@ -192,7 +192,7 @@ TEST(PhiReduce4) {
     R.CheckReduce(a, R.Phi(R.self, a, a, R.self));
   }
 
-  for (size_t i = 1; i < ARRAY_SIZE(singles); i++) {
+  for (size_t i = 1; i < arraysize(singles); i++) {
     Node* a = singles[i], *b = singles[0];
     Node* phi1 = R.Phi(b, a, a, a);
     R.CheckReduce(phi1, phi1);
@@ -217,7 +217,7 @@ TEST(PhiReduceShouldIgnoreControlNodes) {
   Node* param = R.Parameter();
 
   Node* singles[] = {zero, one, oneish, param};
-  for (size_t i = 0; i < ARRAY_SIZE(singles); ++i) {
+  for (size_t i = 0; i < arraysize(singles); ++i) {
     R.CheckReduce(singles[i], R.PhiWithControl(singles[i], R.dead));
     R.CheckReduce(singles[i], R.PhiWithControl(R.self, singles[i], R.dead));
     R.CheckReduce(singles[i], R.PhiWithControl(singles[i], R.self, R.dead));
index ea7ee7c..61082d1 100644 (file)
@@ -138,20 +138,20 @@ TEST(BitToBool_constant) {
 TEST(ToTagged_constant) {
   RepresentationChangerTester r;
 
-  for (size_t i = 0; i < ARRAY_SIZE(double_inputs); i++) {
+  for (size_t i = 0; i < arraysize(double_inputs); i++) {
     Node* n = r.jsgraph()->Float64Constant(double_inputs[i]);
     Node* c = r.changer()->GetRepresentationFor(n, kRepFloat64, kRepTagged);
     r.CheckNumberConstant(c, double_inputs[i]);
   }
 
-  for (size_t i = 0; i < ARRAY_SIZE(int32_inputs); i++) {
+  for (size_t i = 0; i < arraysize(int32_inputs); i++) {
     Node* n = r.jsgraph()->Int32Constant(int32_inputs[i]);
     Node* c = r.changer()->GetRepresentationFor(n, kRepWord32 | kTypeInt32,
                                                 kRepTagged);
     r.CheckNumberConstant(c, static_cast<double>(int32_inputs[i]));
   }
 
-  for (size_t i = 0; i < ARRAY_SIZE(uint32_inputs); i++) {
+  for (size_t i = 0; i < arraysize(uint32_inputs); i++) {
     Node* n = r.jsgraph()->Int32Constant(uint32_inputs[i]);
     Node* c = r.changer()->GetRepresentationFor(n, kRepWord32 | kTypeUint32,
                                                 kRepTagged);
@@ -218,7 +218,7 @@ TEST(Nops) {
   RepresentationChangerTester r;
 
   // X -> X is always a nop for any single representation X.
-  for (size_t i = 0; i < ARRAY_SIZE(all_reps); i++) {
+  for (size_t i = 0; i < arraysize(all_reps); i++) {
     r.CheckNop(all_reps[i], all_reps[i]);
   }
 
@@ -273,8 +273,8 @@ TEST(TypeErrors) {
   r.CheckTypeError(kRepWord64, kRepWord32 | kTypeUint32);
   r.CheckTypeError(kRepWord32 | kTypeUint32, kRepWord64);
 
-  for (size_t i = 0; i < ARRAY_SIZE(all_reps); i++) {
-    for (size_t j = 0; j < ARRAY_SIZE(all_reps); j++) {
+  for (size_t i = 0; i < arraysize(all_reps); i++) {
+    for (size_t j = 0; j < arraysize(all_reps); j++) {
       if (i == j) continue;
       // Only a single from representation is allowed.
       r.CheckTypeError(all_reps[i] | all_reps[j], kRepTagged);
index 0a67398..59796c3 100644 (file)
@@ -102,7 +102,7 @@ TEST(RunGotoMultiple) {
   int constant = 9999977;
 
   MLabel labels[10];
-  for (size_t i = 0; i < ARRAY_SIZE(labels); i++) {
+  for (size_t i = 0; i < arraysize(labels); i++) {
     m.Goto(&labels[i]);
     m.Bind(&labels[i]);
   }
@@ -512,7 +512,7 @@ TEST(RunLoadInt32Offset) {
   int32_t offsets[] = {-2000000, -100, -101, 1,          3,
                        7,        120,  2000, 2000000000, 0xff};
 
-  for (size_t i = 0; i < ARRAY_SIZE(offsets); i++) {
+  for (size_t i = 0; i < arraysize(offsets); i++) {
     RawMachineAssemblerTester<int32_t> m;
     int32_t offset = offsets[i];
     byte* pointer = reinterpret_cast<byte*>(&p1) - offset;
@@ -741,7 +741,7 @@ TEST(RunInt32AddInBranch) {
     RawMachineAssemblerTester<void> m;
     Operator* shops[] = {m.machine()->Word32Sar(), m.machine()->Word32Shl(),
                          m.machine()->Word32Shr()};
-    for (size_t n = 0; n < ARRAY_SIZE(shops); n++) {
+    for (size_t n = 0; n < arraysize(shops); n++) {
       RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32,
                                            kMachUint32);
       MLabel blocka, blockb;
@@ -832,7 +832,7 @@ TEST(RunInt32AddInComparison) {
     RawMachineAssemblerTester<void> m;
     Operator* shops[] = {m.machine()->Word32Sar(), m.machine()->Word32Shl(),
                          m.machine()->Word32Shr()};
-    for (size_t n = 0; n < ARRAY_SIZE(shops); n++) {
+    for (size_t n = 0; n < arraysize(shops); n++) {
       RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32,
                                            kMachUint32);
       m.Return(m.Word32Equal(
@@ -1076,7 +1076,7 @@ TEST(RunInt32SubInBranch) {
     RawMachineAssemblerTester<void> m;
     Operator* shops[] = {m.machine()->Word32Sar(), m.machine()->Word32Shl(),
                          m.machine()->Word32Shr()};
-    for (size_t n = 0; n < ARRAY_SIZE(shops); n++) {
+    for (size_t n = 0; n < arraysize(shops); n++) {
       RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32,
                                            kMachUint32);
       MLabel blocka, blockb;
@@ -1167,7 +1167,7 @@ TEST(RunInt32SubInComparison) {
     RawMachineAssemblerTester<void> m;
     Operator* shops[] = {m.machine()->Word32Sar(), m.machine()->Word32Shl(),
                          m.machine()->Word32Shr()};
-    for (size_t n = 0; n < ARRAY_SIZE(shops); n++) {
+    for (size_t n = 0; n < arraysize(shops); n++) {
       RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32,
                                            kMachUint32);
       m.Return(m.Word32Equal(
@@ -1699,7 +1699,7 @@ TEST(RunWord32AndInBranch) {
     RawMachineAssemblerTester<void> m;
     Operator* shops[] = {m.machine()->Word32Sar(), m.machine()->Word32Shl(),
                          m.machine()->Word32Shr()};
-    for (size_t n = 0; n < ARRAY_SIZE(shops); n++) {
+    for (size_t n = 0; n < arraysize(shops); n++) {
       RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32,
                                            kMachUint32);
       MLabel blocka, blockb;
@@ -1926,7 +1926,7 @@ TEST(RunWord32OrInBranch) {
     RawMachineAssemblerTester<void> m;
     Operator* shops[] = {m.machine()->Word32Sar(), m.machine()->Word32Shl(),
                          m.machine()->Word32Shr()};
-    for (size_t n = 0; n < ARRAY_SIZE(shops); n++) {
+    for (size_t n = 0; n < arraysize(shops); n++) {
       RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32,
                                            kMachUint32);
       MLabel blocka, blockb;
@@ -2150,7 +2150,7 @@ TEST(RunWord32XorInBranch) {
     RawMachineAssemblerTester<void> m;
     Operator* shops[] = {m.machine()->Word32Sar(), m.machine()->Word32Shl(),
                          m.machine()->Word32Shr()};
-    for (size_t n = 0; n < ARRAY_SIZE(shops); n++) {
+    for (size_t n = 0; n < arraysize(shops); n++) {
       RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32,
                                            kMachUint32);
       MLabel blocka, blockb;
@@ -3701,7 +3701,7 @@ TEST(RunFloat64Compare) {
   for (int test = 0; test < kFloat64CompareHelperTestCases; test++) {
     for (int node_type = 0; node_type < kFloat64CompareHelperNodeType;
          node_type++) {
-      for (size_t input = 0; input < ARRAY_SIZE(inputs); input += 2) {
+      for (size_t input = 0; input < arraysize(inputs); input += 2) {
         RawMachineAssemblerTester<int32_t> m;
         int expected = Float64CompareHelper(&m, test, node_type, inputs[input],
                                             inputs[input + 1]);
@@ -3722,7 +3722,7 @@ TEST(RunFloat64UnorderedCompare) {
   double nan = v8::base::OS::nan_value();
 
   FOR_FLOAT64_INPUTS(i) {
-    for (size_t o = 0; o < ARRAY_SIZE(operators); ++o) {
+    for (size_t o = 0; o < arraysize(operators); ++o) {
       for (int j = 0; j < 2; j++) {
         RawMachineAssemblerTester<int32_t> m;
         Node* a = m.Float64Constant(*i);
@@ -3870,7 +3870,7 @@ TEST(RunIntPtrCompare) {
   intptr_t max = std::numeric_limits<intptr_t>::max();
   // An ascending chain of intptr_t
   intptr_t inputs[] = {min, min / 2, -1, 0, 1, max / 2, max};
-  for (size_t i = 0; i < ARRAY_SIZE(inputs) - 1; i++) {
+  for (size_t i = 0; i < arraysize(inputs) - 1; i++) {
     IntPtrCompare(inputs[i], inputs[i + 1]);
   }
 }
@@ -4315,7 +4315,7 @@ TEST(RunTruncateFloat64ToInt32P) {
   double input = -1.0;
   RawMachineAssemblerTester<int32_t> m;
   m.Return(m.TruncateFloat64ToInt32(m.LoadFromPointer(&input, kMachFloat64)));
-  for (size_t i = 0; i < ARRAY_SIZE(kValues); ++i) {
+  for (size_t i = 0; i < arraysize(kValues); ++i) {
     input = kValues[i].from;
     uint64_t expected = static_cast<int64_t>(kValues[i].raw);
     CHECK_EQ(static_cast<int>(expected), m.Call());
index 73ac015..4a65435 100644 (file)
@@ -247,7 +247,7 @@ TEST(RunLoadStoreArrayBuffer) {
 TEST(RunLoadFieldFromUntaggedBase) {
   Smi* smis[] = {Smi::FromInt(1), Smi::FromInt(2), Smi::FromInt(3)};
 
-  for (size_t i = 0; i < ARRAY_SIZE(smis); i++) {
+  for (size_t i = 0; i < arraysize(smis); i++) {
     int offset = static_cast<int>(i * sizeof(Smi*));
     FieldAccess access = {kUntaggedBase, offset, Handle<Name>(),
                           Type::Integral32(), kMachAnyTagged};
@@ -271,7 +271,7 @@ TEST(RunLoadFieldFromUntaggedBase) {
 TEST(RunStoreFieldToUntaggedBase) {
   Smi* smis[] = {Smi::FromInt(1), Smi::FromInt(2), Smi::FromInt(3)};
 
-  for (size_t i = 0; i < ARRAY_SIZE(smis); i++) {
+  for (size_t i = 0; i < arraysize(smis); i++) {
     int offset = static_cast<int>(i * sizeof(Smi*));
     FieldAccess access = {kUntaggedBase, offset, Handle<Name>(),
                           Type::Integral32(), kMachAnyTagged};
@@ -298,8 +298,8 @@ TEST(RunLoadElementFromUntaggedBase) {
   Smi* smis[] = {Smi::FromInt(1), Smi::FromInt(2), Smi::FromInt(3),
                  Smi::FromInt(4), Smi::FromInt(5)};
 
-  for (size_t i = 0; i < ARRAY_SIZE(smis); i++) {    // for header sizes
-    for (size_t j = 0; (i + j) < ARRAY_SIZE(smis); j++) {  // for element index
+  for (size_t i = 0; i < arraysize(smis); i++) {    // for header sizes
+    for (size_t j = 0; (i + j) < arraysize(smis); j++) {  // for element index
       int offset = static_cast<int>(i * sizeof(Smi*));
       ElementAccess access = {kUntaggedBase, offset, Type::Integral32(),
                               kMachAnyTagged};
@@ -326,8 +326,8 @@ TEST(RunStoreElementFromUntaggedBase) {
   Smi* smis[] = {Smi::FromInt(1), Smi::FromInt(2), Smi::FromInt(3),
                  Smi::FromInt(4), Smi::FromInt(5)};
 
-  for (size_t i = 0; i < ARRAY_SIZE(smis); i++) {    // for header sizes
-    for (size_t j = 0; (i + j) < ARRAY_SIZE(smis); j++) {  // for element index
+  for (size_t i = 0; i < arraysize(smis); i++) {    // for header sizes
+    for (size_t j = 0; (i + j) < arraysize(smis); j++) {  // for element index
       int offset = static_cast<int>(i * sizeof(Smi*));
       ElementAccess access = {kUntaggedBase, offset, Type::Integral32(),
                               kMachAnyTagged};
@@ -557,19 +557,19 @@ static void RunAccessTest(MachineType rep, E* original_elements, size_t num) {
 TEST(RunAccessTests_uint8) {
   uint8_t data[] = {0x07, 0x16, 0x25, 0x34, 0x43, 0x99,
                     0xab, 0x78, 0x89, 0x19, 0x2b, 0x38};
-  RunAccessTest<uint8_t>(kMachInt8, data, ARRAY_SIZE(data));
+  RunAccessTest<uint8_t>(kMachInt8, data, arraysize(data));
 }
 
 
 TEST(RunAccessTests_uint16) {
   uint16_t data[] = {0x071a, 0x162b, 0x253c, 0x344d, 0x435e, 0x7777};
-  RunAccessTest<uint16_t>(kMachInt16, data, ARRAY_SIZE(data));
+  RunAccessTest<uint16_t>(kMachInt16, data, arraysize(data));
 }
 
 
 TEST(RunAccessTests_int32) {
   int32_t data[] = {-211, 211, 628347, 2000000000, -2000000000, -1, -100000034};
-  RunAccessTest<int32_t>(kMachInt32, data, ARRAY_SIZE(data));
+  RunAccessTest<int32_t>(kMachInt32, data, arraysize(data));
 }
 
 
@@ -583,13 +583,13 @@ TEST(RunAccessTests_int64) {
                     V8_2PART_INT64(0x30313233, 34353637),
                     V8_2PART_INT64(0xa0a1a2a3, a4a5a6a7),
                     V8_2PART_INT64(0xf0f1f2f3, f4f5f6f7)};
-  RunAccessTest<int64_t>(kMachInt64, data, ARRAY_SIZE(data));
+  RunAccessTest<int64_t>(kMachInt64, data, arraysize(data));
 }
 
 
 TEST(RunAccessTests_float64) {
   double data[] = {1.25, -1.25, 2.75, 11.0, 11100.8};
-  RunAccessTest<double>(kMachFloat64, data, ARRAY_SIZE(data));
+  RunAccessTest<double>(kMachFloat64, data, arraysize(data));
 }
 
 
@@ -597,7 +597,7 @@ TEST(RunAccessTests_Smi) {
   Smi* data[] = {Smi::FromInt(-1),    Smi::FromInt(-9),
                  Smi::FromInt(0),     Smi::FromInt(666),
                  Smi::FromInt(77777), Smi::FromInt(Smi::kMaxValue)};
-  RunAccessTest<Smi*>(kMachAnyTagged, data, ARRAY_SIZE(data));
+  RunAccessTest<Smi*>(kMachAnyTagged, data, arraysize(data));
 }
 
 
@@ -813,7 +813,7 @@ TEST(LowerNumberCmp_to_uint32) {
 TEST(LowerNumberCmp_to_float64) {
   static Type* types[] = {Type::Number(), Type::Any()};
 
-  for (size_t i = 0; i < ARRAY_SIZE(types); i++) {
+  for (size_t i = 0; i < arraysize(types); i++) {
     TestingGraph t(types[i], types[i]);
 
     t.CheckLoweringBinop(IrOpcode::kFloat64Equal,
@@ -849,7 +849,7 @@ TEST(LowerNumberAddSub_to_uint32) {
 
 
 TEST(LowerNumberAddSub_to_float64) {
-  for (size_t i = 0; i < ARRAY_SIZE(test_types); i++) {
+  for (size_t i = 0; i < arraysize(test_types); i++) {
     TestingGraph t(test_types[i], test_types[i]);
 
     t.CheckLoweringBinop(IrOpcode::kFloat64Add, t.simplified()->NumberAdd());
@@ -860,7 +860,7 @@ TEST(LowerNumberAddSub_to_float64) {
 
 
 TEST(LowerNumberDivMod_to_float64) {
-  for (size_t i = 0; i < ARRAY_SIZE(test_types); i++) {
+  for (size_t i = 0; i < arraysize(test_types); i++) {
     TestingGraph t(test_types[i], test_types[i]);
 
     t.CheckLoweringBinop(IrOpcode::kFloat64Div, t.simplified()->NumberDivide());
@@ -1057,7 +1057,7 @@ TEST(InsertChangesAroundInt32Binops) {
                      t.machine()->Word32Or(),  t.machine()->Word32Xor(),
                      t.machine()->Word32Shl(), t.machine()->Word32Sar()};
 
-  for (size_t i = 0; i < ARRAY_SIZE(ops); i++) {
+  for (size_t i = 0; i < arraysize(ops); i++) {
     CheckChangesAroundBinop(&t, ops[i], IrOpcode::kChangeTaggedToInt32,
                             IrOpcode::kChangeInt32ToTagged);
   }
@@ -1070,7 +1070,7 @@ TEST(InsertChangesAroundInt32Cmp) {
   Operator* ops[] = {t.machine()->Int32LessThan(),
                      t.machine()->Int32LessThanOrEqual()};
 
-  for (size_t i = 0; i < ARRAY_SIZE(ops); i++) {
+  for (size_t i = 0; i < arraysize(ops); i++) {
     CheckChangesAroundBinop(&t, ops[i], IrOpcode::kChangeTaggedToInt32,
                             IrOpcode::kChangeBitToBool);
   }
@@ -1083,7 +1083,7 @@ TEST(InsertChangesAroundUint32Cmp) {
   Operator* ops[] = {t.machine()->Uint32LessThan(),
                      t.machine()->Uint32LessThanOrEqual()};
 
-  for (size_t i = 0; i < ARRAY_SIZE(ops); i++) {
+  for (size_t i = 0; i < arraysize(ops); i++) {
     CheckChangesAroundBinop(&t, ops[i], IrOpcode::kChangeTaggedToUint32,
                             IrOpcode::kChangeBitToBool);
   }
@@ -1099,7 +1099,7 @@ TEST(InsertChangesAroundFloat64Binops) {
       t.machine()->Float64Mod(),
   };
 
-  for (size_t i = 0; i < ARRAY_SIZE(ops); i++) {
+  for (size_t i = 0; i < arraysize(ops); i++) {
     CheckChangesAroundBinop(&t, ops[i], IrOpcode::kChangeTaggedToFloat64,
                             IrOpcode::kChangeFloat64ToTagged);
   }
@@ -1113,7 +1113,7 @@ TEST(InsertChangesAroundFloat64Cmp) {
                      t.machine()->Float64LessThan(),
                      t.machine()->Float64LessThanOrEqual()};
 
-  for (size_t i = 0; i < ARRAY_SIZE(ops); i++) {
+  for (size_t i = 0; i < arraysize(ops); i++) {
     CheckChangesAroundBinop(&t, ops[i], IrOpcode::kChangeTaggedToFloat64,
                             IrOpcode::kChangeBitToBool);
   }
@@ -1152,7 +1152,7 @@ static const MachineType machine_reps[] = {
 TEST(LowerLoadField_to_load) {
   TestingGraph t(Type::Any(), Type::Signed32());
 
-  for (size_t i = 0; i < ARRAY_SIZE(machine_reps); i++) {
+  for (size_t i = 0; i < arraysize(machine_reps); i++) {
     FieldAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize,
                           Handle<Name>::null(), Type::Any(), machine_reps[i]};
 
@@ -1174,7 +1174,7 @@ TEST(LowerLoadField_to_load) {
 TEST(LowerStoreField_to_store) {
   TestingGraph t(Type::Any(), Type::Signed32());
 
-  for (size_t i = 0; i < ARRAY_SIZE(machine_reps); i++) {
+  for (size_t i = 0; i < arraysize(machine_reps); i++) {
     FieldAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize,
                           Handle<Name>::null(), Type::Any(), machine_reps[i]};
 
@@ -1200,7 +1200,7 @@ TEST(LowerStoreField_to_store) {
 TEST(LowerLoadElement_to_load) {
   TestingGraph t(Type::Any(), Type::Signed32());
 
-  for (size_t i = 0; i < ARRAY_SIZE(machine_reps); i++) {
+  for (size_t i = 0; i < arraysize(machine_reps); i++) {
     ElementAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize,
                             Type::Any(), machine_reps[i]};
 
@@ -1222,7 +1222,7 @@ TEST(LowerLoadElement_to_load) {
 TEST(LowerStoreElement_to_store) {
   TestingGraph t(Type::Any(), Type::Signed32());
 
-  for (size_t i = 0; i < ARRAY_SIZE(machine_reps); i++) {
+  for (size_t i = 0; i < arraysize(machine_reps); i++) {
     ElementAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize,
                             Type::Any(), machine_reps[i]};
 
index a18c72d..74cba29 100644 (file)
@@ -606,7 +606,7 @@ TEST(RunExpressionStrings) {
       "v|(v)",   "v|(v&v)", "v|(v&v)|v", "v|(((v)|(v&v)|(v)|v)&(v))|v",
   };
   v8::base::RandomNumberGenerator rng;
-  for (size_t i = 0; i < ARRAY_SIZE(strings); i++) {
+  for (size_t i = 0; i < arraysize(strings); i++) {
     IfBuilderGenerator m;
     m.ParseExpression(strings[i]);
     m.RunRandom(&rng);
@@ -619,7 +619,7 @@ TEST(RunSimpleIfElseTester) {
       "i(v)",   "i(v)t",   "i(v)te",
       "i(v)er", "i(v)ter", "i(v)ti(v)trei(v)ei(v)ei(v)ei(v)ei(v)ei(v)ei(v)e"};
   v8::base::RandomNumberGenerator rng;
-  for (size_t i = 0; i < ARRAY_SIZE(tests); ++i) {
+  for (size_t i = 0; i < arraysize(tests); ++i) {
     IfBuilderGenerator m;
     m.ParseIfThenElse(tests[i]);
     m.RunRandom(&rng);
index 0ae6383..2ddd240 100644 (file)
@@ -279,8 +279,8 @@ static void RunIfBuilderDisjunction(size_t max, IfBuilderBranchType then_type,
 TEST(RunIfBuilderDisjunction) {
   size_t len = ValueHelper::int32_vector().size() - 1;
   size_t max = len > 10 ? 10 : len - 1;
-  for (size_t i = 0; i < ARRAY_SIZE(all_branch_types); i++) {
-    for (size_t j = 0; j < ARRAY_SIZE(all_branch_types); j++) {
+  for (size_t i = 0; i < arraysize(all_branch_types); i++) {
+    for (size_t j = 0; j < arraysize(all_branch_types); j++) {
       for (size_t size = 1; size < max; size++) {
         RunIfBuilderDisjunction(size, all_branch_types[i], all_branch_types[j]);
       }
@@ -345,8 +345,8 @@ static void RunIfBuilderConjunction(size_t max, IfBuilderBranchType then_type,
 TEST(RunIfBuilderConjunction) {
   size_t len = ValueHelper::int32_vector().size() - 1;
   size_t max = len > 10 ? 10 : len - 1;
-  for (size_t i = 0; i < ARRAY_SIZE(all_branch_types); i++) {
-    for (size_t j = 0; j < ARRAY_SIZE(all_branch_types); j++) {
+  for (size_t i = 0; i < arraysize(all_branch_types); i++) {
+    for (size_t j = 0; j < arraysize(all_branch_types); j++) {
       for (size_t size = 1; size < max; size++) {
         RunIfBuilderConjunction(size, all_branch_types[i], all_branch_types[j]);
       }
@@ -683,7 +683,7 @@ TEST(RunFib) {
   m.Return(res.Get());
 
   int32_t values[] = {0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144};
-  for (size_t i = 0; i < ARRAY_SIZE(values); i++) {
+  for (size_t i = 0; i < arraysize(values); i++) {
     CHECK_EQ(values[i], m.Call(static_cast<int32_t>(i)));
   }
 }
@@ -894,7 +894,7 @@ class QuicksortHelper : public StructuredMachineAssemblerTester<int32_t> {
     int32_t stack_space[20];
     // Do call.
     int32_t return_val = Call(input, input_length, stack_space,
-                              static_cast<int32_t>(ARRAY_SIZE(stack_space)));
+                              static_cast<int32_t>(arraysize(stack_space)));
     // Ran out of stack space.
     if (return_val != 0) return return_val;
     // Check sorted.
@@ -1018,7 +1018,7 @@ class QuicksortHelper : public StructuredMachineAssemblerTester<int32_t> {
 TEST(RunSimpleQuicksort) {
   QuicksortHelper m;
   int32_t inputs[] = {9, 7, 1, 8, 11};
-  CHECK_EQ(0, m.DoCall(inputs, ARRAY_SIZE(inputs)));
+  CHECK_EQ(0, m.DoCall(inputs, arraysize(inputs)));
 }
 
 
index 3f6e500..5054c73 100644 (file)
@@ -76,7 +76,7 @@ class ValueHelper {
         -V8_INFINITY,    nan,             2147483647.375, 2147483647.75,
         2147483648.0,    2147483648.25,   2147483649.25,  -2147483647.0,
         -2147483647.125, -2147483647.875, -2147483648.25, -2147483649.5};
-    return std::vector<double>(&values[0], &values[ARRAY_SIZE(values)]);
+    return std::vector<double>(&values[0], &values[arraysize(values)]);
   }
 
   static const std::vector<int32_t> int32_vector() {
@@ -94,7 +94,7 @@ class ValueHelper {
         0xeeeeeeee, 0xfffffffd, 0xf0000000, 0x007fffff, 0x003fffff, 0x001fffff,
         0x000fffff, 0x0007ffff, 0x0003ffff, 0x0001ffff, 0x0000ffff, 0x00007fff,
         0x00003fff, 0x00001fff, 0x00000fff, 0x000007ff, 0x000003ff, 0x000001ff};
-    return std::vector<uint32_t>(&kValues[0], &kValues[ARRAY_SIZE(kValues)]);
+    return std::vector<uint32_t>(&kValues[0], &kValues[arraysize(kValues)]);
   }
 
   static const std::vector<double> nan_vector(size_t limit = 0) {
@@ -102,14 +102,14 @@ class ValueHelper {
     static const double values[] = {-nan,               -V8_INFINITY * -0.0,
                                     -V8_INFINITY * 0.0, V8_INFINITY * -0.0,
                                     V8_INFINITY * 0.0,  nan};
-    return std::vector<double>(&values[0], &values[ARRAY_SIZE(values)]);
+    return std::vector<double>(&values[0], &values[arraysize(values)]);
   }
 
   static const std::vector<uint32_t> ror_vector() {
     static const uint32_t kValues[31] = {
         1,  2,  3,  4,  5,  6,  7,  8,  9,  10, 11, 12, 13, 14, 15, 16,
         17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31};
-    return std::vector<uint32_t>(&kValues[0], &kValues[ARRAY_SIZE(kValues)]);
+    return std::vector<uint32_t>(&kValues[0], &kValues[arraysize(kValues)]);
   }
 };
 
index c910f0e..407de66 100644 (file)
@@ -263,7 +263,7 @@ THREADED_TEST(ReceiverSignature) {
   const char* test_objects[] = {
       "fun_instance", "sub_fun_instance", "obj", "unrel" };
   unsigned bad_signature_start_offset = 2;
-  for (unsigned i = 0; i < ARRAY_SIZE(test_objects); i++) {
+  for (unsigned i = 0; i < arraysize(test_objects); i++) {
     i::ScopedVector<char> source(200);
     i::SNPrintF(
         source, "var test_object = %s; test_object", test_objects[i]);
@@ -1189,7 +1189,7 @@ THREADED_PROFILED_TEST(FastReturnValues) {
       0, 234, -723,
       i::Smi::kMinValue, i::Smi::kMaxValue
   };
-  for (size_t i = 0; i < ARRAY_SIZE(int_values); i++) {
+  for (size_t i = 0; i < arraysize(int_values); i++) {
     for (int modifier = -1; modifier <= 1; modifier++) {
       int int_value = int_values[i] + modifier;
       // check int32_t
@@ -1221,7 +1221,7 @@ THREADED_PROFILED_TEST(FastReturnValues) {
       kUndefinedReturnValue,
       kEmptyStringReturnValue
   };
-  for (size_t i = 0; i < ARRAY_SIZE(oddballs); i++) {
+  for (size_t i = 0; i < arraysize(oddballs); i++) {
     fast_return_value_void = oddballs[i];
     value = TestFastReturnValues<void>();
     switch (fast_return_value_void) {
@@ -19203,7 +19203,7 @@ TEST(ContainsOnlyOneByte) {
       String::NewExternal(isolate,
                           new TestResource(string_contents, NULL, false));
   USE(two_byte); USE(cons_strings);
-  for (size_t i = 0; i < ARRAY_SIZE(cons_strings); i++) {
+  for (size_t i = 0; i < arraysize(cons_strings); i++) {
     // Base assumptions.
     string = cons_strings[i];
     CHECK(string->IsOneByte() && string->ContainsOnlyOneByte());
@@ -22418,12 +22418,12 @@ class ApiCallOptimizationChecker {
   void RunAll() {
     SignatureType signature_types[] =
       {kNoSignature, kSignatureOnReceiver, kSignatureOnPrototype};
-    for (unsigned i = 0; i < ARRAY_SIZE(signature_types); i++) {
+    for (unsigned i = 0; i < arraysize(signature_types); i++) {
       SignatureType signature_type = signature_types[i];
       for (int j = 0; j < 2; j++) {
         bool global = j == 0;
         int key = signature_type +
-            ARRAY_SIZE(signature_types) * (global ? 1 : 0);
+            arraysize(signature_types) * (global ? 1 : 0);
         Run(signature_type, global, key);
       }
     }
index a49a7db..79e87dd 100644 (file)
@@ -20,7 +20,7 @@ TEST(CheckEqualsReflexivity) {
   double nan = v8::base::OS::nan_value();
   double constants[] = {-nan, -inf, -3.1415, -1.0,   -0.1, -0.0,
                         0.0,  0.1,  1.0,     3.1415, inf,  nan};
-  for (size_t i = 0; i < ARRAY_SIZE(constants); ++i) {
+  for (size_t i = 0; i < arraysize(constants); ++i) {
     CHECK_EQ(constants[i], constants[i]);
   }
 }
index 2d91371..d5cae22 100644 (file)
@@ -238,7 +238,7 @@ TEST(C2JSFrames) {
   Execution::Call(isolate,
                   Handle<JSFunction>::cast(fun1),
                   global,
-                  ARRAY_SIZE(argv),
+                  arraysize(argv),
                   argv).Check();
 }
 
index 6051c3f..8d429d2 100644 (file)
@@ -469,7 +469,7 @@ static const v8::CpuProfileNode* GetChild(v8::Isolate* isolate,
   const v8::CpuProfileNode* result = FindChild(isolate, node, name);
   if (!result) {
     char buffer[100];
-    i::SNPrintF(Vector<char>(buffer, ARRAY_SIZE(buffer)),
+    i::SNPrintF(Vector<char>(buffer, arraysize(buffer)),
                 "Failed to GetChild: %s", name);
     FATAL(buffer);
   }
@@ -552,8 +552,8 @@ TEST(CollectCpuProfile) {
     v8::Integer::New(env->GetIsolate(), profiling_interval_ms)
   };
   v8::CpuProfile* profile =
-      RunProfiler(env.local(), function, args, ARRAY_SIZE(args), 200);
-  function->Call(env->Global(), ARRAY_SIZE(args), args);
+      RunProfiler(env.local(), function, args, arraysize(args), 200);
+  function->Call(env->Global(), arraysize(args), args);
 
   const v8::CpuProfileNode* root = profile->GetTopDownRoot();
 
@@ -575,13 +575,13 @@ TEST(CollectCpuProfile) {
 
   const char* barBranch[] = { "bar", "delay", "loop" };
   CheckSimpleBranch(env->GetIsolate(), fooNode, barBranch,
-                    ARRAY_SIZE(barBranch));
+                    arraysize(barBranch));
   const char* bazBranch[] = { "baz", "delay", "loop" };
   CheckSimpleBranch(env->GetIsolate(), fooNode, bazBranch,
-                    ARRAY_SIZE(bazBranch));
+                    arraysize(bazBranch));
   const char* delayBranch[] = { "delay", "loop" };
   CheckSimpleBranch(env->GetIsolate(), fooNode, delayBranch,
-                    ARRAY_SIZE(delayBranch));
+                    arraysize(delayBranch));
 
   profile->Delete();
 }
@@ -630,8 +630,8 @@ TEST(HotDeoptNoFrameEntry) {
     v8::Integer::New(env->GetIsolate(), profiling_interval_ms)
   };
   v8::CpuProfile* profile =
-      RunProfiler(env.local(), function, args, ARRAY_SIZE(args), 200);
-  function->Call(env->Global(), ARRAY_SIZE(args), args);
+      RunProfiler(env.local(), function, args, arraysize(args), 200);
+  function->Call(env->Global(), arraysize(args), args);
 
   const v8::CpuProfileNode* root = profile->GetTopDownRoot();
 
@@ -667,7 +667,7 @@ TEST(CollectCpuProfileSamples) {
     v8::Integer::New(env->GetIsolate(), profiling_interval_ms)
   };
   v8::CpuProfile* profile =
-      RunProfiler(env.local(), function, args, ARRAY_SIZE(args), 200, true);
+      RunProfiler(env.local(), function, args, arraysize(args), 200, true);
 
   CHECK_LE(200, profile->GetSamplesCount());
   uint64_t end_time = profile->GetEndTime();
@@ -723,7 +723,7 @@ TEST(SampleWhenFrameIsNotSetup) {
     v8::Integer::New(env->GetIsolate(), repeat_count)
   };
   v8::CpuProfile* profile =
-      RunProfiler(env.local(), function, args, ARRAY_SIZE(args), 100);
+      RunProfiler(env.local(), function, args, arraysize(args), 100);
 
   const v8::CpuProfileNode* root = profile->GetTopDownRoot();
 
@@ -843,7 +843,7 @@ TEST(NativeAccessorUninitializedIC) {
   int32_t repeat_count = 1;
   v8::Handle<v8::Value> args[] = { v8::Integer::New(isolate, repeat_count) };
   v8::CpuProfile* profile =
-      RunProfiler(env.local(), function, args, ARRAY_SIZE(args), 180);
+      RunProfiler(env.local(), function, args, arraysize(args), 180);
 
   const v8::CpuProfileNode* root = profile->GetTopDownRoot();
   const v8::CpuProfileNode* startNode =
@@ -893,14 +893,14 @@ TEST(NativeAccessorMonomorphicIC) {
     v8::Handle<v8::Value> args[] = {
       v8::Integer::New(isolate, warm_up_iterations)
     };
-    function->Call(env->Global(), ARRAY_SIZE(args), args);
+    function->Call(env->Global(), arraysize(args), args);
     accessors.set_warming_up(false);
   }
 
   int32_t repeat_count = 100;
   v8::Handle<v8::Value> args[] = { v8::Integer::New(isolate, repeat_count) };
   v8::CpuProfile* profile =
-      RunProfiler(env.local(), function, args, ARRAY_SIZE(args), 200);
+      RunProfiler(env.local(), function, args, arraysize(args), 200);
 
   const v8::CpuProfileNode* root = profile->GetTopDownRoot();
   const v8::CpuProfileNode* startNode =
@@ -954,7 +954,7 @@ TEST(NativeMethodUninitializedIC) {
   int32_t repeat_count = 1;
   v8::Handle<v8::Value> args[] = { v8::Integer::New(isolate, repeat_count) };
   v8::CpuProfile* profile =
-      RunProfiler(env.local(), function, args, ARRAY_SIZE(args), 100);
+      RunProfiler(env.local(), function, args, arraysize(args), 100);
 
   const v8::CpuProfileNode* root = profile->GetTopDownRoot();
   const v8::CpuProfileNode* startNode =
@@ -1004,14 +1004,14 @@ TEST(NativeMethodMonomorphicIC) {
     v8::Handle<v8::Value> args[] = {
       v8::Integer::New(isolate, warm_up_iterations)
     };
-    function->Call(env->Global(), ARRAY_SIZE(args), args);
+    function->Call(env->Global(), arraysize(args), args);
     callbacks.set_warming_up(false);
   }
 
   int32_t repeat_count = 100;
   v8::Handle<v8::Value> args[] = { v8::Integer::New(isolate, repeat_count) };
   v8::CpuProfile* profile =
-      RunProfiler(env.local(), function, args, ARRAY_SIZE(args), 100);
+      RunProfiler(env.local(), function, args, arraysize(args), 100);
 
   const v8::CpuProfileNode* root = profile->GetTopDownRoot();
   GetChild(isolate, root, "start");
@@ -1105,7 +1105,7 @@ TEST(FunctionCallSample) {
     v8::Integer::New(env->GetIsolate(), duration_ms)
   };
   v8::CpuProfile* profile =
-      RunProfiler(env.local(), function, args, ARRAY_SIZE(args), 100);
+      RunProfiler(env.local(), function, args, arraysize(args), 100);
 
   const v8::CpuProfileNode* root = profile->GetTopDownRoot();
   {
@@ -1188,7 +1188,7 @@ TEST(FunctionApplySample) {
   };
 
   v8::CpuProfile* profile =
-      RunProfiler(env.local(), function, args, ARRAY_SIZE(args), 100);
+      RunProfiler(env.local(), function, args, arraysize(args), 100);
 
   const v8::CpuProfileNode* root = profile->GetTopDownRoot();
   {
@@ -1321,7 +1321,7 @@ static const char* js_native_js_test_source =
 static void CallJsFunction(const v8::FunctionCallbackInfo<v8::Value>& info) {
   v8::Handle<v8::Function> function = info[0].As<v8::Function>();
   v8::Handle<v8::Value> argv[] = { info[1] };
-  function->Call(info.This(), ARRAY_SIZE(argv), argv);
+  function->Call(info.This(), arraysize(argv), argv);
 }
 
 
index f218795..2f722c2 100644 (file)
@@ -132,7 +132,7 @@ TEST(DaylightSavingsTime) {
   int local_offset_ms = -36000000;  // -10 hours.
 
   DateCacheMock* date_cache =
-    new DateCacheMock(local_offset_ms, rules, ARRAY_SIZE(rules));
+    new DateCacheMock(local_offset_ms, rules, arraysize(rules));
 
   reinterpret_cast<Isolate*>(isolate)->set_date_cache(date_cache);
 
index 4331907..c98d480 100644 (file)
@@ -4154,7 +4154,7 @@ TEST(DebugBreak) {
 
   // Call all functions with different argument count.
   break_point_hit_count = 0;
-  for (unsigned int i = 0; i < ARRAY_SIZE(argv); i++) {
+  for (unsigned int i = 0; i < arraysize(argv); i++) {
     f0->Call(env->Global(), i, argv);
     f1->Call(env->Global(), i, argv);
     f2->Call(env->Global(), i, argv);
@@ -4162,7 +4162,7 @@ TEST(DebugBreak) {
   }
 
   // One break for each function called.
-  CHECK_EQ(4 * ARRAY_SIZE(argv), break_point_hit_count);
+  CHECK_EQ(4 * arraysize(argv), break_point_hit_count);
 
   // Get rid of the debug event listener.
   v8::Debug::SetDebugEventListener(NULL);
index 94bec31..8de610b 100644 (file)
@@ -2311,7 +2311,7 @@ TEST(CheckCodeNames) {
     "::(ArraySingleArgumentConstructorStub code)"
   };
   const v8::HeapGraphNode* node = GetNodeByPath(snapshot,
-      stub_path, ARRAY_SIZE(stub_path));
+      stub_path, arraysize(stub_path));
   CHECK_NE(NULL, node);
 
   const char* builtin_path1[] = {
@@ -2319,7 +2319,7 @@ TEST(CheckCodeNames) {
     "::(Builtins)",
     "::(KeyedLoadIC_Generic builtin)"
   };
-  node = GetNodeByPath(snapshot, builtin_path1, ARRAY_SIZE(builtin_path1));
+  node = GetNodeByPath(snapshot, builtin_path1, arraysize(builtin_path1));
   CHECK_NE(NULL, node);
 
   const char* builtin_path2[] = {
@@ -2327,7 +2327,7 @@ TEST(CheckCodeNames) {
     "::(Builtins)",
     "::(CompileUnoptimized builtin)"
   };
-  node = GetNodeByPath(snapshot, builtin_path2, ARRAY_SIZE(builtin_path2));
+  node = GetNodeByPath(snapshot, builtin_path2, arraysize(builtin_path2));
   CHECK_NE(NULL, node);
   v8::String::Utf8Value node_name(node->GetName());
   CHECK_EQ("(CompileUnoptimized builtin)", *node_name);
@@ -2420,7 +2420,7 @@ TEST(ArrayGrowLeftTrim) {
   tracker->trace_tree()->Print(tracker);
 
   AllocationTraceNode* node =
-      FindNode(tracker, Vector<const char*>(names, ARRAY_SIZE(names)));
+      FindNode(tracker, Vector<const char*>(names, arraysize(names)));
   CHECK_NE(NULL, node);
   CHECK_GE(node->allocation_count(), 2);
   CHECK_GE(node->allocation_size(), 4 * 5);
@@ -2447,7 +2447,7 @@ TEST(TrackHeapAllocations) {
 
   const char* names[] = {"", "start", "f_0_0", "f_0_1", "f_0_2"};
   AllocationTraceNode* node =
-      FindNode(tracker, Vector<const char*>(names, ARRAY_SIZE(names)));
+      FindNode(tracker, Vector<const char*>(names, arraysize(names)));
   CHECK_NE(NULL, node);
   CHECK_GE(node->allocation_count(), 100);
   CHECK_GE(node->allocation_size(), 4 * node->allocation_count());
@@ -2496,7 +2496,7 @@ TEST(TrackBumpPointerAllocations) {
     tracker->trace_tree()->Print(tracker);
 
     AllocationTraceNode* node =
-        FindNode(tracker, Vector<const char*>(names, ARRAY_SIZE(names)));
+        FindNode(tracker, Vector<const char*>(names, arraysize(names)));
     CHECK_NE(NULL, node);
     CHECK_GE(node->allocation_count(), 100);
     CHECK_GE(node->allocation_size(), 4 * node->allocation_count());
@@ -2522,7 +2522,7 @@ TEST(TrackBumpPointerAllocations) {
     tracker->trace_tree()->Print(tracker);
 
     AllocationTraceNode* node =
-        FindNode(tracker, Vector<const char*>(names, ARRAY_SIZE(names)));
+        FindNode(tracker, Vector<const char*>(names, arraysize(names)));
     CHECK_NE(NULL, node);
     CHECK_LT(node->allocation_count(), 100);
 
@@ -2552,7 +2552,7 @@ TEST(TrackV8ApiAllocation) {
   tracker->trace_tree()->Print(tracker);
 
   AllocationTraceNode* node =
-      FindNode(tracker, Vector<const char*>(names, ARRAY_SIZE(names)));
+      FindNode(tracker, Vector<const char*>(names, arraysize(names)));
   CHECK_NE(NULL, node);
   CHECK_GE(node->allocation_count(), 2);
   CHECK_GE(node->allocation_size(), 4 * node->allocation_count());
index 1d4b0d8..6047823 100644 (file)
@@ -139,13 +139,13 @@ TEST(MarkCompactCollector) {
   heap->CollectGarbage(OLD_POINTER_SPACE, "trigger 1");
 
   // keep allocating garbage in new space until it fails
-  const int ARRAY_SIZE = 100;
+  const int arraysize = 100;
   AllocationResult allocation;
   do {
-    allocation = heap->AllocateFixedArray(ARRAY_SIZE);
+    allocation = heap->AllocateFixedArray(arraysize);
   } while (!allocation.IsRetry());
   heap->CollectGarbage(NEW_SPACE, "trigger 2");
-  heap->AllocateFixedArray(ARRAY_SIZE).ToObjectChecked();
+  heap->AllocateFixedArray(arraysize).ToObjectChecked();
 
   // keep allocating maps until it fails
   do {
index 679569e..d208a26 100644 (file)
@@ -253,7 +253,7 @@ static void ExpectRecords(v8::Isolate* isolate,
 
 #define EXPECT_RECORDS(records, expectations)                \
   ExpectRecords(CcTest::isolate(), records, expectations, \
-                ARRAY_SIZE(expectations))
+                arraysize(expectations))
 
 TEST(APITestBasicMutation) {
   v8::Isolate* v8_isolate = CcTest::isolate();
index 57671c0..8a76f52 100644 (file)
@@ -87,7 +87,7 @@ TEST(ScanKeywords) {
     }
     // Adding characters will make keyword matching fail.
     static const char chars_to_append[] = { 'z', '0', '_' };
-    for (int j = 0; j < static_cast<int>(ARRAY_SIZE(chars_to_append)); ++j) {
+    for (int j = 0; j < static_cast<int>(arraysize(chars_to_append)); ++j) {
       i::MemMove(buffer, keyword, length);
       buffer[length] = chars_to_append[j];
       i::Utf8ToUtf16CharacterStream stream(buffer, length + 1);
@@ -265,7 +265,7 @@ TEST(PreparseFunctionDataIsUsed) {
       "var this_is_lazy = () => { if (   }; var foo = () => 25; foo();",
   };
 
-  for (unsigned i = 0; i < ARRAY_SIZE(good_code); i++) {
+  for (unsigned i = 0; i < arraysize(good_code); i++) {
     v8::ScriptCompiler::Source good_source(v8_str(good_code[i]));
     v8::ScriptCompiler::Compile(isolate, &good_source,
                                 v8::ScriptCompiler::kProduceDataToCache);
@@ -1459,7 +1459,7 @@ TEST(ParserSync) {
             termination_data[k],
             context_data[i][1]);
         CHECK(length == kProgramSize);
-        TestParserSync(program.start(), flags1, ARRAY_SIZE(flags1));
+        TestParserSync(program.start(), flags1, arraysize(flags1));
       }
     }
   }
@@ -1468,11 +1468,11 @@ TEST(ParserSync) {
   // interaction with the flags above, so test these separately to reduce
   // the combinatorial explosion.
   static const ParserFlag flags2[] = { kAllowHarmonyNumericLiterals };
-  TestParserSync("0o1234", flags2, ARRAY_SIZE(flags2));
-  TestParserSync("0b1011", flags2, ARRAY_SIZE(flags2));
+  TestParserSync("0o1234", flags2, arraysize(flags2));
+  TestParserSync("0b1011", flags2, arraysize(flags2));
 
   static const ParserFlag flags3[] = { kAllowNativesSyntax };
-  TestParserSync("%DebugPrint(123)", flags3, ARRAY_SIZE(flags3));
+  TestParserSync("%DebugPrint(123)", flags3, arraysize(flags3));
 }
 
 
@@ -1520,7 +1520,7 @@ void RunParserSyncTest(const char* context_data[][2],
   ParserFlag* generated_flags = NULL;
   if (flags == NULL) {
     flags = default_flags;
-    flags_len = ARRAY_SIZE(default_flags);
+    flags_len = arraysize(default_flags);
     if (always_true_flags != NULL) {
       // Remove always_true_flags from default_flags.
       CHECK(always_true_flags_len < flags_len);
@@ -1670,7 +1670,7 @@ TEST(NoErrorsEvalAndArgumentsStrict) {
 
   static const ParserFlag always_flags[] = {kAllowArrowFunctions};
   RunParserSyncTest(context_data, statement_data, kSuccess, NULL, 0,
-                    always_flags, ARRAY_SIZE(always_flags));
+                    always_flags, arraysize(always_flags));
 }
 
 
@@ -1703,7 +1703,7 @@ TEST(ErrorsFutureStrictReservedWords) {
 
   static const ParserFlag always_flags[] = {kAllowArrowFunctions};
   RunParserSyncTest(context_data, statement_data, kError, NULL, 0, always_flags,
-                    ARRAY_SIZE(always_flags));
+                    arraysize(always_flags));
 }
 
 
@@ -1732,7 +1732,7 @@ TEST(NoErrorsFutureStrictReservedWords) {
 
   static const ParserFlag always_flags[] = {kAllowArrowFunctions};
   RunParserSyncTest(context_data, statement_data, kSuccess, NULL, 0,
-                    always_flags, ARRAY_SIZE(always_flags));
+                    always_flags, arraysize(always_flags));
 }
 
 
@@ -2157,7 +2157,7 @@ TEST(NoErrorsIllegalWordsAsLabels) {
 
   static const ParserFlag always_flags[] = {kAllowArrowFunctions};
   RunParserSyncTest(context_data, statement_data, kSuccess, NULL, 0,
-                    always_flags, ARRAY_SIZE(always_flags));
+                    always_flags, arraysize(always_flags));
 }
 
 
@@ -3098,10 +3098,10 @@ TEST(InnerAssignment) {
   int prefix_len = Utf8LengthHelper(prefix);
   int midfix_len = Utf8LengthHelper(midfix);
   int suffix_len = Utf8LengthHelper(suffix);
-  for (unsigned i = 0; i < ARRAY_SIZE(outers); ++i) {
+  for (unsigned i = 0; i < arraysize(outers); ++i) {
     const char* outer = outers[i].source;
     int outer_len = Utf8LengthHelper(outer);
-    for (unsigned j = 0; j < ARRAY_SIZE(inners); ++j) {
+    for (unsigned j = 0; j < arraysize(inners); ++j) {
       for (unsigned outer_lazy = 0; outer_lazy < 2; ++outer_lazy) {
         for (unsigned inner_lazy = 0; inner_lazy < 2; ++inner_lazy) {
           if (outers[i].strict && inners[j].with) continue;
@@ -3280,7 +3280,7 @@ TEST(ErrorsArrowFunctions) {
   };
   static const ParserFlag always_flags[] = { kAllowArrowFunctions };
   RunParserSyncTest(context_data, statement_data, kError, flags,
-                    ARRAY_SIZE(flags), always_flags, ARRAY_SIZE(always_flags));
+                    arraysize(flags), always_flags, arraysize(always_flags));
 }
 
 
@@ -3334,7 +3334,7 @@ TEST(NoErrorsArrowFunctions) {
 
   static const ParserFlag always_flags[] = {kAllowArrowFunctions};
   RunParserSyncTest(context_data, statement_data, kSuccess, NULL, 0,
-                    always_flags, ARRAY_SIZE(always_flags));
+                    always_flags, arraysize(always_flags));
 }
 
 
@@ -3359,7 +3359,7 @@ TEST(NoErrorsSuper) {
 
   static const ParserFlag always_flags[] = {kAllowClasses};
   RunParserSyncTest(context_data, statement_data, kSuccess, NULL, 0,
-                    always_flags, ARRAY_SIZE(always_flags));
+                    always_flags, arraysize(always_flags));
 }
 
 
@@ -3378,5 +3378,5 @@ TEST(ErrorsSuper) {
 
   static const ParserFlag always_flags[] = {kAllowClasses};
   RunParserSyncTest(context_data, statement_data, kError, NULL, 0,
-                    always_flags, ARRAY_SIZE(always_flags));
+                    always_flags, arraysize(always_flags));
 }
index a53205c..d2e67c7 100644 (file)
@@ -41,7 +41,7 @@ static const int kRandomSeeds[] = {
 
 
 TEST(RandomSeedFlagIsUsed) {
-  for (unsigned n = 0; n < ARRAY_SIZE(kRandomSeeds); ++n) {
+  for (unsigned n = 0; n < arraysize(kRandomSeeds); ++n) {
     FLAG_random_seed = kRandomSeeds[n];
     v8::Isolate* i = v8::Isolate::New();
     v8::base::RandomNumberGenerator& rng1 =
index de09c21..159858e 100644 (file)
@@ -34,7 +34,7 @@ GET_TYPE_NAME(double)
 // inside the loop body.
 // TODO(bmeurer): Migrate to C++11 once we're ready.
 #define TRACED_FOREACH(_type, _var, _array)                                \
-  for (size_t _i = 0; _i < ARRAY_SIZE(_array); ++_i)                       \
+  for (size_t _i = 0; _i < arraysize(_array); ++_i)                        \
     for (bool _done = false; !_done;)                                      \
       for (const _type _var = _array[_i]; !_done;)                         \
         for (SCOPED_TRACE(::testing::Message() << #_var << " = " << _var); \