i::Handle<i::Object> argv[] = { data };
return CallV8HeapFunction(name,
i::Isolate::Current()->js_builtins_object(),
- ARRAY_SIZE(argv),
+ arraysize(argv),
argv);
}
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);
}
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);
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));
}
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();
isolate,
isolate->promise_resolve(),
isolate->factory()->undefined_value(),
- ARRAY_SIZE(argv), argv,
+ arraysize(argv), argv,
false).is_null();
EXCEPTION_BAILOUT_CHECK(isolate, /* void */ ;);
}
isolate,
isolate->promise_reject(),
isolate->factory()->undefined_value(),
- ARRAY_SIZE(argv), argv,
+ arraysize(argv), argv,
false).is_null();
EXCEPTION_BAILOUT_CHECK(isolate, /* void */ ;);
}
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));
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));
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));
}
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());
CodeStubInterfaceDescriptor* descriptor) {
Register registers[] = { cp, r2 };
descriptor->Initialize(
- MajorKey(), ARRAY_SIZE(registers), registers,
+ MajorKey(), arraysize(registers), registers,
Runtime::FunctionForId(Runtime::kNewClosureFromStubFailure)->entry);
}
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);
}
CodeStubInterfaceDescriptor* descriptor) {
Register registers[] = { cp, r0 };
descriptor->Initialize(
- MajorKey(), ARRAY_SIZE(registers), registers,
+ MajorKey(), arraysize(registers), registers,
Runtime::FunctionForId(Runtime::kNumberToStringRT)->entry);
}
Representation::Smi(),
Representation::Tagged() };
descriptor->Initialize(
- MajorKey(), ARRAY_SIZE(registers), registers,
+ MajorKey(), arraysize(registers), registers,
Runtime::FunctionForId(Runtime::kCreateArrayLiteralStubBailout)->entry,
representations);
}
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);
}
void CreateAllocationSiteStub::InitializeInterfaceDescriptor(
CodeStubInterfaceDescriptor* descriptor) {
Register registers[] = { cp, r2, r3 };
- descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers);
+ descriptor->Initialize(MajorKey(), arraysize(registers), registers);
}
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);
}
// 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);
}
CodeStubInterfaceDescriptor* descriptor) {
Register registers[] = { cp, r2, r1, r0 };
descriptor->Initialize(
- MajorKey(), ARRAY_SIZE(registers), registers,
+ MajorKey(), arraysize(registers), registers,
Runtime::FunctionForId(Runtime::kRegExpConstructResult)->entry);
}
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));
}
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()));
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 {
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);
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 {
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);
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()));
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()));
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));
}
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);
}
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);
}
{
Representation::Tagged(), // context
Representation::Tagged(), // key
};
- descriptor->Initialize(ARRAY_SIZE(registers), registers,
+ descriptor->Initialize(arraysize(registers), registers,
representations, &noInlineDescriptor);
}
{
Representation::Tagged(), // context
Representation::Tagged(), // name
};
- descriptor->Initialize(ARRAY_SIZE(registers), registers,
+ descriptor->Initialize(arraysize(registers), registers,
representations, &noInlineDescriptor);
}
{
Representation::Tagged(), // context
Representation::Tagged(), // receiver
};
- descriptor->Initialize(ARRAY_SIZE(registers), registers,
+ descriptor->Initialize(arraysize(registers), registers,
representations, &default_descriptor);
}
{
Representation::Tagged(), // holder
Representation::External(), // api_function_address
};
- descriptor->Initialize(ARRAY_SIZE(registers), registers,
+ descriptor->Initialize(arraysize(registers), registers,
representations, &default_descriptor);
}
}
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();
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;
// x2: function info
Register registers[] = { cp, x2 };
descriptor->Initialize(
- MajorKey(), ARRAY_SIZE(registers), registers,
+ MajorKey(), arraysize(registers), registers,
Runtime::FunctionForId(Runtime::kNewClosureFromStubFailure)->entry);
}
// cp: context
// x1: function
Register registers[] = { cp, x1 };
- descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers);
+ descriptor->Initialize(MajorKey(), arraysize(registers), registers);
}
// cp: context
// x0: value
Register registers[] = { cp, x0 };
- descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers);
+ descriptor->Initialize(MajorKey(), arraysize(registers), registers);
}
// x0: value
Register registers[] = { cp, x0 };
descriptor->Initialize(
- MajorKey(), ARRAY_SIZE(registers), registers,
+ MajorKey(), arraysize(registers), registers,
Runtime::FunctionForId(Runtime::kNumberToStringRT)->entry);
}
Representation::Smi(),
Representation::Tagged() };
descriptor->Initialize(
- MajorKey(), ARRAY_SIZE(registers), registers,
+ MajorKey(), arraysize(registers), registers,
Runtime::FunctionForId(Runtime::kCreateArrayLiteralStubBailout)->entry,
representations);
}
// 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);
}
// 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);
}
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);
}
// 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);
}
// x0: string
Register registers[] = { cp, x2, x1, x0 };
descriptor->Initialize(
- MajorKey(), ARRAY_SIZE(registers), registers,
+ MajorKey(), arraysize(registers), registers,
Runtime::FunctionForId(Runtime::kRegExpConstructResult)->entry);
}
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));
}
// 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()));
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 {
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);
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 {
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);
// 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()));
// 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()));
// 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));
}
// 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);
}
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);
}
{
Representation::Tagged(), // context
Representation::Tagged(), // key
};
- descriptor->Initialize(ARRAY_SIZE(registers), registers,
+ descriptor->Initialize(arraysize(registers), registers,
representations, &noInlineDescriptor);
}
{
Representation::Tagged(), // context
Representation::Tagged(), // name
};
- descriptor->Initialize(ARRAY_SIZE(registers), registers,
+ descriptor->Initialize(arraysize(registers), registers,
representations, &noInlineDescriptor);
}
{
Representation::Tagged(), // context
Representation::Tagged(), // receiver
};
- descriptor->Initialize(ARRAY_SIZE(registers), registers,
+ descriptor->Initialize(arraysize(registers), registers,
representations, &default_descriptor);
}
{
Representation::Tagged(), // holder
Representation::External(), // api_function_address
};
- descriptor->Initialize(ARRAY_SIZE(registers), registers,
+ descriptor->Initialize(arraysize(registers), registers,
representations, &default_descriptor);
}
}
}
}
- 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);
"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,
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.
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) {
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");
(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
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),
};
#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.
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));
}
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));
}
LoadIC::NameRegister() };
STATIC_ASSERT(LoadIC::kParameterCount == 2);
descriptor->Initialize(
- MajorKey(), ARRAY_SIZE(registers), registers,
+ MajorKey(), arraysize(registers), registers,
Runtime::FunctionForId(Runtime::kKeyedGetProperty)->entry);
}
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));
}
}
KeyedStoreIC::ReceiverRegister(),
KeyedStoreIC::NameRegister(),
KeyedStoreIC::ValueRegister() };
- descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers,
+ descriptor->Initialize(MajorKey(), arraysize(registers), registers,
FUNCTION_ADDR(KeyedStoreIC_MissFromStubFailure));
}
MapRegister(),
KeyRegister(),
ObjectRegister() };
- descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers,
+ descriptor->Initialize(MajorKey(), arraysize(registers), registers,
FUNCTION_ADDR(ElementsTransitionAndStoreIC_Miss));
}
Register registers[] = { InterfaceDescriptor::ContextRegister(),
InstanceofStub::left(),
InstanceofStub::right() };
- descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers);
+ descriptor->Initialize(MajorKey(), arraysize(registers), registers);
}
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,
// 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;
}
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,
}
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);
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);
// 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;
}
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) {
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);
// 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;
}
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);
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);
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);
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);
}
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);
}
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);
}
Register registers[] = { InterfaceDescriptor::ContextRegister(),
LoadIC::ReceiverRegister(),
LoadIC::NameRegister() };
- descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers);
+ descriptor->Initialize(MajorKey(), arraysize(registers), registers);
}
private:
Register registers[] = { InterfaceDescriptor::ContextRegister(),
KeyedLoadIC::ReceiverRegister(),
KeyedLoadIC::NameRegister() };
- descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers);
+ descriptor->Initialize(MajorKey(), arraysize(registers), registers);
}
private:
StoreIC::ReceiverRegister(),
StoreIC::NameRegister(),
StoreIC::ValueRegister() };
- descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers);
+ descriptor->Initialize(MajorKey(), arraysize(registers), registers);
}
private:
KeyedStoreIC::ReceiverRegister(),
KeyedStoreIC::NameRegister(),
KeyedStoreIC::ValueRegister() };
- descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers);
+ descriptor->Initialize(MajorKey(), arraysize(registers), registers);
}
private:
// 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;
}
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);
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);
}
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);
}
// 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));
}
Handle<Object> result;
if (!Execution::TryCall(check_break_point,
isolate_->js_builtins_object(),
- ARRAY_SIZE(argv),
+ arraysize(argv),
argv).ToHandle(&result)) {
return false;
}
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);
}
// 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);
}
exception,
isolate_->factory()->ToBoolean(uncaught),
promise };
- return MakeJSObject("MakeExceptionEvent", ARRAY_SIZE(argv), argv);
+ return MakeJSObject("MakeExceptionEvent", arraysize(argv), argv);
}
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);
}
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;
}
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);
}
}
isolate_,
fun,
Handle<Object>(debug_context()->global_proxy(), isolate_),
- ARRAY_SIZE(argv),
+ arraysize(argv),
argv);
}
// 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;
}
}
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;
}
return Call(isolate, \
isolate->name##_fun(), \
isolate->js_builtins_object(), \
- ARRAY_SIZE(argv), argv); \
+ arraysize(argv), argv); \
} while (false)
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();
}
Call(isolate,
isolate->instantiate_fun(),
isolate->js_builtins_object(),
- ARRAY_SIZE(args),
+ arraysize(args),
args),
JSFunction);
return Handle<JSFunction>::cast(result);
Call(isolate,
isolate->instantiate_fun(),
isolate->js_builtins_object(),
- ARRAY_SIZE(args),
+ arraysize(args),
args),
JSObject);
}
return Execution::Call(isolate,
isolate->configure_instance_fun(),
isolate->js_builtins_object(),
- ARRAY_SIZE(args),
+ arraysize(args),
args);
}
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()) {
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--;
Handle<Object> exception;
if (!Execution::TryCall(fun,
isolate()->js_builtins_object(),
- ARRAY_SIZE(argv),
+ arraysize(argv),
argv,
&exception).ToHandle(&result)) {
return exception;
Handle<Object> exception;
if (!Execution::TryCall(fun,
isolate()->js_builtins_object(),
- ARRAY_SIZE(argv),
+ arraysize(argv),
argv,
&exception).ToHandle(&result)) {
return exception;
}
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();
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];
}
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;
}
}
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);
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;
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;
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;
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.
CodeStubInterfaceDescriptor* descriptor) {
Register registers[] = { esi, ebx };
descriptor->Initialize(
- MajorKey(), ARRAY_SIZE(registers), registers,
+ MajorKey(), arraysize(registers), registers,
Runtime::FunctionForId(Runtime::kNewClosureFromStubFailure)->entry);
}
void FastNewContextStub::InitializeInterfaceDescriptor(
CodeStubInterfaceDescriptor* descriptor) {
Register registers[] = { esi, edi };
- descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers);
+ descriptor->Initialize(MajorKey(), arraysize(registers), registers);
}
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);
}
CodeStubInterfaceDescriptor* descriptor) {
Register registers[] = { esi, eax };
descriptor->Initialize(
- MajorKey(), ARRAY_SIZE(registers), registers,
+ MajorKey(), arraysize(registers), registers,
Runtime::FunctionForId(Runtime::kNumberToStringRT)->entry);
}
Representation::Tagged() };
descriptor->Initialize(
- MajorKey(), ARRAY_SIZE(registers), registers,
+ MajorKey(), arraysize(registers), registers,
Runtime::FunctionForId(Runtime::kCreateArrayLiteralStubBailout)->entry,
representations);
}
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);
}
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);
}
// 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);
}
CodeStubInterfaceDescriptor* descriptor) {
Register registers[] = { esi, ecx, ebx, eax };
descriptor->Initialize(
- MajorKey(), ARRAY_SIZE(registers), registers,
+ MajorKey(), arraysize(registers), registers,
Runtime::FunctionForId(Runtime::kRegExpConstructResult)->entry);
}
CodeStubInterfaceDescriptor* descriptor) {
Register registers[] = { esi, eax, ebx };
descriptor->Initialize(
- MajorKey(), ARRAY_SIZE(registers), registers,
+ MajorKey(), arraysize(registers), registers,
Runtime::FunctionForId(Runtime::kTransitionElementsKind)->entry);
}
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 {
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);
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 {
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);
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()));
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()));
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()));
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));
}
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);
}
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 =
Representation::Tagged(), // context
Representation::Tagged(), // key
};
- descriptor->Initialize(ARRAY_SIZE(registers), registers, representations);
+ descriptor->Initialize(arraysize(registers), registers, representations);
}
{
CallInterfaceDescriptor* descriptor =
Representation::Tagged(), // context
Representation::Tagged(), // name
};
- descriptor->Initialize(ARRAY_SIZE(registers), registers, representations);
+ descriptor->Initialize(arraysize(registers), registers, representations);
}
{
CallInterfaceDescriptor* descriptor =
Representation::Tagged(), // context
Representation::Tagged(), // receiver
};
- descriptor->Initialize(ARRAY_SIZE(registers), registers, representations);
+ descriptor->Initialize(arraysize(registers), registers, representations);
}
{
CallInterfaceDescriptor* descriptor =
Representation::Tagged(), // holder
Representation::External(), // api_function_address
};
- descriptor->Initialize(ARRAY_SIZE(registers), registers, representations);
+ descriptor->Initialize(arraysize(registers), registers, representations);
}
}
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);
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);
}
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) {
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);
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>"));
CodeStubInterfaceDescriptor* descriptor) {
Register registers[] = { cp, a2 };
descriptor->Initialize(
- MajorKey(), ARRAY_SIZE(registers), registers,
+ MajorKey(), arraysize(registers), registers,
Runtime::FunctionForId(Runtime::kNewClosureFromStubFailure)->entry);
}
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);
}
CodeStubInterfaceDescriptor* descriptor) {
Register registers[] = { cp, a0 };
descriptor->Initialize(
- MajorKey(), ARRAY_SIZE(registers), registers,
+ MajorKey(), arraysize(registers), registers,
Runtime::FunctionForId(Runtime::kNumberToStringRT)->entry);
}
Representation::Smi(),
Representation::Tagged() };
descriptor->Initialize(
- MajorKey(), ARRAY_SIZE(registers), registers,
+ MajorKey(), arraysize(registers), registers,
Runtime::FunctionForId(Runtime::kCreateArrayLiteralStubBailout)->entry,
representations);
}
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);
}
void CreateAllocationSiteStub::InitializeInterfaceDescriptor(
CodeStubInterfaceDescriptor* descriptor) {
Register registers[] = { cp, a2, a3 };
- descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers);
+ descriptor->Initialize(MajorKey(), arraysize(registers), registers);
}
CodeStubInterfaceDescriptor* descriptor) {
Register registers[] = { cp, a2, a1, a0 };
descriptor->Initialize(
- MajorKey(), ARRAY_SIZE(registers), registers,
+ MajorKey(), arraysize(registers), registers,
Runtime::FunctionForId(Runtime::kRegExpConstructResult)->entry);
}
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));
}
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()));
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 {
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);
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 {
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);
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()));
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()));
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));
}
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);
}
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 =
Representation::Tagged(), // context
Representation::Tagged(), // key
};
- descriptor->Initialize(ARRAY_SIZE(registers), registers, representations);
+ descriptor->Initialize(arraysize(registers), registers, representations);
}
{
CallInterfaceDescriptor* descriptor =
Representation::Tagged(), // context
Representation::Tagged(), // name
};
- descriptor->Initialize(ARRAY_SIZE(registers), registers, representations);
+ descriptor->Initialize(arraysize(registers), registers, representations);
}
{
CallInterfaceDescriptor* descriptor =
Representation::Tagged(), // context
Representation::Tagged(), // receiver
};
- descriptor->Initialize(ARRAY_SIZE(registers), registers, representations);
+ descriptor->Initialize(arraysize(registers), registers, representations);
}
{
CallInterfaceDescriptor* descriptor =
Representation::Tagged(), // holder
Representation::External(), // api_function_address
};
- descriptor->Initialize(ARRAY_SIZE(registers), registers, representations);
+ descriptor->Initialize(arraysize(registers), registers, representations);
}
}
CodeStubInterfaceDescriptor* descriptor) {
Register registers[] = { cp, a2 };
descriptor->Initialize(
- MajorKey(), ARRAY_SIZE(registers), registers,
+ MajorKey(), arraysize(registers), registers,
Runtime::FunctionForId(Runtime::kNewClosureFromStubFailure)->entry);
}
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);
}
CodeStubInterfaceDescriptor* descriptor) {
Register registers[] = { cp, a0 };
descriptor->Initialize(
- MajorKey(), ARRAY_SIZE(registers), registers,
+ MajorKey(), arraysize(registers), registers,
Runtime::FunctionForId(Runtime::kNumberToStringRT)->entry);
}
Representation::Smi(),
Representation::Tagged() };
descriptor->Initialize(
- MajorKey(), ARRAY_SIZE(registers), registers,
+ MajorKey(), arraysize(registers), registers,
Runtime::FunctionForId(Runtime::kCreateArrayLiteralStubBailout)->entry,
representations);
}
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);
}
void CreateAllocationSiteStub::InitializeInterfaceDescriptor(
CodeStubInterfaceDescriptor* descriptor) {
Register registers[] = { cp, a2, a3 };
- descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers);
+ descriptor->Initialize(MajorKey(), arraysize(registers), registers);
}
CodeStubInterfaceDescriptor* descriptor) {
Register registers[] = { cp, a2, a1, a0 };
descriptor->Initialize(
- MajorKey(), ARRAY_SIZE(registers), registers,
+ MajorKey(), arraysize(registers), registers,
Runtime::FunctionForId(Runtime::kRegExpConstructResult)->entry);
}
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));
}
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()));
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 {
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);
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 {
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);
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()));
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()));
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));
}
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);
}
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 =
Representation::Tagged(), // context
Representation::Tagged(), // key
};
- descriptor->Initialize(ARRAY_SIZE(registers), registers, representations);
+ descriptor->Initialize(arraysize(registers), registers, representations);
}
{
CallInterfaceDescriptor* descriptor =
Representation::Tagged(), // context
Representation::Tagged(), // name
};
- descriptor->Initialize(ARRAY_SIZE(registers), registers, representations);
+ descriptor->Initialize(arraysize(registers), registers, representations);
}
{
CallInterfaceDescriptor* descriptor =
Representation::Tagged(), // context
Representation::Tagged(), // receiver
};
- descriptor->Initialize(ARRAY_SIZE(registers), registers, representations);
+ descriptor->Initialize(arraysize(registers), registers, representations);
}
{
CallInterfaceDescriptor* descriptor =
Representation::Tagged(), // holder
Representation::External(), // api_function_address
};
- descriptor->Initialize(ARRAY_SIZE(registers), registers, representations);
+ descriptor->Initialize(arraysize(registers), registers, representations);
}
}
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");
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);
}
Handle<Object> error =
isolate->factory()->NewTypeError("incompatible_method_receiver",
HandleVector(args,
- ARRAY_SIZE(args)));
+ arraysize(args)));
return isolate->Throw<Object>(error);
}
if (structure->IsDeclaredAccessorInfo()) {
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();
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;
}
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);
}
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();
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());
CallTrap(proxy,
"set",
isolate->derived_set_trap(),
- ARRAY_SIZE(args),
+ arraysize(args),
args),
Object);
CallTrap(proxy,
"getPropertyDescriptor",
Handle<Object>(),
- ARRAY_SIZE(args),
+ arraysize(args),
args),
Object);
Execution::Call(isolate,
isolate->to_complete_property_descriptor(),
result,
- ARRAY_SIZE(argv),
+ arraysize(argv),
argv),
Object);
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());
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);
}
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);
}
CallTrap(proxy,
"delete",
Handle<Object>(),
- ARRAY_SIZE(args),
+ arraysize(args),
args),
Object);
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);
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);
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.
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);
}
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);
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>();
}
Execution::Call(isolate,
isolate->proxy_enumerate(),
object,
- ARRAY_SIZE(args),
+ arraysize(args),
args),
FixedArray);
ASSIGN_RETURN_ON_EXCEPTION(
Execution::Call(isolate,
Handle<JSFunction>(isolate->observers_enqueue_splice()),
isolate->factory()->undefined_value(),
- ARRAY_SIZE(args),
+ arraysize(args),
args).Assert();
}
Execution::Call(isolate,
Handle<JSFunction>(isolate->observers_begin_perform_splice()),
isolate->factory()->undefined_value(),
- ARRAY_SIZE(args),
+ arraysize(args),
args).Assert();
}
Execution::Call(isolate,
Handle<JSFunction>(isolate->observers_end_perform_splice()),
isolate->factory()->undefined_value(),
- ARRAY_SIZE(args),
+ arraysize(args),
args).Assert();
}
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);
}
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);
}
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);
}
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);
}
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,
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);
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
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]);
}
#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,
}; // 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,
// 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
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 << " | ";
#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));
CodeStubInterfaceDescriptor* descriptor) {
Register registers[] = { rsi, rbx };
descriptor->Initialize(
- MajorKey(), ARRAY_SIZE(registers), registers,
+ MajorKey(), arraysize(registers), registers,
Runtime::FunctionForId(Runtime::kNewClosureFromStubFailure)->entry);
}
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);
}
CodeStubInterfaceDescriptor* descriptor) {
Register registers[] = { rsi, rax };
descriptor->Initialize(
- MajorKey(), ARRAY_SIZE(registers), registers,
+ MajorKey(), arraysize(registers), registers,
Runtime::FunctionForId(Runtime::kNumberToStringRT)->entry);
}
Representation::Tagged() };
descriptor->Initialize(
- MajorKey(), ARRAY_SIZE(registers), registers,
+ MajorKey(), arraysize(registers), registers,
Runtime::FunctionForId(Runtime::kCreateArrayLiteralStubBailout)->entry,
representations);
}
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);
}
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);
}
// 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);
}
CodeStubInterfaceDescriptor* descriptor) {
Register registers[] = { rsi, rcx, rbx, rax };
descriptor->Initialize(
- MajorKey(), ARRAY_SIZE(registers), registers,
+ MajorKey(), arraysize(registers), registers,
Runtime::FunctionForId(Runtime::kRegExpConstructResult)->entry);
}
CodeStubInterfaceDescriptor* descriptor) {
Register registers[] = { rsi, rax, rbx };
descriptor->Initialize(
- MajorKey(), ARRAY_SIZE(registers), registers,
+ MajorKey(), arraysize(registers), registers,
Runtime::FunctionForId(Runtime::kTransitionElementsKind)->entry);
}
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 {
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);
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 {
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);
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()));
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()));
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()));
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));
}
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);
}
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 =
Representation::Tagged(), // context
Representation::Tagged(), // key
};
- descriptor->Initialize(ARRAY_SIZE(registers), registers, representations);
+ descriptor->Initialize(arraysize(registers), registers, representations);
}
{
CallInterfaceDescriptor* descriptor =
Representation::Tagged(), // context
Representation::Tagged(), // name
};
- descriptor->Initialize(ARRAY_SIZE(registers), registers, representations);
+ descriptor->Initialize(arraysize(registers), registers, representations);
}
{
CallInterfaceDescriptor* descriptor =
Representation::Tagged(), // context
Representation::Tagged(), // receiver
};
- descriptor->Initialize(ARRAY_SIZE(registers), registers, representations);
+ descriptor->Initialize(arraysize(registers), registers, representations);
}
{
CallInterfaceDescriptor* descriptor =
Representation::Tagged(), // holder
Representation::External(), // api_function_address
};
- descriptor->Initialize(ARRAY_SIZE(registers), registers, representations);
+ descriptor->Initialize(arraysize(registers), registers, representations);
}
}
CodeStubInterfaceDescriptor* descriptor) {
Register registers[] = { esi, ebx };
descriptor->Initialize(
- MajorKey(), ARRAY_SIZE(registers), registers,
+ MajorKey(), arraysize(registers), registers,
Runtime::FunctionForId(Runtime::kNewClosureFromStubFailure)->entry);
}
void FastNewContextStub::InitializeInterfaceDescriptor(
CodeStubInterfaceDescriptor* descriptor) {
Register registers[] = { esi, edi };
- descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers);
+ descriptor->Initialize(MajorKey(), arraysize(registers), registers);
}
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);
}
CodeStubInterfaceDescriptor* descriptor) {
Register registers[] = { esi, eax };
descriptor->Initialize(
- MajorKey(), ARRAY_SIZE(registers), registers,
+ MajorKey(), arraysize(registers), registers,
Runtime::FunctionForId(Runtime::kNumberToStringRT)->entry);
}
Representation::Tagged() };
descriptor->Initialize(
- MajorKey(), ARRAY_SIZE(registers), registers,
+ MajorKey(), arraysize(registers), registers,
Runtime::FunctionForId(Runtime::kCreateArrayLiteralStubBailout)->entry,
representations);
}
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);
}
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);
}
// 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);
}
CodeStubInterfaceDescriptor* descriptor) {
Register registers[] = { esi, ecx, ebx, eax };
descriptor->Initialize(
- MajorKey(), ARRAY_SIZE(registers), registers,
+ MajorKey(), arraysize(registers), registers,
Runtime::FunctionForId(Runtime::kRegExpConstructResult)->entry);
}
CodeStubInterfaceDescriptor* descriptor) {
Register registers[] = { esi, eax, ebx };
descriptor->Initialize(
- MajorKey(), ARRAY_SIZE(registers), registers,
+ MajorKey(), arraysize(registers), registers,
Runtime::FunctionForId(Runtime::kTransitionElementsKind)->entry);
}
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 {
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);
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 {
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);
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()));
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()));
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()));
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));
}
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);
}
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 =
Representation::Tagged(), // context
Representation::Tagged(), // key
};
- descriptor->Initialize(ARRAY_SIZE(registers), registers, representations);
+ descriptor->Initialize(arraysize(registers), registers, representations);
}
{
CallInterfaceDescriptor* descriptor =
Representation::Tagged(), // context
Representation::Tagged(), // name
};
- descriptor->Initialize(ARRAY_SIZE(registers), registers, representations);
+ descriptor->Initialize(arraysize(registers), registers, representations);
}
{
CallInterfaceDescriptor* descriptor =
Representation::Tagged(), // context
Representation::Tagged(), // receiver
};
- descriptor->Initialize(ARRAY_SIZE(registers), registers, representations);
+ descriptor->Initialize(arraysize(registers), registers, representations);
}
{
CallInterfaceDescriptor* descriptor =
Representation::Tagged(), // holder
Representation::External(), // api_function_address
};
- descriptor->Initialize(ARRAY_SIZE(registers), registers, representations);
+ descriptor->Initialize(arraysize(registers), registers, representations);
}
}
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]));
}
}
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>
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>
ReturnValueTraits<P2>::Representation(),
ReturnValueTraits<P3>::Representation(),
ReturnValueTraits<P4>::Representation()};
- VerifyParameters(ARRAY_SIZE(parameters), parameters);
+ VerifyParameters(arraysize(parameters), parameters);
}
#endif
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();
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();
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();
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();
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();
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();
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;
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 =
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());
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]);
}
}
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);
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);
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);
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) {
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) {
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());
}
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());
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);
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());
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());
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());
}
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());
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);
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);
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);
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());
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);
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);
}
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());
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());
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);
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);
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());
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);
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);
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);
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));
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));
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);
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));
}
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++) {
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));
}
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) {
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]));
}
}
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);
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);
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));
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);
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));
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);
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]);
}
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);
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]);
}
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;
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;
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(
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;
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(
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;
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;
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;
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]);
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);
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]);
}
}
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());
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};
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};
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};
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};
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));
}
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));
}
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));
}
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,
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());
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());
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);
}
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);
}
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);
}
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);
}
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);
}
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]};
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]};
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]};
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]};
"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);
"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);
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]);
}
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]);
}
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)));
}
}
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.
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)));
}
-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() {
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) {
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)]);
}
};
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]);
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
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) {
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());
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);
}
}
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]);
}
}
Execution::Call(isolate,
Handle<JSFunction>::cast(fun1),
global,
- ARRAY_SIZE(argv),
+ arraysize(argv),
argv).Check();
}
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);
}
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();
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();
}
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();
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();
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();
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 =
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 =
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 =
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");
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();
{
};
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();
{
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);
}
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);
// 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);
}
// 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);
"::(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[] = {
"::(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[] = {
"::(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);
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);
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());
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());
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);
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());
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 {
#define EXPECT_RECORDS(records, expectations) \
ExpectRecords(CcTest::isolate(), records, expectations, \
- ARRAY_SIZE(expectations))
+ arraysize(expectations))
TEST(APITestBasicMutation) {
v8::Isolate* v8_isolate = CcTest::isolate();
}
// 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);
"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);
termination_data[k],
context_data[i][1]);
CHECK(length == kProgramSize);
- TestParserSync(program.start(), flags1, ARRAY_SIZE(flags1));
+ TestParserSync(program.start(), flags1, arraysize(flags1));
}
}
}
// 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));
}
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);
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));
}
static const ParserFlag always_flags[] = {kAllowArrowFunctions};
RunParserSyncTest(context_data, statement_data, kError, NULL, 0, always_flags,
- ARRAY_SIZE(always_flags));
+ arraysize(always_flags));
}
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));
}
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));
}
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;
};
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));
}
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));
}
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));
}
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));
}
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 =
// 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); \