Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Unified Diff: src/runtime/runtime.cc

Issue 597943003: Move i18n-related runtime functions into a separate file. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: adapt check-name-clashes.py Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/runtime/runtime.h ('k') | src/runtime/runtime-i18n.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime/runtime.cc
diff --git a/src/runtime.cc b/src/runtime/runtime.cc
similarity index 85%
rename from src/runtime.cc
rename to src/runtime/runtime.cc
index 5209de4684be1bb697cdd989b2acf68035dfcf31..373d4b1227971f93a9e4cd34ea9b449456fe3527 100644
--- a/src/runtime.cc
+++ b/src/runtime/runtime.cc
@@ -36,7 +36,8 @@
#include "src/misc-intrinsics.h"
#include "src/parser.h"
#include "src/prototype.h"
-#include "src/runtime.h"
+#include "src/runtime/runtime.h"
+#include "src/runtime/runtime-utils.h"
#include "src/runtime-profiler.h"
#include "src/scopeinfo.h"
#include "src/smart-pointers.h"
@@ -47,30 +48,6 @@
#include "src/vm-state-inl.h"
#include "third_party/fdlibm/fdlibm.h"
-#ifdef V8_I18N_SUPPORT
-#include "src/i18n.h"
-#include "unicode/brkiter.h"
-#include "unicode/calendar.h"
-#include "unicode/coll.h"
-#include "unicode/curramt.h"
-#include "unicode/datefmt.h"
-#include "unicode/dcfmtsym.h"
-#include "unicode/decimfmt.h"
-#include "unicode/dtfmtsym.h"
-#include "unicode/dtptngen.h"
-#include "unicode/locid.h"
-#include "unicode/numfmt.h"
-#include "unicode/numsys.h"
-#include "unicode/rbbi.h"
-#include "unicode/smpdtfmt.h"
-#include "unicode/timezone.h"
-#include "unicode/uchar.h"
-#include "unicode/ucol.h"
-#include "unicode/ucurr.h"
-#include "unicode/uloc.h"
-#include "unicode/unum.h"
-#include "unicode/uversion.h"
-#endif
#ifndef _STLP_VENDOR_CSTD
// STLPort doesn't import fpclassify and isless into the std namespace.
@@ -81,89 +58,31 @@ using std::isless;
namespace v8 {
namespace internal {
+// Header of runtime functions.
+#define F(name, number_of_args, result_size) \
+ Object* Runtime_##name(int args_length, Object** args_object, \
+ Isolate* isolate);
+
+#define P(name, number_of_args, result_size) \
+ ObjectPair Runtime_##name(int args_length, Object** args_object, \
+ Isolate* isolate);
+
+#define I(name, number_of_args, result_size) \
+ Object* RuntimeReference_##name(int args_length, Object** args_object, \
+ Isolate* isolate);
+
+RUNTIME_FUNCTION_LIST_RETURN_OBJECT(F)
+RUNTIME_FUNCTION_LIST_RETURN_PAIR(P)
+INLINE_OPTIMIZED_FUNCTION_LIST(F)
+INLINE_FUNCTION_LIST(I)
-#define RUNTIME_ASSERT(value) \
- if (!(value)) return isolate->ThrowIllegalOperation();
-
-#define RUNTIME_ASSERT_HANDLIFIED(value, T) \
- if (!(value)) { \
- isolate->ThrowIllegalOperation(); \
- return MaybeHandle<T>(); \
- }
-
-// Cast the given object to a value of the specified type and store
-// it in a variable with the given name. If the object is not of the
-// expected type call IllegalOperation and return.
-#define CONVERT_ARG_CHECKED(Type, name, index) \
- RUNTIME_ASSERT(args[index]->Is##Type()); \
- Type* name = Type::cast(args[index]);
-
-#define CONVERT_ARG_HANDLE_CHECKED(Type, name, index) \
- RUNTIME_ASSERT(args[index]->Is##Type()); \
- Handle<Type> name = args.at<Type>(index);
-
-#define CONVERT_NUMBER_ARG_HANDLE_CHECKED(name, index) \
- RUNTIME_ASSERT(args[index]->IsNumber()); \
- Handle<Object> name = args.at<Object>(index);
-
-// Cast the given object to a boolean and store it in a variable with
-// the given name. If the object is not a boolean call IllegalOperation
-// and return.
-#define CONVERT_BOOLEAN_ARG_CHECKED(name, index) \
- RUNTIME_ASSERT(args[index]->IsBoolean()); \
- bool name = args[index]->IsTrue();
-
-// Cast the given argument to a Smi and store its value in an int variable
-// with the given name. If the argument is not a Smi call IllegalOperation
-// and return.
-#define CONVERT_SMI_ARG_CHECKED(name, index) \
- RUNTIME_ASSERT(args[index]->IsSmi()); \
- int name = args.smi_at(index);
-
-// Cast the given argument to a double and store it in a variable with
-// the given name. If the argument is not a number (as opposed to
-// the number not-a-number) call IllegalOperation and return.
-#define CONVERT_DOUBLE_ARG_CHECKED(name, index) \
- RUNTIME_ASSERT(args[index]->IsNumber()); \
- double name = args.number_at(index);
-
-// Call the specified converter on the object *comand store the result in
-// a variable of the specified type with the given name. If the
-// object is not a Number call IllegalOperation and return.
-#define CONVERT_NUMBER_CHECKED(type, name, Type, obj) \
- RUNTIME_ASSERT(obj->IsNumber()); \
- type name = NumberTo##Type(obj);
-
-
-// Cast the given argument to PropertyDetails and store its value in a
-// variable with the given name. If the argument is not a Smi call
-// IllegalOperation and return.
-#define CONVERT_PROPERTY_DETAILS_CHECKED(name, index) \
- RUNTIME_ASSERT(args[index]->IsSmi()); \
- PropertyDetails name = PropertyDetails(Smi::cast(args[index]));
-
-
-// Assert that the given argument has a valid value for a StrictMode
-// and store it in a StrictMode variable with the given name.
-#define CONVERT_STRICT_MODE_ARG_CHECKED(name, index) \
- RUNTIME_ASSERT(args[index]->IsSmi()); \
- RUNTIME_ASSERT(args.smi_at(index) == STRICT || \
- args.smi_at(index) == SLOPPY); \
- StrictMode name = static_cast<StrictMode>(args.smi_at(index));
-
-
-// Assert that the given argument is a number within the Int32 range
-// and convert it to int32_t. If the argument is not an Int32 call
-// IllegalOperation and return.
-#define CONVERT_INT32_ARG_CHECKED(name, index) \
- RUNTIME_ASSERT(args[index]->IsNumber()); \
- int32_t name = 0; \
- RUNTIME_ASSERT(args[index]->ToInt32(&name));
+#undef I
+#undef F
+#undef P
static Handle<Map> ComputeObjectLiteralMap(
- Handle<Context> context,
- Handle<FixedArray> constant_properties,
+ Handle<Context> context, Handle<FixedArray> constant_properties,
bool* is_result_from_cache) {
Isolate* isolate = context->GetIsolate();
int properties_length = constant_properties->length();
@@ -213,16 +132,13 @@ static Handle<Map> ComputeObjectLiteralMap(
MUST_USE_RESULT static MaybeHandle<Object> CreateLiteralBoilerplate(
- Isolate* isolate,
- Handle<FixedArray> literals,
+ Isolate* isolate, Handle<FixedArray> literals,
Handle<FixedArray> constant_properties);
MUST_USE_RESULT static MaybeHandle<Object> CreateObjectLiteralBoilerplate(
- Isolate* isolate,
- Handle<FixedArray> literals,
- Handle<FixedArray> constant_properties,
- bool should_have_fast_elements,
+ Isolate* isolate, Handle<FixedArray> literals,
+ Handle<FixedArray> constant_properties, bool should_have_fast_elements,
bool has_function_literal) {
// Get the native context from the literals array. This is the
// context in which the function was created and we use the object
@@ -239,10 +155,9 @@ MUST_USE_RESULT static MaybeHandle<Object> CreateObjectLiteralBoilerplate(
// not the same (which is the common case).
bool is_result_from_cache = false;
Handle<Map> map = has_function_literal
- ? Handle<Map>(context->object_function()->initial_map())
- : ComputeObjectLiteralMap(context,
- constant_properties,
- &is_result_from_cache);
+ ? Handle<Map>(context->object_function()->initial_map())
+ : ComputeObjectLiteralMap(context, constant_properties,
+ &is_result_from_cache);
PretenureFlag pretenure_flag =
isolate->heap()->InNewSpace(*literals) ? NOT_TENURED : TENURED;
@@ -260,20 +175,19 @@ MUST_USE_RESULT static MaybeHandle<Object> CreateObjectLiteralBoilerplate(
bool should_normalize = should_transform || has_function_literal;
if (should_normalize) {
// TODO(verwaest): We might not want to ever normalize here.
- JSObject::NormalizeProperties(
- boilerplate, KEEP_INOBJECT_PROPERTIES, length / 2);
+ JSObject::NormalizeProperties(boilerplate, KEEP_INOBJECT_PROPERTIES,
+ length / 2);
}
// TODO(verwaest): Support tracking representations in the boilerplate.
- for (int index = 0; index < length; index +=2) {
- Handle<Object> key(constant_properties->get(index+0), isolate);
- Handle<Object> value(constant_properties->get(index+1), isolate);
+ for (int index = 0; index < length; index += 2) {
+ Handle<Object> key(constant_properties->get(index + 0), isolate);
+ Handle<Object> value(constant_properties->get(index + 1), isolate);
if (value->IsFixedArray()) {
// The value contains the constant_properties of a
// simple object or array literal.
Handle<FixedArray> array = Handle<FixedArray>::cast(value);
ASSIGN_RETURN_ON_EXCEPTION(
- isolate, value,
- CreateLiteralBoilerplate(isolate, literals, array),
+ isolate, value, CreateLiteralBoilerplate(isolate, literals, array),
Object);
}
MaybeHandle<Object> maybe_result;
@@ -318,8 +232,8 @@ MUST_USE_RESULT static MaybeHandle<Object> CreateObjectLiteralBoilerplate(
// computed properties have been assigned so that we can generate
// constant function properties.
if (should_transform && !has_function_literal) {
- JSObject::MigrateSlowToFast(
- boilerplate, boilerplate->map()->unused_property_fields());
+ JSObject::MigrateSlowToFast(boilerplate,
+ boilerplate->map()->unused_property_fields());
}
return boilerplate;
@@ -327,9 +241,7 @@ MUST_USE_RESULT static MaybeHandle<Object> CreateObjectLiteralBoilerplate(
MUST_USE_RESULT static MaybeHandle<Object> TransitionElements(
- Handle<Object> object,
- ElementsKind to_kind,
- Isolate* isolate) {
+ Handle<Object> object, ElementsKind to_kind, Isolate* isolate) {
HandleScope scope(isolate);
if (!object->IsJSObject()) {
isolate->ThrowIllegalOperation();
@@ -347,8 +259,7 @@ MUST_USE_RESULT static MaybeHandle<Object> TransitionElements(
MaybeHandle<Object> Runtime::CreateArrayLiteralBoilerplate(
- Isolate* isolate,
- Handle<FixedArray> literals,
+ Isolate* isolate, Handle<FixedArray> literals,
Handle<FixedArray> elements) {
// Create the JSArray.
Handle<JSFunction> constructor(
@@ -365,7 +276,8 @@ MaybeHandle<Object> Runtime::CreateArrayLiteralBoilerplate(
Handle<FixedArrayBase> constant_elements_values(
FixedArrayBase::cast(elements->get(1)));
- { DisallowHeapAllocation no_gc;
+ {
+ DisallowHeapAllocation no_gc;
DCHECK(IsFastElementsKind(constant_elements_kind));
Context* native_context = isolate->context()->native_context();
Object* maps_array = native_context->js_array_maps();
@@ -380,9 +292,8 @@ MaybeHandle<Object> Runtime::CreateArrayLiteralBoilerplate(
Handle<FixedDoubleArray>::cast(constant_elements_values));
} else {
DCHECK(IsFastSmiOrObjectElementsKind(constant_elements_kind));
- const bool is_cow =
- (constant_elements_values->map() ==
- isolate->heap()->fixed_cow_array_map());
+ const bool is_cow = (constant_elements_values->map() ==
+ isolate->heap()->fixed_cow_array_map());
if (is_cow) {
copied_elements_values = constant_elements_values;
#if DEBUG
@@ -405,8 +316,7 @@ MaybeHandle<Object> Runtime::CreateArrayLiteralBoilerplate(
Handle<FixedArray> fa(FixedArray::cast(fixed_array_values->get(i)));
Handle<Object> result;
ASSIGN_RETURN_ON_EXCEPTION(
- isolate, result,
- CreateLiteralBoilerplate(isolate, literals, fa),
+ isolate, result, CreateLiteralBoilerplate(isolate, literals, fa),
Object);
fixed_array_values_copy->set(i, *result);
}
@@ -422,27 +332,19 @@ MaybeHandle<Object> Runtime::CreateArrayLiteralBoilerplate(
MUST_USE_RESULT static MaybeHandle<Object> CreateLiteralBoilerplate(
- Isolate* isolate,
- Handle<FixedArray> literals,
- Handle<FixedArray> array) {
+ Isolate* isolate, Handle<FixedArray> literals, Handle<FixedArray> array) {
Handle<FixedArray> elements = CompileTimeValue::GetElements(array);
const bool kHasNoFunctionLiteral = false;
switch (CompileTimeValue::GetLiteralType(array)) {
case CompileTimeValue::OBJECT_LITERAL_FAST_ELEMENTS:
- return CreateObjectLiteralBoilerplate(isolate,
- literals,
- elements,
- true,
+ return CreateObjectLiteralBoilerplate(isolate, literals, elements, true,
kHasNoFunctionLiteral);
case CompileTimeValue::OBJECT_LITERAL_SLOW_ELEMENTS:
- return CreateObjectLiteralBoilerplate(isolate,
- literals,
- elements,
- false,
+ return CreateObjectLiteralBoilerplate(isolate, literals, elements, false,
kHasNoFunctionLiteral);
case CompileTimeValue::ARRAY_LITERAL:
- return Runtime::CreateArrayLiteralBoilerplate(
- isolate, literals, elements);
+ return Runtime::CreateArrayLiteralBoilerplate(isolate, literals,
+ elements);
default:
UNREACHABLE();
return MaybeHandle<Object>();
@@ -470,33 +372,29 @@ RUNTIME_FUNCTION(Runtime_CreateObjectLiteral) {
Handle<Object> raw_boilerplate;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, raw_boilerplate,
- CreateObjectLiteralBoilerplate(
- isolate,
- literals,
- constant_properties,
- should_have_fast_elements,
- has_function_literal));
+ CreateObjectLiteralBoilerplate(isolate, literals, constant_properties,
+ should_have_fast_elements,
+ has_function_literal));
boilerplate = Handle<JSObject>::cast(raw_boilerplate);
AllocationSiteCreationContext creation_context(isolate);
site = creation_context.EnterNewScope();
RETURN_FAILURE_ON_EXCEPTION(
- isolate,
- JSObject::DeepWalk(boilerplate, &creation_context));
+ isolate, JSObject::DeepWalk(boilerplate, &creation_context));
creation_context.ExitScope(site, boilerplate);
// Update the functions literal and return the boilerplate.
literals->set(literals_index, *site);
} else {
site = Handle<AllocationSite>::cast(literal_site);
- boilerplate = Handle<JSObject>(JSObject::cast(site->transition_info()),
- isolate);
+ boilerplate =
+ Handle<JSObject>(JSObject::cast(site->transition_info()), isolate);
}
AllocationSiteUsageContext usage_context(isolate, site, true);
usage_context.EnterNewScope();
- MaybeHandle<Object> maybe_copy = JSObject::DeepCopy(
- boilerplate, &usage_context);
+ MaybeHandle<Object> maybe_copy =
+ JSObject::DeepCopy(boilerplate, &usage_context);
usage_context.ExitScope(site, boilerplate);
Handle<Object> copy;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, copy, maybe_copy);
@@ -505,9 +403,7 @@ RUNTIME_FUNCTION(Runtime_CreateObjectLiteral) {
MUST_USE_RESULT static MaybeHandle<AllocationSite> GetLiteralAllocationSite(
- Isolate* isolate,
- Handle<FixedArray> literals,
- int literals_index,
+ Isolate* isolate, Handle<FixedArray> literals, int literals_index,
Handle<FixedArray> elements) {
// Check if boilerplate exists. If not, create it first.
Handle<Object> literal_site(literals->get(literals_index), isolate);
@@ -538,12 +434,12 @@ MUST_USE_RESULT static MaybeHandle<AllocationSite> GetLiteralAllocationSite(
static MaybeHandle<JSObject> CreateArrayLiteralImpl(Isolate* isolate,
- Handle<FixedArray> literals,
- int literals_index,
- Handle<FixedArray> elements,
- int flags) {
- RUNTIME_ASSERT_HANDLIFIED(literals_index >= 0 &&
- literals_index < literals->length(), JSObject);
+ Handle<FixedArray> literals,
+ int literals_index,
+ Handle<FixedArray> elements,
+ int flags) {
+ RUNTIME_ASSERT_HANDLIFIED(
+ literals_index >= 0 && literals_index < literals->length(), JSObject);
Handle<AllocationSite> site;
ASSIGN_RETURN_ON_EXCEPTION(
isolate, site,
@@ -557,8 +453,8 @@ static MaybeHandle<JSObject> CreateArrayLiteralImpl(Isolate* isolate,
JSObject::DeepCopyHints hints = (flags & ArrayLiteral::kShallowElements) == 0
? JSObject::kNoHints
: JSObject::kObjectIsShallow;
- MaybeHandle<JSObject> copy = JSObject::DeepCopy(boilerplate, &usage_context,
- hints);
+ MaybeHandle<JSObject> copy =
+ JSObject::DeepCopy(boilerplate, &usage_context, hints);
usage_context.ExitScope(site, boilerplate);
return copy;
}
@@ -573,9 +469,9 @@ RUNTIME_FUNCTION(Runtime_CreateArrayLiteral) {
CONVERT_SMI_ARG_CHECKED(flags, 3);
Handle<JSObject> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result,
- CreateArrayLiteralImpl(isolate, literals, literals_index, elements,
- flags));
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
+ isolate, result, CreateArrayLiteralImpl(isolate, literals, literals_index,
+ elements, flags));
return *result;
}
@@ -588,9 +484,10 @@ RUNTIME_FUNCTION(Runtime_CreateArrayLiteralStubBailout) {
CONVERT_ARG_HANDLE_CHECKED(FixedArray, elements, 2);
Handle<JSObject> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result,
- CreateArrayLiteralImpl(isolate, literals, literals_index, elements,
- ArrayLiteral::kShallowElements));
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
+ isolate, result,
+ CreateArrayLiteralImpl(isolate, literals, literals_index, elements,
+ ArrayLiteral::kShallowElements));
return *result;
}
@@ -702,8 +599,8 @@ RUNTIME_FUNCTION(Runtime_CreateJSFunctionProxy) {
CONVERT_ARG_HANDLE_CHECKED(JSFunction, construct_trap, 2);
CONVERT_ARG_HANDLE_CHECKED(Object, prototype, 3);
if (!prototype->IsJSReceiver()) prototype = isolate->factory()->null_value();
- return *isolate->factory()->NewJSFunctionProxy(
- handler, call_trap, construct_trap, prototype);
+ return *isolate->factory()->NewJSFunctionProxy(handler, call_trap,
+ construct_trap, prototype);
}
@@ -764,26 +661,24 @@ void Runtime::FreeArrayBuffer(Isolate* isolate,
}
if (phantom_array_buffer->is_external()) return;
- size_t allocated_length = NumberToSize(
- isolate, phantom_array_buffer->byte_length());
+ size_t allocated_length =
+ NumberToSize(isolate, phantom_array_buffer->byte_length());
reinterpret_cast<v8::Isolate*>(isolate)
->AdjustAmountOfExternalAllocatedMemory(
-static_cast<int64_t>(allocated_length));
CHECK(V8::ArrayBufferAllocator() != NULL);
- V8::ArrayBufferAllocator()->Free(
- phantom_array_buffer->backing_store(),
- allocated_length);
+ V8::ArrayBufferAllocator()->Free(phantom_array_buffer->backing_store(),
+ allocated_length);
}
void Runtime::SetupArrayBuffer(Isolate* isolate,
Handle<JSArrayBuffer> array_buffer,
- bool is_external,
- void* data,
+ bool is_external, void* data,
size_t allocated_length) {
DCHECK(array_buffer->GetInternalFieldCount() ==
- v8::ArrayBuffer::kInternalFieldCount);
+ v8::ArrayBuffer::kInternalFieldCount);
for (int i = 0; i < v8::ArrayBuffer::kInternalFieldCount; i++) {
array_buffer->SetInternalField(i, Smi::FromInt(0));
}
@@ -802,11 +697,10 @@ void Runtime::SetupArrayBuffer(Isolate* isolate,
}
-bool Runtime::SetupArrayBufferAllocatingData(
- Isolate* isolate,
- Handle<JSArrayBuffer> array_buffer,
- size_t allocated_length,
- bool initialize) {
+bool Runtime::SetupArrayBufferAllocatingData(Isolate* isolate,
+ Handle<JSArrayBuffer> array_buffer,
+ size_t allocated_length,
+ bool initialize) {
void* data;
CHECK(V8::ArrayBufferAllocator() != NULL);
if (allocated_length != 0) {
@@ -863,8 +757,8 @@ RUNTIME_FUNCTION(Runtime_ArrayBufferInitialize) {
isolate, NewRangeError("invalid_array_buffer_length",
HandleVector<Object>(NULL, 0)));
}
- if (!Runtime::SetupArrayBufferAllocatingData(isolate,
- holder, allocated_length)) {
+ if (!Runtime::SetupArrayBufferAllocatingData(isolate, holder,
+ allocated_length)) {
THROW_NEW_ERROR_RETURN_FAILURE(
isolate, NewRangeError("invalid_array_buffer_length",
HandleVector<Object>(NULL, 0)));
@@ -930,20 +824,18 @@ RUNTIME_FUNCTION(Runtime_ArrayBufferNeuter) {
}
-void Runtime::ArrayIdToTypeAndSize(
- int arrayId,
- ExternalArrayType* array_type,
- ElementsKind* external_elements_kind,
- ElementsKind* fixed_elements_kind,
- size_t* element_size) {
+void Runtime::ArrayIdToTypeAndSize(int arrayId, ExternalArrayType* array_type,
+ ElementsKind* external_elements_kind,
+ ElementsKind* fixed_elements_kind,
+ size_t* element_size) {
switch (arrayId) {
-#define ARRAY_ID_CASE(Type, type, TYPE, ctype, size) \
- case ARRAY_ID_##TYPE: \
- *array_type = kExternal##Type##Array; \
- *external_elements_kind = EXTERNAL_##TYPE##_ELEMENTS; \
- *fixed_elements_kind = TYPE##_ELEMENTS; \
- *element_size = size; \
- break;
+#define ARRAY_ID_CASE(Type, type, TYPE, ctype, size) \
+ case ARRAY_ID_##TYPE: \
+ *array_type = kExternal##Type##Array; \
+ *external_elements_kind = EXTERNAL_##TYPE##_ELEMENTS; \
+ *fixed_elements_kind = TYPE##_ELEMENTS; \
+ *element_size = size; \
+ break;
TYPED_ARRAYS(ARRAY_ID_CASE)
#undef ARRAY_ID_CASE
@@ -967,15 +859,12 @@ RUNTIME_FUNCTION(Runtime_TypedArrayInitialize) {
arrayId <= Runtime::ARRAY_ID_LAST);
ExternalArrayType array_type = kExternalInt8Array; // Bogus initialization.
- size_t element_size = 1; // Bogus initialization.
+ size_t element_size = 1; // Bogus initialization.
ElementsKind external_elements_kind =
- EXTERNAL_INT8_ELEMENTS; // Bogus initialization.
+ EXTERNAL_INT8_ELEMENTS; // Bogus initialization.
ElementsKind fixed_elements_kind = INT8_ELEMENTS; // Bogus initialization.
- Runtime::ArrayIdToTypeAndSize(arrayId,
- &array_type,
- &external_elements_kind,
- &fixed_elements_kind,
- &element_size);
+ Runtime::ArrayIdToTypeAndSize(arrayId, &array_type, &external_elements_kind,
+ &fixed_elements_kind, &element_size);
RUNTIME_ASSERT(holder->map()->elements_kind() == fixed_elements_kind);
size_t byte_offset = 0;
@@ -1005,7 +894,7 @@ RUNTIME_FUNCTION(Runtime_TypedArrayInitialize) {
// All checks are done, now we can modify objects.
DCHECK(holder->GetInternalFieldCount() ==
- v8::ArrayBufferView::kInternalFieldCount);
+ v8::ArrayBufferView::kInternalFieldCount);
for (int i = 0; i < v8::ArrayBufferView::kInternalFieldCount; i++) {
holder->SetInternalField(i, Smi::FromInt(0));
}
@@ -1020,10 +909,9 @@ RUNTIME_FUNCTION(Runtime_TypedArrayInitialize) {
holder->set_weak_next(buffer->weak_first_view());
buffer->set_weak_first_view(*holder);
- Handle<ExternalArray> elements =
- isolate->factory()->NewExternalArray(
- static_cast<int>(length), array_type,
- static_cast<uint8_t*>(buffer->backing_store()) + byte_offset);
+ Handle<ExternalArray> elements = isolate->factory()->NewExternalArray(
+ static_cast<int>(length), array_type,
+ static_cast<uint8_t*>(buffer->backing_store()) + byte_offset);
Handle<Map> map =
JSObject::GetElementsTransitionMap(holder, external_elements_kind);
JSObject::SetMapAndElements(holder, map, elements);
@@ -1032,8 +920,8 @@ RUNTIME_FUNCTION(Runtime_TypedArrayInitialize) {
holder->set_buffer(Smi::FromInt(0));
holder->set_weak_next(isolate->heap()->undefined_value());
Handle<FixedTypedArrayBase> elements =
- isolate->factory()->NewFixedTypedArray(
- static_cast<int>(length), array_type);
+ isolate->factory()->NewFixedTypedArray(static_cast<int>(length),
+ array_type);
holder->set_elements(*elements);
}
return isolate->heap()->undefined_value();
@@ -1057,15 +945,12 @@ RUNTIME_FUNCTION(Runtime_TypedArrayInitializeFromArrayLike) {
arrayId <= Runtime::ARRAY_ID_LAST);
ExternalArrayType array_type = kExternalInt8Array; // Bogus initialization.
- size_t element_size = 1; // Bogus initialization.
+ size_t element_size = 1; // Bogus initialization.
ElementsKind external_elements_kind =
- EXTERNAL_INT8_ELEMENTS; // Bogus intialization.
+ EXTERNAL_INT8_ELEMENTS; // Bogus intialization.
ElementsKind fixed_elements_kind = INT8_ELEMENTS; // Bogus initialization.
- Runtime::ArrayIdToTypeAndSize(arrayId,
- &array_type,
- &external_elements_kind,
- &fixed_elements_kind,
- &element_size);
+ Runtime::ArrayIdToTypeAndSize(arrayId, &array_type, &external_elements_kind,
+ &fixed_elements_kind, &element_size);
RUNTIME_ASSERT(holder->map()->elements_kind() == fixed_elements_kind);
@@ -1086,7 +971,7 @@ RUNTIME_FUNCTION(Runtime_TypedArrayInitializeFromArrayLike) {
size_t byte_length = length * element_size;
DCHECK(holder->GetInternalFieldCount() ==
- v8::ArrayBufferView::kInternalFieldCount);
+ v8::ArrayBufferView::kInternalFieldCount);
for (int i = 0; i < v8::ArrayBufferView::kInternalFieldCount; i++) {
holder->SetInternalField(i, Smi::FromInt(0));
}
@@ -1107,8 +992,8 @@ RUNTIME_FUNCTION(Runtime_TypedArrayInitializeFromArrayLike) {
//
// TODO(dslomov): revise this once we support subclassing.
- if (!Runtime::SetupArrayBufferAllocatingData(
- isolate, buffer, byte_length, false)) {
+ if (!Runtime::SetupArrayBufferAllocatingData(isolate, buffer, byte_length,
+ false)) {
THROW_NEW_ERROR_RETURN_FAILURE(
isolate, NewRangeError("invalid_array_buffer_length",
HandleVector<Object>(NULL, 0)));
@@ -1123,12 +1008,11 @@ RUNTIME_FUNCTION(Runtime_TypedArrayInitializeFromArrayLike) {
holder->set_weak_next(buffer->weak_first_view());
buffer->set_weak_first_view(*holder);
- Handle<ExternalArray> elements =
- isolate->factory()->NewExternalArray(
- static_cast<int>(length), array_type,
- static_cast<uint8_t*>(buffer->backing_store()));
- Handle<Map> map = JSObject::GetElementsTransitionMap(
- holder, external_elements_kind);
+ Handle<ExternalArray> elements = isolate->factory()->NewExternalArray(
+ static_cast<int>(length), array_type,
+ static_cast<uint8_t*>(buffer->backing_store()));
+ Handle<Map> map =
+ JSObject::GetElementsTransitionMap(holder, external_elements_kind);
JSObject::SetMapAndElements(holder, map, elements);
if (source->IsJSTypedArray()) {
@@ -1136,14 +1020,11 @@ RUNTIME_FUNCTION(Runtime_TypedArrayInitializeFromArrayLike) {
if (typed_array->type() == holder->type()) {
uint8_t* backing_store =
- static_cast<uint8_t*>(
- typed_array->GetBuffer()->backing_store());
+ static_cast<uint8_t*>(typed_array->GetBuffer()->backing_store());
size_t source_byte_offset =
NumberToSize(isolate, typed_array->byte_offset());
- memcpy(
- buffer->backing_store(),
- backing_store + source_byte_offset,
- byte_length);
+ memcpy(buffer->backing_store(), backing_store + source_byte_offset,
+ byte_length);
return isolate->heap()->true_value();
}
}
@@ -1152,12 +1033,12 @@ RUNTIME_FUNCTION(Runtime_TypedArrayInitializeFromArrayLike) {
}
-#define BUFFER_VIEW_GETTER(Type, getter, accessor) \
- RUNTIME_FUNCTION(Runtime_##Type##Get##getter) { \
- HandleScope scope(isolate); \
- DCHECK(args.length() == 1); \
- CONVERT_ARG_HANDLE_CHECKED(JS##Type, holder, 0); \
- return holder->accessor(); \
+#define BUFFER_VIEW_GETTER(Type, getter, accessor) \
+ RUNTIME_FUNCTION(Runtime_##Type##Get##getter) { \
+ HandleScope scope(isolate); \
+ DCHECK(args.length() == 1); \
+ CONVERT_ARG_HANDLE_CHECKED(JS##Type, holder, 0); \
+ return holder->accessor(); \
}
BUFFER_VIEW_GETTER(ArrayBufferView, ByteLength, byte_length)
@@ -1224,28 +1105,27 @@ RUNTIME_FUNCTION(Runtime_TypedArraySetFastCases) {
size_t target_offset = NumberToSize(isolate, target->byte_offset());
size_t source_offset = NumberToSize(isolate, source->byte_offset());
uint8_t* target_base =
- static_cast<uint8_t*>(
- target->GetBuffer()->backing_store()) + target_offset;
+ static_cast<uint8_t*>(target->GetBuffer()->backing_store()) +
+ target_offset;
uint8_t* source_base =
- static_cast<uint8_t*>(
- source->GetBuffer()->backing_store()) + source_offset;
+ static_cast<uint8_t*>(source->GetBuffer()->backing_store()) +
+ source_offset;
// Typed arrays of the same type: use memmove.
if (target->type() == source->type()) {
- memmove(target_base + offset * target->element_size(),
- source_base, source_byte_length);
+ memmove(target_base + offset * target->element_size(), source_base,
+ source_byte_length);
return Smi::FromInt(TYPED_ARRAY_SET_TYPED_ARRAY_SAME_TYPE);
}
// Typed arrays of different types over the same backing store
if ((source_base <= target_base &&
- source_base + source_byte_length > target_base) ||
+ source_base + source_byte_length > target_base) ||
(target_base <= source_base &&
- target_base + target_byte_length > source_base)) {
+ target_base + target_byte_length > source_base)) {
// We do not support overlapping ArrayBuffers
- DCHECK(
- target->GetBuffer()->backing_store() ==
- source->GetBuffer()->backing_store());
+ DCHECK(target->GetBuffer()->backing_store() ==
+ source->GetBuffer()->backing_store());
return Smi::FromInt(TYPED_ARRAY_SET_TYPED_ARRAY_OVERLAPPING);
} else { // Non-overlapping typed arrays
return Smi::FromInt(TYPED_ARRAY_SET_TYPED_ARRAY_NONOVERLAPPING);
@@ -1255,8 +1135,8 @@ RUNTIME_FUNCTION(Runtime_TypedArraySetFastCases) {
RUNTIME_FUNCTION(Runtime_TypedArrayMaxSizeInHeap) {
DCHECK(args.length() == 0);
- DCHECK_OBJECT_SIZE(
- FLAG_typed_array_max_size_in_heap + FixedTypedArrayBase::kDataOffset);
+ DCHECK_OBJECT_SIZE(FLAG_typed_array_max_size_in_heap +
+ FixedTypedArrayBase::kDataOffset);
return Smi::FromInt(FLAG_typed_array_max_size_in_heap);
}
@@ -1270,7 +1150,7 @@ RUNTIME_FUNCTION(Runtime_DataViewInitialize) {
CONVERT_NUMBER_ARG_HANDLE_CHECKED(byte_length, 3);
DCHECK(holder->GetInternalFieldCount() ==
- v8::ArrayBufferView::kInternalFieldCount);
+ v8::ArrayBufferView::kInternalFieldCount);
for (int i = 0; i < v8::ArrayBufferView::kInternalFieldCount; i++) {
holder->SetInternalField(i, Smi::FromInt(0));
}
@@ -1309,7 +1189,7 @@ inline static bool NeedToFlipBytes(bool is_little_endian) {
}
-template<int n>
+template <int n>
inline void CopyBytes(uint8_t* target, uint8_t* source) {
for (int i = 0; i < n; i++) {
*(target++) = *(source++);
@@ -1317,22 +1197,20 @@ inline void CopyBytes(uint8_t* target, uint8_t* source) {
}
-template<int n>
+template <int n>
inline void FlipBytes(uint8_t* target, uint8_t* source) {
- source = source + (n-1);
+ source = source + (n - 1);
for (int i = 0; i < n; i++) {
*(target++) = *(source--);
}
}
-template<typename T>
-inline static bool DataViewGetValue(
- Isolate* isolate,
- Handle<JSDataView> data_view,
- Handle<Object> byte_offset_obj,
- bool is_little_endian,
- T* result) {
+template <typename T>
+inline static bool DataViewGetValue(Isolate* isolate,
+ Handle<JSDataView> data_view,
+ Handle<Object> byte_offset_obj,
+ bool is_little_endian, T* result) {
size_t byte_offset = 0;
if (!TryNumberToSize(isolate, *byte_offset_obj, &byte_offset)) {
return false;
@@ -1344,7 +1222,7 @@ inline static bool DataViewGetValue(
size_t data_view_byte_length =
NumberToSize(isolate, data_view->byte_length());
if (byte_offset + sizeof(T) > data_view_byte_length ||
- byte_offset + sizeof(T) < byte_offset) { // overflow
+ byte_offset + sizeof(T) < byte_offset) { // overflow
return false;
}
@@ -1355,11 +1233,10 @@ inline static bool DataViewGetValue(
Value value;
size_t buffer_offset = data_view_byte_offset + byte_offset;
- DCHECK(
- NumberToSize(isolate, buffer->byte_length())
- >= buffer_offset + sizeof(T));
+ DCHECK(NumberToSize(isolate, buffer->byte_length()) >=
+ buffer_offset + sizeof(T));
uint8_t* source =
- static_cast<uint8_t*>(buffer->backing_store()) + buffer_offset;
+ static_cast<uint8_t*>(buffer->backing_store()) + buffer_offset;
if (NeedToFlipBytes(is_little_endian)) {
FlipBytes<sizeof(T)>(value.bytes, source);
} else {
@@ -1370,13 +1247,10 @@ inline static bool DataViewGetValue(
}
-template<typename T>
-static bool DataViewSetValue(
- Isolate* isolate,
- Handle<JSDataView> data_view,
- Handle<Object> byte_offset_obj,
- bool is_little_endian,
- T data) {
+template <typename T>
+static bool DataViewSetValue(Isolate* isolate, Handle<JSDataView> data_view,
+ Handle<Object> byte_offset_obj,
+ bool is_little_endian, T data) {
size_t byte_offset = 0;
if (!TryNumberToSize(isolate, *byte_offset_obj, &byte_offset)) {
return false;
@@ -1388,7 +1262,7 @@ static bool DataViewSetValue(
size_t data_view_byte_length =
NumberToSize(isolate, data_view->byte_length());
if (byte_offset + sizeof(T) > data_view_byte_length ||
- byte_offset + sizeof(T) < byte_offset) { // overflow
+ byte_offset + sizeof(T) < byte_offset) { // overflow
return false;
}
@@ -1400,11 +1274,10 @@ static bool DataViewSetValue(
Value value;
value.data = data;
size_t buffer_offset = data_view_byte_offset + byte_offset;
- DCHECK(
- NumberToSize(isolate, buffer->byte_length())
- >= buffer_offset + sizeof(T));
+ DCHECK(NumberToSize(isolate, buffer->byte_length()) >=
+ buffer_offset + sizeof(T));
uint8_t* target =
- static_cast<uint8_t*>(buffer->backing_store()) + buffer_offset;
+ static_cast<uint8_t*>(buffer->backing_store()) + buffer_offset;
if (NeedToFlipBytes(is_little_endian)) {
FlipBytes<sizeof(T)>(target, value.bytes);
} else {
@@ -1701,9 +1574,9 @@ RUNTIME_FUNCTION(Runtime_MapIteratorInitialize) {
CONVERT_ARG_HANDLE_CHECKED(JSMapIterator, holder, 0);
CONVERT_ARG_HANDLE_CHECKED(JSMap, map, 1);
CONVERT_SMI_ARG_CHECKED(kind, 2)
- RUNTIME_ASSERT(kind == JSMapIterator::kKindKeys
- || kind == JSMapIterator::kKindValues
- || kind == JSMapIterator::kKindEntries);
+ RUNTIME_ASSERT(kind == JSMapIterator::kKindKeys ||
+ kind == JSMapIterator::kKindValues ||
+ kind == JSMapIterator::kKindEntries);
Handle<OrderedHashMap> table(OrderedHashMap::cast(map->table()));
holder->set_table(*table);
holder->set_index(Smi::FromInt(0));
@@ -1746,8 +1619,7 @@ RUNTIME_FUNCTION(Runtime_MapIteratorNext) {
static Handle<JSWeakCollection> WeakCollectionInitialize(
- Isolate* isolate,
- Handle<JSWeakCollection> weak_collection) {
+ Isolate* isolate, Handle<JSWeakCollection> weak_collection) {
DCHECK(weak_collection->map()->inobject_properties() == 0);
Handle<ObjectHashTable> table = ObjectHashTable::New(isolate, 0);
weak_collection->set_table(*table);
@@ -1797,8 +1669,8 @@ RUNTIME_FUNCTION(Runtime_WeakCollectionDelete) {
CONVERT_ARG_HANDLE_CHECKED(JSWeakCollection, weak_collection, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, key, 1);
RUNTIME_ASSERT(key->IsJSReceiver() || key->IsSymbol());
- Handle<ObjectHashTable> table(ObjectHashTable::cast(
- weak_collection->table()));
+ Handle<ObjectHashTable> table(
+ ObjectHashTable::cast(weak_collection->table()));
RUNTIME_ASSERT(table->IsKey(*key));
bool was_present = false;
Handle<ObjectHashTable> new_table =
@@ -1906,8 +1778,8 @@ RUNTIME_FUNCTION(Runtime_SetPrototype) {
CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, prototype, 1);
if (obj->IsAccessCheckNeeded() &&
- !isolate->MayNamedAccess(
- obj, isolate->factory()->proto_string(), v8::ACCESS_SET)) {
+ !isolate->MayNamedAccess(obj, isolate->factory()->proto_string(),
+ v8::ACCESS_SET)) {
isolate->ReportFailedAccessCheck(obj, v8::ACCESS_SET);
RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate);
return isolate->heap()->undefined_value();
@@ -1916,21 +1788,18 @@ RUNTIME_FUNCTION(Runtime_SetPrototype) {
Handle<Object> old_value = GetPrototypeSkipHiddenPrototypes(isolate, obj);
Handle<Object> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result,
- JSObject::SetPrototype(obj, prototype, true));
+ isolate, result, JSObject::SetPrototype(obj, prototype, true));
Handle<Object> new_value = GetPrototypeSkipHiddenPrototypes(isolate, obj);
if (!new_value->SameValue(*old_value)) {
- JSObject::EnqueueChangeRecord(obj, "setPrototype",
- isolate->factory()->proto_string(),
- old_value);
+ JSObject::EnqueueChangeRecord(
+ obj, "setPrototype", isolate->factory()->proto_string(), old_value);
}
return *result;
}
Handle<Object> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result,
- JSObject::SetPrototype(obj, prototype, true));
+ isolate, result, JSObject::SetPrototype(obj, prototype, true));
return *result;
}
@@ -1988,8 +1857,9 @@ MUST_USE_RESULT static MaybeHandle<Object> GetOwnProperty(Isolate* isolate,
// Get value if not an AccessorPair.
if (maybe_accessors.is_null()) {
- ASSIGN_RETURN_ON_EXCEPTION(isolate, value,
- Runtime::GetElementOrCharAt(isolate, obj, index), Object);
+ ASSIGN_RETURN_ON_EXCEPTION(
+ isolate, value, Runtime::GetElementOrCharAt(isolate, obj, index),
+ Object);
}
} else {
// Get attributes.
@@ -2007,8 +1877,8 @@ MUST_USE_RESULT static MaybeHandle<Object> GetOwnProperty(Isolate* isolate,
// Get value if not an AccessorPair.
if (maybe_accessors.is_null()) {
- ASSIGN_RETURN_ON_EXCEPTION(
- isolate, value, Object::GetProperty(&it), Object);
+ ASSIGN_RETURN_ON_EXCEPTION(isolate, value, Object::GetProperty(&it),
+ Object);
}
}
DCHECK(!isolate->has_pending_exception());
@@ -2045,8 +1915,8 @@ RUNTIME_FUNCTION(Runtime_GetOwnProperty) {
CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0);
CONVERT_ARG_HANDLE_CHECKED(Name, name, 1);
Handle<Object> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result, GetOwnProperty(isolate, obj, name));
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result,
+ GetOwnProperty(isolate, obj, name));
return *result;
}
@@ -2056,8 +1926,8 @@ RUNTIME_FUNCTION(Runtime_PreventExtensions) {
DCHECK(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0);
Handle<Object> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result, JSObject::PreventExtensions(obj));
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result,
+ JSObject::PreventExtensions(obj));
return *result;
}
@@ -2126,8 +1996,8 @@ RUNTIME_FUNCTION(Runtime_RegExpCompile) {
CONVERT_ARG_HANDLE_CHECKED(String, pattern, 1);
CONVERT_ARG_HANDLE_CHECKED(String, flags, 2);
Handle<Object> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result, RegExpImpl::Compile(re, pattern, flags));
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result,
+ RegExpImpl::Compile(re, pattern, flags));
return *result;
}
@@ -2201,7 +2071,7 @@ RUNTIME_FUNCTION(Runtime_EnableAccessChecks) {
static Object* ThrowRedeclarationError(Isolate* isolate, Handle<String> name) {
HandleScope scope(isolate);
- Handle<Object> args[1] = { name };
+ Handle<Object> args[1] = {name};
THROW_NEW_ERROR_RETURN_FAILURE(
isolate, NewTypeError("var_redeclaration", HandleVector(args, 1)));
}
@@ -2557,7 +2427,7 @@ RUNTIME_FUNCTION(Runtime_RegExpConstructResult) {
RUNTIME_ASSERT(size >= 0 && size <= FixedArray::kMaxLength);
CONVERT_ARG_HANDLE_CHECKED(Object, index, 1);
CONVERT_ARG_HANDLE_CHECKED(Object, input, 2);
- Handle<FixedArray> elements = isolate->factory()->NewFixedArray(size);
+ Handle<FixedArray> elements = isolate->factory()->NewFixedArray(size);
Handle<Map> regexp_map(isolate->native_context()->regexp_result_map());
Handle<JSObject> object =
isolate->factory()->NewJSObjectFromMap(regexp_map, NOT_TENURED, false);
@@ -2594,21 +2464,20 @@ RUNTIME_FUNCTION(Runtime_RegExpInitializeObject) {
Map* map = regexp->map();
Object* constructor = map->constructor();
- if (!FLAG_harmony_regexps &&
- constructor->IsJSFunction() &&
+ if (!FLAG_harmony_regexps && constructor->IsJSFunction() &&
JSFunction::cast(constructor)->initial_map() == map) {
// If we still have the original map, set in-object properties directly.
regexp->InObjectPropertyAtPut(JSRegExp::kSourceFieldIndex, *source);
// Both true and false are immovable immortal objects so no need for write
// barrier.
- regexp->InObjectPropertyAtPut(
- JSRegExp::kGlobalFieldIndex, *global, SKIP_WRITE_BARRIER);
- regexp->InObjectPropertyAtPut(
- JSRegExp::kIgnoreCaseFieldIndex, *ignoreCase, SKIP_WRITE_BARRIER);
- regexp->InObjectPropertyAtPut(
- JSRegExp::kMultilineFieldIndex, *multiline, SKIP_WRITE_BARRIER);
- regexp->InObjectPropertyAtPut(
- JSRegExp::kLastIndexFieldIndex, Smi::FromInt(0), SKIP_WRITE_BARRIER);
+ regexp->InObjectPropertyAtPut(JSRegExp::kGlobalFieldIndex, *global,
+ SKIP_WRITE_BARRIER);
+ regexp->InObjectPropertyAtPut(JSRegExp::kIgnoreCaseFieldIndex, *ignoreCase,
+ SKIP_WRITE_BARRIER);
+ regexp->InObjectPropertyAtPut(JSRegExp::kMultilineFieldIndex, *multiline,
+ SKIP_WRITE_BARRIER);
+ regexp->InObjectPropertyAtPut(JSRegExp::kLastIndexFieldIndex,
+ Smi::FromInt(0), SKIP_WRITE_BARRIER);
return *regexp;
}
@@ -2623,20 +2492,20 @@ RUNTIME_FUNCTION(Runtime_RegExpInitializeObject) {
static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE);
Handle<Object> zero(Smi::FromInt(0), isolate);
Factory* factory = isolate->factory();
- JSObject::SetOwnPropertyIgnoreAttributes(
- regexp, factory->source_string(), source, final).Check();
- JSObject::SetOwnPropertyIgnoreAttributes(
- regexp, factory->global_string(), global, final).Check();
+ JSObject::SetOwnPropertyIgnoreAttributes(regexp, factory->source_string(),
+ source, final).Check();
+ JSObject::SetOwnPropertyIgnoreAttributes(regexp, factory->global_string(),
+ global, final).Check();
JSObject::SetOwnPropertyIgnoreAttributes(
regexp, factory->ignore_case_string(), ignoreCase, final).Check();
- JSObject::SetOwnPropertyIgnoreAttributes(
- regexp, factory->multiline_string(), multiline, final).Check();
+ JSObject::SetOwnPropertyIgnoreAttributes(regexp, factory->multiline_string(),
+ multiline, final).Check();
if (FLAG_harmony_regexps) {
- JSObject::SetOwnPropertyIgnoreAttributes(
- regexp, factory->sticky_string(), sticky, final).Check();
+ JSObject::SetOwnPropertyIgnoreAttributes(regexp, factory->sticky_string(),
+ sticky, final).Check();
}
- JSObject::SetOwnPropertyIgnoreAttributes(
- regexp, factory->last_index_string(), zero, writable).Check();
+ JSObject::SetOwnPropertyIgnoreAttributes(regexp, factory->last_index_string(),
+ zero, writable).Check();
return *regexp;
}
@@ -2655,10 +2524,8 @@ RUNTIME_FUNCTION(Runtime_FinishArrayPrototypeSetup) {
}
-static void InstallBuiltin(Isolate* isolate,
- Handle<JSObject> holder,
- const char* name,
- Builtins::Name builtin_name) {
+static void InstallBuiltin(Isolate* isolate, Handle<JSObject> holder,
+ const char* name, Builtins::Name builtin_name) {
Handle<String> key = isolate->factory()->InternalizeUtf8String(name);
Handle<Code> code(isolate->builtins()->builtin(builtin_name));
Handle<JSFunction> optimized =
@@ -2694,9 +2561,8 @@ RUNTIME_FUNCTION(Runtime_IsSloppyModeFunction) {
HandleScope scope(isolate);
Handle<Object> delegate;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, delegate,
- Execution::TryGetFunctionDelegate(
- isolate, Handle<JSReceiver>(callable)));
+ isolate, delegate, Execution::TryGetFunctionDelegate(
+ isolate, Handle<JSReceiver>(callable)));
callable = JSFunction::cast(*delegate);
}
JSFunction* function = JSFunction::cast(callable);
@@ -2714,9 +2580,8 @@ RUNTIME_FUNCTION(Runtime_GetDefaultReceiver) {
HandleScope scope(isolate);
Handle<Object> delegate;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, delegate,
- Execution::TryGetFunctionDelegate(
- isolate, Handle<JSReceiver>(callable)));
+ isolate, delegate, Execution::TryGetFunctionDelegate(
+ isolate, Handle<JSReceiver>(callable)));
callable = JSFunction::cast(*delegate);
}
JSFunction* function = JSFunction::cast(callable);
@@ -2745,9 +2610,8 @@ RUNTIME_FUNCTION(Runtime_MaterializeRegExpLiteral) {
// function was created. We do not use the RegExp function from the
// current native context because this might be the RegExp function
// from another context which we should not have access to.
- Handle<JSFunction> constructor =
- Handle<JSFunction>(
- JSFunction::NativeContextFromLiterals(*literals)->regexp_function());
+ Handle<JSFunction> constructor = Handle<JSFunction>(
+ JSFunction::NativeContextFromLiterals(*literals)->regexp_function());
// Compute the regular expression literal.
Handle<Object> regexp;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
@@ -2989,8 +2853,8 @@ RUNTIME_FUNCTION(Runtime_SetCode) {
if (isolate->logger()->is_logging_code_events() ||
isolate->cpu_profiler()->is_profiling()) {
- isolate->logger()->LogExistingFunction(
- source_shared, Handle<Code>(source_shared->code()));
+ isolate->logger()->LogExistingFunction(source_shared,
+ Handle<Code>(source_shared->code()));
}
return *target;
@@ -3126,9 +2990,10 @@ RUNTIME_FUNCTION(Runtime_ThrowGeneratorStateError) {
DCHECK(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator, 0);
int continuation = generator->continuation();
- const char* message = continuation == JSGeneratorObject::kGeneratorClosed ?
- "generator_finished" : "generator_running";
- Vector< Handle<Object> > argv = HandleVector<Object>(NULL, 0);
+ const char* message = continuation == JSGeneratorObject::kGeneratorClosed
+ ? "generator_finished"
+ : "generator_running";
+ Vector<Handle<Object> > argv = HandleVector<Object>(NULL, 0);
THROW_NEW_ERROR_RETURN_FAILURE(isolate, NewError(message, argv));
}
@@ -3140,8 +3005,7 @@ RUNTIME_FUNCTION(Runtime_ObjectFreeze) {
// %ObjectFreeze is a fast path and these cases are handled elsewhere.
RUNTIME_ASSERT(!object->HasSloppyArgumentsElements() &&
- !object->map()->is_observed() &&
- !object->IsJSProxy());
+ !object->map()->is_observed() && !object->IsJSProxy());
Handle<Object> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, JSObject::Freeze(object));
@@ -3193,9 +3057,7 @@ class FixedArrayBuilder {
}
explicit FixedArrayBuilder(Handle<FixedArray> backing_store)
- : array_(backing_store),
- length_(0),
- has_non_smi_elements_(false) {
+ : array_(backing_store), length_(0), has_non_smi_elements_(false) {
// Require a non-zero initial size. Ensures that doubling the size to
// extend the array will work.
DCHECK(backing_store->length() > 0);
@@ -3237,17 +3099,11 @@ class FixedArrayBuilder {
length_++;
}
- Handle<FixedArray> array() {
- return array_;
- }
+ Handle<FixedArray> array() { return array_; }
- int length() {
- return length_;
- }
+ int length() { return length_; }
- int capacity() {
- return array_->length();
- }
+ int capacity() { return array_->length(); }
Handle<JSArray> ToJSArray(Handle<JSArray> target_array) {
JSArray::SetContent(target_array, array_);
@@ -3268,15 +3124,11 @@ const int kStringBuilderConcatHelperLengthBits = 11;
const int kStringBuilderConcatHelperPositionBits = 19;
template <typename schar>
-static inline void StringBuilderConcatHelper(String*,
- schar*,
- FixedArray*,
- int);
+static inline void StringBuilderConcatHelper(String*, schar*, FixedArray*, int);
typedef BitField<int, 0, kStringBuilderConcatHelperLengthBits>
StringBuilderSubstringLength;
-typedef BitField<int,
- kStringBuilderConcatHelperLengthBits,
+typedef BitField<int, kStringBuilderConcatHelperLengthBits,
kStringBuilderConcatHelperPositionBits>
StringBuilderSubstringPosition;
@@ -3295,8 +3147,7 @@ class ReplacementStringBuilder {
DCHECK(estimated_part_count > 0);
}
- static inline void AddSubjectSlice(FixedArrayBuilder* builder,
- int from,
+ static inline void AddSubjectSlice(FixedArrayBuilder* builder, int from,
int to) {
DCHECK(from >= 0);
int length = to - from;
@@ -3304,7 +3155,7 @@ class ReplacementStringBuilder {
if (StringBuilderSubstringLength::is_valid(length) &&
StringBuilderSubstringPosition::is_valid(from)) {
int encoded_slice = StringBuilderSubstringLength::encode(length) |
- StringBuilderSubstringPosition::encode(from);
+ StringBuilderSubstringPosition::encode(from);
builder->Add(Smi::FromInt(encoded_slice));
} else {
// Otherwise encode as two smis.
@@ -3314,9 +3165,7 @@ class ReplacementStringBuilder {
}
- void EnsureCapacity(int elements) {
- array_builder_.EnsureCapacity(elements);
- }
+ void EnsureCapacity(int elements) { array_builder_.EnsureCapacity(elements); }
void AddSubjectSlice(int from, int to) {
@@ -3347,14 +3196,11 @@ class ReplacementStringBuilder {
Handle<SeqOneByteString> seq;
ASSIGN_RETURN_ON_EXCEPTION(
isolate, seq,
- isolate->factory()->NewRawOneByteString(character_count_),
- String);
+ isolate->factory()->NewRawOneByteString(character_count_), String);
DisallowHeapAllocation no_gc;
uint8_t* char_buffer = seq->GetChars();
- StringBuilderConcatHelper(*subject_,
- char_buffer,
- *array_builder_.array(),
+ StringBuilderConcatHelper(*subject_, char_buffer, *array_builder_.array(),
array_builder_.length());
joined_string = Handle<String>::cast(seq);
} else {
@@ -3362,14 +3208,11 @@ class ReplacementStringBuilder {
Handle<SeqTwoByteString> seq;
ASSIGN_RETURN_ON_EXCEPTION(
isolate, seq,
- isolate->factory()->NewRawTwoByteString(character_count_),
- String);
+ isolate->factory()->NewRawTwoByteString(character_count_), String);
DisallowHeapAllocation no_gc;
uc16* char_buffer = seq->GetChars();
- StringBuilderConcatHelper(*subject_,
- char_buffer,
- *array_builder_.array(),
+ StringBuilderConcatHelper(*subject_, char_buffer, *array_builder_.array(),
array_builder_.length());
joined_string = Handle<String>::cast(seq);
}
@@ -3407,20 +3250,15 @@ class CompiledReplacement {
: parts_(1, zone), replacement_substrings_(0, zone), zone_(zone) {}
// Return whether the replacement is simple.
- bool Compile(Handle<String> replacement,
- int capture_count,
+ bool Compile(Handle<String> replacement, int capture_count,
int subject_length);
// Use Apply only if Compile returned false.
- void Apply(ReplacementStringBuilder* builder,
- int match_from,
- int match_to,
+ void Apply(ReplacementStringBuilder* builder, int match_from, int match_to,
int32_t* match);
// Number of distinct parts of the replacement pattern.
- int parts() {
- return parts_.length();
- }
+ int parts() { return parts_.length(); }
Zone* zone() const { return zone_; }
@@ -3431,7 +3269,6 @@ class CompiledReplacement {
SUBJECT_CAPTURE,
REPLACEMENT_SUBSTRING,
REPLACEMENT_STRING,
-
NUMBER_OF_PART_TYPES
};
@@ -3459,8 +3296,7 @@ class CompiledReplacement {
// If tag <= 0 then it is the negation of a start index of a substring of
// the replacement pattern, otherwise it's a value from PartType.
- ReplacementPart(int tag, int data)
- : tag(tag), data(data) {
+ ReplacementPart(int tag, int data) : tag(tag), data(data) {
// Must be non-positive or a PartType value.
DCHECK(tag < NUMBER_OF_PART_TYPES);
}
@@ -3481,12 +3317,10 @@ class CompiledReplacement {
int data;
};
- template<typename Char>
+ template <typename Char>
bool ParseReplacementPattern(ZoneList<ReplacementPart>* parts,
- Vector<Char> characters,
- int capture_count,
- int subject_length,
- Zone* zone) {
+ Vector<Char> characters, int capture_count,
+ int subject_length, Zone* zone) {
int length = characters.length();
int last = 0;
for (int i = 0; i < length; i++) {
@@ -3498,83 +3332,85 @@ class CompiledReplacement {
}
Char c2 = characters[next_index];
switch (c2) {
- case '$':
- if (i > last) {
- // There is a substring before. Include the first "$".
- parts->Add(ReplacementPart::ReplacementSubString(last, next_index),
- zone);
- last = next_index + 1; // Continue after the second "$".
- } else {
- // Let the next substring start with the second "$".
- last = next_index;
- }
- i = next_index;
- break;
- case '`':
- if (i > last) {
- parts->Add(ReplacementPart::ReplacementSubString(last, i), zone);
- }
- parts->Add(ReplacementPart::SubjectPrefix(), zone);
- i = next_index;
- last = i + 1;
- break;
- case '\'':
- if (i > last) {
- parts->Add(ReplacementPart::ReplacementSubString(last, i), zone);
- }
- parts->Add(ReplacementPart::SubjectSuffix(subject_length), zone);
- i = next_index;
- last = i + 1;
- break;
- case '&':
- if (i > last) {
- parts->Add(ReplacementPart::ReplacementSubString(last, i), zone);
- }
- parts->Add(ReplacementPart::SubjectMatch(), zone);
- i = next_index;
- last = i + 1;
- break;
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9': {
- int capture_ref = c2 - '0';
- if (capture_ref > capture_count) {
+ case '$':
+ if (i > last) {
+ // There is a substring before. Include the first "$".
+ parts->Add(
+ ReplacementPart::ReplacementSubString(last, next_index),
+ zone);
+ last = next_index + 1; // Continue after the second "$".
+ } else {
+ // Let the next substring start with the second "$".
+ last = next_index;
+ }
i = next_index;
- continue;
- }
- int second_digit_index = next_index + 1;
- if (second_digit_index < length) {
- // Peek ahead to see if we have two digits.
- Char c3 = characters[second_digit_index];
- if ('0' <= c3 && c3 <= '9') { // Double digits.
- int double_digit_ref = capture_ref * 10 + c3 - '0';
- if (double_digit_ref <= capture_count) {
- next_index = second_digit_index;
- capture_ref = double_digit_ref;
- }
+ break;
+ case '`':
+ if (i > last) {
+ parts->Add(ReplacementPart::ReplacementSubString(last, i), zone);
}
- }
- if (capture_ref > 0) {
+ parts->Add(ReplacementPart::SubjectPrefix(), zone);
+ i = next_index;
+ last = i + 1;
+ break;
+ case '\'':
+ if (i > last) {
+ parts->Add(ReplacementPart::ReplacementSubString(last, i), zone);
+ }
+ parts->Add(ReplacementPart::SubjectSuffix(subject_length), zone);
+ i = next_index;
+ last = i + 1;
+ break;
+ case '&':
if (i > last) {
parts->Add(ReplacementPart::ReplacementSubString(last, i), zone);
}
- DCHECK(capture_ref <= capture_count);
- parts->Add(ReplacementPart::SubjectCapture(capture_ref), zone);
- last = next_index + 1;
+ parts->Add(ReplacementPart::SubjectMatch(), zone);
+ i = next_index;
+ last = i + 1;
+ break;
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': {
+ int capture_ref = c2 - '0';
+ if (capture_ref > capture_count) {
+ i = next_index;
+ continue;
+ }
+ int second_digit_index = next_index + 1;
+ if (second_digit_index < length) {
+ // Peek ahead to see if we have two digits.
+ Char c3 = characters[second_digit_index];
+ if ('0' <= c3 && c3 <= '9') { // Double digits.
+ int double_digit_ref = capture_ref * 10 + c3 - '0';
+ if (double_digit_ref <= capture_count) {
+ next_index = second_digit_index;
+ capture_ref = double_digit_ref;
+ }
+ }
+ }
+ if (capture_ref > 0) {
+ if (i > last) {
+ parts->Add(ReplacementPart::ReplacementSubString(last, i),
+ zone);
+ }
+ DCHECK(capture_ref <= capture_count);
+ parts->Add(ReplacementPart::SubjectCapture(capture_ref), zone);
+ last = next_index + 1;
+ }
+ i = next_index;
+ break;
}
- i = next_index;
- break;
- }
- default:
- i = next_index;
- break;
+ default:
+ i = next_index;
+ break;
}
}
}
@@ -3595,8 +3431,7 @@ class CompiledReplacement {
};
-bool CompiledReplacement::Compile(Handle<String> replacement,
- int capture_count,
+bool CompiledReplacement::Compile(Handle<String> replacement, int capture_count,
int subject_length) {
{
DisallowHeapAllocation no_gc;
@@ -3604,18 +3439,12 @@ bool CompiledReplacement::Compile(Handle<String> replacement,
DCHECK(content.IsFlat());
bool simple = false;
if (content.IsOneByte()) {
- simple = ParseReplacementPattern(&parts_,
- content.ToOneByteVector(),
- capture_count,
- subject_length,
- zone());
+ simple = ParseReplacementPattern(&parts_, content.ToOneByteVector(),
+ capture_count, subject_length, zone());
} else {
DCHECK(content.IsTwoByte());
- simple = ParseReplacementPattern(&parts_,
- content.ToUC16Vector(),
- capture_count,
- subject_length,
- zone());
+ simple = ParseReplacementPattern(&parts_, content.ToUC16Vector(),
+ capture_count, subject_length, zone());
}
if (simple) return true;
}
@@ -3644,9 +3473,7 @@ bool CompiledReplacement::Compile(Handle<String> replacement,
void CompiledReplacement::Apply(ReplacementStringBuilder* builder,
- int match_from,
- int match_to,
- int32_t* match) {
+ int match_from, int match_to, int32_t* match) {
DCHECK_LT(0, parts_.length());
for (int i = 0, n = parts_.length(); i < n; i++) {
ReplacementPart part = parts_[i];
@@ -3701,10 +3528,8 @@ void FindOneByteStringIndices(Vector<const uint8_t> subject, char pattern,
}
-void FindTwoByteStringIndices(const Vector<const uc16> subject,
- uc16 pattern,
- ZoneList<int>* indices,
- unsigned int limit,
+void FindTwoByteStringIndices(const Vector<const uc16> subject, uc16 pattern,
+ ZoneList<int>* indices, unsigned int limit,
Zone* zone) {
DCHECK(limit > 0);
const uc16* subject_start = subject.start();
@@ -3719,12 +3544,9 @@ void FindTwoByteStringIndices(const Vector<const uc16> subject,
template <typename SubjectChar, typename PatternChar>
-void FindStringIndices(Isolate* isolate,
- Vector<const SubjectChar> subject,
+void FindStringIndices(Isolate* isolate, Vector<const SubjectChar> subject,
Vector<const PatternChar> pattern,
- ZoneList<int>* indices,
- unsigned int limit,
- Zone* zone) {
+ ZoneList<int>* indices, unsigned int limit, Zone* zone) {
DCHECK(limit > 0);
// Collect indices of pattern in subject.
// Stop after finding at most limit values.
@@ -3741,12 +3563,9 @@ void FindStringIndices(Isolate* isolate,
}
-void FindStringIndicesDispatch(Isolate* isolate,
- String* subject,
- String* pattern,
- ZoneList<int>* indices,
- unsigned int limit,
- Zone* zone) {
+void FindStringIndicesDispatch(Isolate* isolate, String* subject,
+ String* pattern, ZoneList<int>* indices,
+ unsigned int limit, Zone* zone) {
{
DisallowHeapAllocation no_gc;
String::FlatContent subject_content = subject->GetFlatContent();
@@ -3762,20 +3581,12 @@ void FindStringIndicesDispatch(Isolate* isolate,
FindOneByteStringIndices(subject_vector, pattern_vector[0], indices,
limit, zone);
} else {
- FindStringIndices(isolate,
- subject_vector,
- pattern_vector,
- indices,
- limit,
- zone);
+ FindStringIndices(isolate, subject_vector, pattern_vector, indices,
+ limit, zone);
}
} else {
- FindStringIndices(isolate,
- subject_vector,
- pattern_content.ToUC16Vector(),
- indices,
- limit,
- zone);
+ FindStringIndices(isolate, subject_vector,
+ pattern_content.ToUC16Vector(), indices, limit, zone);
}
} else {
Vector<const uc16> subject_vector = subject_content.ToUC16Vector();
@@ -3783,34 +3594,20 @@ void FindStringIndicesDispatch(Isolate* isolate,
Vector<const uint8_t> pattern_vector =
pattern_content.ToOneByteVector();
if (pattern_vector.length() == 1) {
- FindTwoByteStringIndices(subject_vector,
- pattern_vector[0],
- indices,
- limit,
- zone);
+ FindTwoByteStringIndices(subject_vector, pattern_vector[0], indices,
+ limit, zone);
} else {
- FindStringIndices(isolate,
- subject_vector,
- pattern_vector,
- indices,
- limit,
- zone);
+ FindStringIndices(isolate, subject_vector, pattern_vector, indices,
+ limit, zone);
}
} else {
Vector<const uc16> pattern_vector = pattern_content.ToUC16Vector();
if (pattern_vector.length() == 1) {
- FindTwoByteStringIndices(subject_vector,
- pattern_vector[0],
- indices,
- limit,
- zone);
+ FindTwoByteStringIndices(subject_vector, pattern_vector[0], indices,
+ limit, zone);
} else {
- FindStringIndices(isolate,
- subject_vector,
- pattern_vector,
- indices,
- limit,
- zone);
+ FindStringIndices(isolate, subject_vector, pattern_vector, indices,
+ limit, zone);
}
}
}
@@ -3818,13 +3615,10 @@ void FindStringIndicesDispatch(Isolate* isolate,
}
-template<typename ResultSeqString>
+template <typename ResultSeqString>
MUST_USE_RESULT static Object* StringReplaceGlobalAtomRegExpWithString(
- Isolate* isolate,
- Handle<String> subject,
- Handle<JSRegExp> pattern_regexp,
- Handle<String> replacement,
- Handle<JSArray> last_match_info) {
+ Isolate* isolate, Handle<String> subject, Handle<JSRegExp> pattern_regexp,
+ Handle<String> replacement, Handle<JSArray> last_match_info) {
DCHECK(subject->IsFlat());
DCHECK(replacement->IsFlat());
@@ -3837,18 +3631,17 @@ MUST_USE_RESULT static Object* StringReplaceGlobalAtomRegExpWithString(
int pattern_len = pattern->length();
int replacement_len = replacement->length();
- FindStringIndicesDispatch(
- isolate, *subject, pattern, &indices, 0xffffffff, zone_scope.zone());
+ FindStringIndicesDispatch(isolate, *subject, pattern, &indices, 0xffffffff,
+ zone_scope.zone());
int matches = indices.length();
if (matches == 0) return *subject;
// Detect integer overflow.
- int64_t result_len_64 =
- (static_cast<int64_t>(replacement_len) -
- static_cast<int64_t>(pattern_len)) *
- static_cast<int64_t>(matches) +
- static_cast<int64_t>(subject_len);
+ int64_t result_len_64 = (static_cast<int64_t>(replacement_len) -
+ static_cast<int64_t>(pattern_len)) *
+ static_cast<int64_t>(matches) +
+ static_cast<int64_t>(subject_len);
int result_len;
if (result_len_64 > static_cast<int64_t>(String::kMaxLength)) {
STATIC_ASSERT(String::kMaxLength < kMaxInt);
@@ -3873,18 +3666,14 @@ MUST_USE_RESULT static Object* StringReplaceGlobalAtomRegExpWithString(
for (int i = 0; i < matches; i++) {
// Copy non-matched subject content.
if (subject_pos < indices.at(i)) {
- String::WriteToFlat(*subject,
- result->GetChars() + result_pos,
- subject_pos,
- indices.at(i));
+ String::WriteToFlat(*subject, result->GetChars() + result_pos,
+ subject_pos, indices.at(i));
result_pos += indices.at(i) - subject_pos;
}
// Replace match.
if (replacement_len > 0) {
- String::WriteToFlat(*replacement,
- result->GetChars() + result_pos,
- 0,
+ String::WriteToFlat(*replacement, result->GetChars() + result_pos, 0,
replacement_len);
result_pos += replacement_len;
}
@@ -3893,14 +3682,12 @@ MUST_USE_RESULT static Object* StringReplaceGlobalAtomRegExpWithString(
}
// Add remaining subject content at the end.
if (subject_pos < subject_len) {
- String::WriteToFlat(*subject,
- result->GetChars() + result_pos,
- subject_pos,
+ String::WriteToFlat(*subject, result->GetChars() + result_pos, subject_pos,
subject_len);
}
- int32_t match_indices[] = { indices.at(matches - 1),
- indices.at(matches - 1) + pattern_len };
+ int32_t match_indices[] = {indices.at(matches - 1),
+ indices.at(matches - 1) + pattern_len};
RegExpImpl::SetLastMatchInfo(last_match_info, subject, 0, match_indices);
return *result;
@@ -3908,11 +3695,8 @@ MUST_USE_RESULT static Object* StringReplaceGlobalAtomRegExpWithString(
MUST_USE_RESULT static Object* StringReplaceGlobalRegExpWithString(
- Isolate* isolate,
- Handle<String> subject,
- Handle<JSRegExp> regexp,
- Handle<String> replacement,
- Handle<JSArray> last_match_info) {
+ Isolate* isolate, Handle<String> subject, Handle<JSRegExp> regexp,
+ Handle<String> replacement, Handle<JSArray> last_match_info) {
DCHECK(subject->IsFlat());
DCHECK(replacement->IsFlat());
@@ -3922,14 +3706,12 @@ MUST_USE_RESULT static Object* StringReplaceGlobalRegExpWithString(
// CompiledReplacement uses zone allocation.
ZoneScope zone_scope(isolate->runtime_zone());
CompiledReplacement compiled_replacement(zone_scope.zone());
- bool simple_replace = compiled_replacement.Compile(replacement,
- capture_count,
- subject_length);
+ bool simple_replace =
+ compiled_replacement.Compile(replacement, capture_count, subject_length);
// Shortcut for simple non-regexp global replacements
if (regexp->TypeTag() == JSRegExp::ATOM && simple_replace) {
- if (subject->HasOnlyOneByteChars() &&
- replacement->HasOnlyOneByteChars()) {
+ if (subject->HasOnlyOneByteChars() && replacement->HasOnlyOneByteChars()) {
return StringReplaceGlobalAtomRegExpWithString<SeqOneByteString>(
isolate, subject, regexp, replacement, last_match_info);
} else {
@@ -3951,9 +3733,7 @@ MUST_USE_RESULT static Object* StringReplaceGlobalRegExpWithString(
// from. Global regexps can match any number of times, so we guess
// conservatively.
int expected_parts = (compiled_replacement.parts() + 1) * 4 + 1;
- ReplacementStringBuilder builder(isolate->heap(),
- subject,
- expected_parts);
+ ReplacementStringBuilder builder(isolate->heap(), subject, expected_parts);
// Number of parts added by compiled replacement plus preceeding
// string and possibly suffix after last match. It is possible for
@@ -3975,10 +3755,7 @@ MUST_USE_RESULT static Object* StringReplaceGlobalRegExpWithString(
if (simple_replace) {
builder.AddString(replacement);
} else {
- compiled_replacement.Apply(&builder,
- start,
- end,
- current_match);
+ compiled_replacement.Apply(&builder, start, end, current_match);
}
prev = end;
@@ -3992,9 +3769,7 @@ MUST_USE_RESULT static Object* StringReplaceGlobalRegExpWithString(
builder.AddSubjectSlice(prev, subject_length);
}
- RegExpImpl::SetLastMatchInfo(last_match_info,
- subject,
- capture_count,
+ RegExpImpl::SetLastMatchInfo(last_match_info, subject, capture_count,
global_cache.LastSuccessfulMatch());
Handle<String> result;
@@ -4005,9 +3780,7 @@ MUST_USE_RESULT static Object* StringReplaceGlobalRegExpWithString(
template <typename ResultSeqString>
MUST_USE_RESULT static Object* StringReplaceGlobalRegExpWithEmptyString(
- Isolate* isolate,
- Handle<String> subject,
- Handle<JSRegExp> regexp,
+ Isolate* isolate, Handle<String> subject, Handle<JSRegExp> regexp,
Handle<JSArray> last_match_info) {
DCHECK(subject->IsFlat());
@@ -4067,15 +3840,13 @@ MUST_USE_RESULT static Object* StringReplaceGlobalRegExpWithEmptyString(
if (global_cache.HasException()) return isolate->heap()->exception();
- RegExpImpl::SetLastMatchInfo(last_match_info,
- subject,
- capture_count,
+ RegExpImpl::SetLastMatchInfo(last_match_info, subject, capture_count,
global_cache.LastSuccessfulMatch());
if (prev < subject_length) {
// Add substring subject[prev;length] to answer string.
- String::WriteToFlat(
- *subject, answer->GetChars() + position, prev, subject_length);
+ String::WriteToFlat(*subject, answer->GetChars() + position, prev,
+ subject_length);
position += subject_length - prev;
}
@@ -4128,19 +3899,16 @@ RUNTIME_FUNCTION(Runtime_StringReplaceGlobalRegExpWithString) {
replacement = String::Flatten(replacement);
- return StringReplaceGlobalRegExpWithString(
- isolate, subject, regexp, replacement, last_match_info);
+ return StringReplaceGlobalRegExpWithString(isolate, subject, regexp,
+ replacement, last_match_info);
}
// This may return an empty MaybeHandle if an exception is thrown or
// we abort due to reaching the recursion limit.
-MaybeHandle<String> StringReplaceOneCharWithString(Isolate* isolate,
- Handle<String> subject,
- Handle<String> search,
- Handle<String> replace,
- bool* found,
- int recursion_limit) {
+MaybeHandle<String> StringReplaceOneCharWithString(
+ Isolate* isolate, Handle<String> subject, Handle<String> search,
+ Handle<String> replace, bool* found, int recursion_limit) {
StackLimitCheck stackLimitCheck(isolate);
if (stackLimitCheck.HasOverflowed() || (recursion_limit == 0)) {
return MaybeHandle<String>();
@@ -4151,17 +3919,16 @@ MaybeHandle<String> StringReplaceOneCharWithString(Isolate* isolate,
Handle<String> first = Handle<String>(cons->first());
Handle<String> second = Handle<String>(cons->second());
Handle<String> new_first;
- if (!StringReplaceOneCharWithString(
- isolate, first, search, replace, found, recursion_limit)
- .ToHandle(&new_first)) {
+ if (!StringReplaceOneCharWithString(isolate, first, search, replace, found,
+ recursion_limit).ToHandle(&new_first)) {
return MaybeHandle<String>();
}
if (*found) return isolate->factory()->NewConsString(new_first, second);
Handle<String> new_second;
- if (!StringReplaceOneCharWithString(
- isolate, second, search, replace, found, recursion_limit)
- .ToHandle(&new_second)) {
+ if (!StringReplaceOneCharWithString(isolate, second, search, replace, found,
+ recursion_limit)
+ .ToHandle(&new_second)) {
return MaybeHandle<String>();
}
if (*found) return isolate->factory()->NewConsString(first, new_second);
@@ -4174,8 +3941,7 @@ MaybeHandle<String> StringReplaceOneCharWithString(Isolate* isolate,
Handle<String> first = isolate->factory()->NewSubString(subject, 0, index);
Handle<String> cons1;
ASSIGN_RETURN_ON_EXCEPTION(
- isolate, cons1,
- isolate->factory()->NewConsString(first, replace),
+ isolate, cons1, isolate->factory()->NewConsString(first, replace),
String);
Handle<String> second =
isolate->factory()->NewSubString(subject, index + 1, subject->length());
@@ -4196,9 +3962,8 @@ RUNTIME_FUNCTION(Runtime_StringReplaceOneCharWithString) {
const int kRecursionLimit = 0x1000;
bool found = false;
Handle<String> result;
- if (StringReplaceOneCharWithString(
- isolate, subject, search, replace, &found, kRecursionLimit)
- .ToHandle(&result)) {
+ if (StringReplaceOneCharWithString(isolate, subject, search, replace, &found,
+ kRecursionLimit).ToHandle(&result)) {
return *result;
}
if (isolate->has_pending_exception()) return isolate->heap()->exception();
@@ -4206,8 +3971,8 @@ RUNTIME_FUNCTION(Runtime_StringReplaceOneCharWithString) {
subject = String::Flatten(subject);
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, result,
- StringReplaceOneCharWithString(
- isolate, subject, search, replace, &found, kRecursionLimit));
+ StringReplaceOneCharWithString(isolate, subject, search, replace, &found,
+ kRecursionLimit));
return *result;
}
@@ -4215,10 +3980,8 @@ RUNTIME_FUNCTION(Runtime_StringReplaceOneCharWithString) {
// Perform string match of pattern on subject, starting at start index.
// Caller must ensure that 0 <= start_index <= sub->length(),
// and should check that pat->length() + start_index <= sub->length().
-int Runtime::StringMatch(Isolate* isolate,
- Handle<String> sub,
- Handle<String> pat,
- int start_index) {
+int Runtime::StringMatch(Isolate* isolate, Handle<String> sub,
+ Handle<String> pat, int start_index) {
DCHECK(0 <= start_index);
DCHECK(start_index <= sub->length());
@@ -4240,27 +4003,18 @@ int Runtime::StringMatch(Isolate* isolate,
if (seq_pat.IsOneByte()) {
Vector<const uint8_t> pat_vector = seq_pat.ToOneByteVector();
if (seq_sub.IsOneByte()) {
- return SearchString(isolate,
- seq_sub.ToOneByteVector(),
- pat_vector,
+ return SearchString(isolate, seq_sub.ToOneByteVector(), pat_vector,
start_index);
}
- return SearchString(isolate,
- seq_sub.ToUC16Vector(),
- pat_vector,
+ return SearchString(isolate, seq_sub.ToUC16Vector(), pat_vector,
start_index);
}
Vector<const uc16> pat_vector = seq_pat.ToUC16Vector();
if (seq_sub.IsOneByte()) {
- return SearchString(isolate,
- seq_sub.ToOneByteVector(),
- pat_vector,
+ return SearchString(isolate, seq_sub.ToOneByteVector(), pat_vector,
start_index);
}
- return SearchString(isolate,
- seq_sub.ToUC16Vector(),
- pat_vector,
- start_index);
+ return SearchString(isolate, seq_sub.ToUC16Vector(), pat_vector, start_index);
}
@@ -4283,8 +4037,7 @@ RUNTIME_FUNCTION(Runtime_StringIndexOf) {
template <typename schar, typename pchar>
static int StringMatchBackwards(Vector<const schar> subject,
- Vector<const pchar> pattern,
- int idx) {
+ Vector<const pchar> pattern, int idx) {
int pattern_length = pattern.length();
DCHECK(pattern_length >= 1);
DCHECK(idx + pattern_length <= subject.length());
@@ -4303,7 +4056,7 @@ static int StringMatchBackwards(Vector<const schar> subject,
if (subject[i] != pattern_first_char) continue;
int j = 1;
while (j < pattern_length) {
- if (pattern[j] != subject[i+j]) {
+ if (pattern[j] != subject[i + j]) {
break;
}
j++;
@@ -4350,23 +4103,19 @@ RUNTIME_FUNCTION(Runtime_StringLastIndexOf) {
if (pat_content.IsOneByte()) {
Vector<const uint8_t> pat_vector = pat_content.ToOneByteVector();
if (sub_content.IsOneByte()) {
- position = StringMatchBackwards(sub_content.ToOneByteVector(),
- pat_vector,
+ position = StringMatchBackwards(sub_content.ToOneByteVector(), pat_vector,
start_index);
} else {
- position = StringMatchBackwards(sub_content.ToUC16Vector(),
- pat_vector,
+ position = StringMatchBackwards(sub_content.ToUC16Vector(), pat_vector,
start_index);
}
} else {
Vector<const uc16> pat_vector = pat_content.ToUC16Vector();
if (sub_content.IsOneByte()) {
- position = StringMatchBackwards(sub_content.ToOneByteVector(),
- pat_vector,
+ position = StringMatchBackwards(sub_content.ToOneByteVector(), pat_vector,
start_index);
} else {
- position = StringMatchBackwards(sub_content.ToUC16Vector(),
- pat_vector,
+ position = StringMatchBackwards(sub_content.ToUC16Vector(), pat_vector,
start_index);
}
}
@@ -4487,9 +4236,7 @@ RUNTIME_FUNCTION(Runtime_StringMatch) {
return isolate->heap()->null_value();
}
- RegExpImpl::SetLastMatchInfo(regexp_info,
- subject,
- capture_count,
+ RegExpImpl::SetLastMatchInfo(regexp_info, subject, capture_count,
global_cache.LastSuccessfulMatch());
int matches = offsets.length() / 2;
@@ -4513,13 +4260,11 @@ RUNTIME_FUNCTION(Runtime_StringMatch) {
// Only called from Runtime_RegExpExecMultiple so it doesn't need to maintain
// separate last match info. See comment on that function.
-template<bool has_capture>
-static Object* SearchRegExpMultiple(
- Isolate* isolate,
- Handle<String> subject,
- Handle<JSRegExp> regexp,
- Handle<JSArray> last_match_array,
- Handle<JSArray> result_array) {
+template <bool has_capture>
+static Object* SearchRegExpMultiple(Isolate* isolate, Handle<String> subject,
+ Handle<JSRegExp> regexp,
+ Handle<JSArray> last_match_array,
+ Handle<JSArray> result_array) {
DCHECK(subject->IsFlat());
DCHECK_NE(has_capture, regexp->CaptureCount() == 0);
@@ -4529,11 +4274,10 @@ static Object* SearchRegExpMultiple(
static const int kMinLengthToCache = 0x1000;
if (subject_length > kMinLengthToCache) {
- Handle<Object> cached_answer(RegExpResultsCache::Lookup(
- isolate->heap(),
- *subject,
- regexp->data(),
- RegExpResultsCache::REGEXP_MULTIPLE_INDICES), isolate);
+ Handle<Object> cached_answer(
+ RegExpResultsCache::Lookup(isolate->heap(), *subject, regexp->data(),
+ RegExpResultsCache::REGEXP_MULTIPLE_INDICES),
+ isolate);
if (*cached_answer != Smi::FromInt(0)) {
Handle<FixedArray> cached_fixed_array =
Handle<FixedArray>(FixedArray::cast(*cached_answer));
@@ -4545,8 +4289,8 @@ static Object* SearchRegExpMultiple(
cached_fixed_array->get(cached_fixed_array->length() - 1);
Smi* js_array_length = Smi::cast(cached_fixed_array_last_element);
result_array->set_length(js_array_length);
- RegExpImpl::SetLastMatchInfo(
- last_match_array, subject, capture_count, NULL);
+ RegExpImpl::SetLastMatchInfo(last_match_array, subject, capture_count,
+ NULL);
return *result_array;
}
}
@@ -4578,8 +4322,7 @@ static Object* SearchRegExpMultiple(
match_start = current_match[0];
builder.EnsureCapacity(kMaxBuilderEntriesPerRegExpMatch);
if (match_end < match_start) {
- ReplacementStringBuilder::AddSubjectSlice(&builder,
- match_end,
+ ReplacementStringBuilder::AddSubjectSlice(&builder, match_end,
match_start);
}
match_end = current_match[1];
@@ -4588,13 +4331,11 @@ static Object* SearchRegExpMultiple(
HandleScope temp_scope(isolate);
Handle<String> match;
if (!first) {
- match = isolate->factory()->NewProperSubString(subject,
- match_start,
+ match = isolate->factory()->NewProperSubString(subject, match_start,
match_end);
} else {
- match = isolate->factory()->NewSubString(subject,
- match_start,
- match_end);
+ match =
+ isolate->factory()->NewSubString(subject, match_start, match_end);
first = false;
}
@@ -4632,13 +4373,12 @@ static Object* SearchRegExpMultiple(
if (match_start >= 0) {
// Finished matching, with at least one match.
if (match_end < subject_length) {
- ReplacementStringBuilder::AddSubjectSlice(&builder,
- match_end,
+ ReplacementStringBuilder::AddSubjectSlice(&builder, match_end,
subject_length);
}
- RegExpImpl::SetLastMatchInfo(
- last_match_array, subject, capture_count, NULL);
+ RegExpImpl::SetLastMatchInfo(last_match_array, subject, capture_count,
+ NULL);
if (subject_length > kMinLengthToCache) {
// Store the length of the result array into the last element of the
@@ -4648,10 +4388,8 @@ static Object* SearchRegExpMultiple(
fixed_array->set(fixed_array->length() - 1,
Smi::FromInt(builder.length()));
// Cache the result and turn the FixedArray into a COW array.
- RegExpResultsCache::Enter(isolate,
- subject,
- handle(regexp->data(), isolate),
- fixed_array,
+ RegExpResultsCache::Enter(isolate, subject,
+ handle(regexp->data(), isolate), fixed_array,
RegExpResultsCache::REGEXP_MULTIPLE_INDICES);
}
return *builder.ToJSArray(result_array);
@@ -4679,11 +4417,11 @@ RUNTIME_FUNCTION(Runtime_RegExpExecMultiple) {
RUNTIME_ASSERT(regexp->GetFlags().is_global());
if (regexp->CaptureCount() == 0) {
- return SearchRegExpMultiple<false>(
- isolate, subject, regexp, last_match_info, result_array);
+ return SearchRegExpMultiple<false>(isolate, subject, regexp,
+ last_match_info, result_array);
} else {
- return SearchRegExpMultiple<true>(
- isolate, subject, regexp, last_match_info, result_array);
+ return SearchRegExpMultiple<true>(isolate, subject, regexp, last_match_info,
+ result_array);
}
}
@@ -4700,8 +4438,8 @@ RUNTIME_FUNCTION(Runtime_NumberToRadixString) {
if (value >= 0 && value < radix) {
// Character array used for conversion.
static const char kCharTable[] = "0123456789abcdefghijklmnopqrstuvwxyz";
- return *isolate->factory()->
- LookupSingleCharacterStringFromCode(kCharTable[value]);
+ return *isolate->factory()->LookupSingleCharacterStringFromCode(
+ kCharTable[value]);
}
}
@@ -4827,8 +4565,8 @@ static MaybeHandle<Name> ToName(Isolate* isolate, Handle<Object> key) {
return Handle<Name>::cast(key);
} else {
Handle<Object> converted;
- ASSIGN_RETURN_ON_EXCEPTION(
- isolate, converted, Execution::ToString(isolate, key), Name);
+ ASSIGN_RETURN_ON_EXCEPTION(isolate, converted,
+ Execution::ToString(isolate, key), Name);
return Handle<Name>::cast(converted);
}
}
@@ -4859,7 +4597,7 @@ MaybeHandle<Object> Runtime::GetObjectProperty(Isolate* isolate,
Handle<Object> object,
Handle<Object> key) {
if (object->IsUndefined() || object->IsNull()) {
- Handle<Object> args[2] = { key, object };
+ Handle<Object> args[2] = {key, object};
THROW_NEW_ERROR(isolate, NewTypeError("non_object_property_load",
HandleVector(args, 2)),
Object);
@@ -4893,8 +4631,7 @@ RUNTIME_FUNCTION(Runtime_GetProperty) {
CONVERT_ARG_HANDLE_CHECKED(Object, key, 1);
Handle<Object> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result,
- Runtime::GetObjectProperty(isolate, object, key));
+ isolate, result, Runtime::GetObjectProperty(isolate, object, key));
return *result;
}
@@ -4920,8 +4657,7 @@ RUNTIME_FUNCTION(Runtime_KeyedGetProperty) {
// for objects that require access checks.
if (receiver_obj->IsJSObject()) {
if (!receiver_obj->IsJSGlobalProxy() &&
- !receiver_obj->IsAccessCheckNeeded() &&
- key_obj->IsName()) {
+ !receiver_obj->IsAccessCheckNeeded() && key_obj->IsName()) {
DisallowHeapAllocation no_allocation;
Handle<JSObject> receiver = Handle<JSObject>::cast(receiver_obj);
Handle<Name> key = Handle<Name>::cast(key_obj);
@@ -4945,7 +4681,7 @@ RUNTIME_FUNCTION(Runtime_KeyedGetProperty) {
// double values requires boxing.
if (!it.representation().IsDouble()) {
keyed_lookup_cache->Update(receiver_map, key,
- field_index.GetKeyedLookupCacheIndex());
+ field_index.GetKeyedLookupCacheIndex());
}
AllowHeapAllocation allow_allocation;
return *JSObject::FastPropertyAt(receiver, it.representation(),
@@ -5104,8 +4840,7 @@ RUNTIME_FUNCTION(Runtime_DefineDataPropertyUnchecked) {
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, result,
JSObject::SetOwnPropertyIgnoreAttributes(
- js_object, name, obj_value, attr,
- JSObject::DONT_FORCE_FIELD));
+ js_object, name, obj_value, attr, JSObject::DONT_FORCE_FIELD));
return *result;
}
@@ -5133,7 +4868,7 @@ MaybeHandle<Object> Runtime::SetObjectProperty(Isolate* isolate,
Handle<Object> value,
StrictMode strict_mode) {
if (object->IsUndefined() || object->IsNull()) {
- Handle<Object> args[2] = { key, object };
+ Handle<Object> args[2] = {key, object};
THROW_NEW_ERROR(isolate, NewTypeError("non_object_property_store",
HandleVector(args, 2)),
Object);
@@ -5144,8 +4879,8 @@ MaybeHandle<Object> Runtime::SetObjectProperty(Isolate* isolate,
if (key->IsSymbol()) {
name_object = key;
} else {
- ASSIGN_RETURN_ON_EXCEPTION(
- isolate, name_object, Execution::ToString(isolate, key), Object);
+ ASSIGN_RETURN_ON_EXCEPTION(isolate, name_object,
+ Execution::ToString(isolate, key), Object);
}
Handle<Name> name = Handle<Name>::cast(name_object);
return Object::SetProperty(Handle<JSProxy>::cast(object), name, value,
@@ -5174,8 +4909,8 @@ MaybeHandle<Object> Runtime::SetObjectProperty(Isolate* isolate,
if (js_object->HasExternalArrayElements() ||
js_object->HasFixedTypedArrayElements()) {
if (!value->IsNumber() && !value->IsUndefined()) {
- ASSIGN_RETURN_ON_EXCEPTION(
- isolate, value, Execution::ToNumber(isolate, value), Object);
+ ASSIGN_RETURN_ON_EXCEPTION(isolate, value,
+ Execution::ToNumber(isolate, value), Object);
}
}
@@ -5208,8 +4943,8 @@ MaybeHandle<Object> Runtime::SetObjectProperty(Isolate* isolate,
// Call-back into JavaScript to convert the key to a string.
Handle<Object> converted;
- ASSIGN_RETURN_ON_EXCEPTION(
- isolate, converted, Execution::ToString(isolate, key), Object);
+ ASSIGN_RETURN_ON_EXCEPTION(isolate, converted,
+ Execution::ToString(isolate, key), Object);
Handle<String> name = Handle<String>::cast(converted);
if (name->AsArrayIndex(&index)) {
@@ -5242,15 +4977,15 @@ MaybeHandle<Object> Runtime::DefineObjectProperty(Handle<JSObject> js_object,
return value;
}
- return JSObject::SetElement(js_object, index, value, attr,
- SLOPPY, false, DEFINE_PROPERTY);
+ return JSObject::SetElement(js_object, index, value, attr, SLOPPY, false,
+ DEFINE_PROPERTY);
}
if (key->IsName()) {
Handle<Name> name = Handle<Name>::cast(key);
if (name->AsArrayIndex(&index)) {
- return JSObject::SetElement(js_object, index, value, attr,
- SLOPPY, false, DEFINE_PROPERTY);
+ return JSObject::SetElement(js_object, index, value, attr, SLOPPY, false,
+ DEFINE_PROPERTY);
} else {
if (name->IsString()) name = String::Flatten(Handle<String>::cast(name));
return JSObject::SetOwnPropertyIgnoreAttributes(js_object, name, value,
@@ -5260,13 +4995,13 @@ MaybeHandle<Object> Runtime::DefineObjectProperty(Handle<JSObject> js_object,
// Call-back into JavaScript to convert the key to a string.
Handle<Object> converted;
- ASSIGN_RETURN_ON_EXCEPTION(
- isolate, converted, Execution::ToString(isolate, key), Object);
+ ASSIGN_RETURN_ON_EXCEPTION(isolate, converted,
+ Execution::ToString(isolate, key), Object);
Handle<String> name = Handle<String>::cast(converted);
if (name->AsArrayIndex(&index)) {
- return JSObject::SetElement(js_object, index, value, attr,
- SLOPPY, false, DEFINE_PROPERTY);
+ return JSObject::SetElement(js_object, index, value, attr, SLOPPY, false,
+ DEFINE_PROPERTY);
} else {
return JSObject::SetOwnPropertyIgnoreAttributes(js_object, name, value,
attr);
@@ -5300,8 +5035,8 @@ MaybeHandle<Object> Runtime::DeleteObjectProperty(Isolate* isolate,
} else {
// Call-back into JavaScript to convert the key to a string.
Handle<Object> converted;
- ASSIGN_RETURN_ON_EXCEPTION(
- isolate, converted, Execution::ToString(isolate, key), Object);
+ ASSIGN_RETURN_ON_EXCEPTION(isolate, converted,
+ Execution::ToString(isolate, key), Object);
name = Handle<String>::cast(converted);
}
@@ -5383,7 +5118,7 @@ RUNTIME_FUNCTION(Runtime_AddPropertyForTemplate) {
duplicate = maybe.value;
}
if (duplicate) {
- Handle<Object> args[1] = { key };
+ Handle<Object> args[1] = {key};
THROW_NEW_ERROR_RETURN_FAILURE(
isolate,
NewTypeError("duplicate_template_property", HandleVector(args, 1)));
@@ -5509,11 +5244,10 @@ RUNTIME_FUNCTION(Runtime_StoreArrayLiteralElement) {
if (value->IsNumber()) {
DCHECK(IsFastSmiElementsKind(elements_kind));
ElementsKind transitioned_kind = IsFastHoleyElementsKind(elements_kind)
- ? FAST_HOLEY_DOUBLE_ELEMENTS
- : FAST_DOUBLE_ELEMENTS;
+ ? FAST_HOLEY_DOUBLE_ELEMENTS
+ : FAST_DOUBLE_ELEMENTS;
if (IsMoreGeneralElementsKindTransition(
- boilerplate_object->GetElementsKind(),
- transitioned_kind)) {
+ boilerplate_object->GetElementsKind(), transitioned_kind)) {
JSObject::TransitionElementsKind(boilerplate_object, transitioned_kind);
}
JSObject::TransitionElementsKind(object, transitioned_kind);
@@ -5524,8 +5258,8 @@ RUNTIME_FUNCTION(Runtime_StoreArrayLiteralElement) {
} else {
if (!IsFastObjectElementsKind(elements_kind)) {
ElementsKind transitioned_kind = IsFastHoleyElementsKind(elements_kind)
- ? FAST_HOLEY_ELEMENTS
- : FAST_ELEMENTS;
+ ? FAST_HOLEY_ELEMENTS
+ : FAST_ELEMENTS;
JSObject::TransitionElementsKind(object, transitioned_kind);
ElementsKind boilerplate_elements_kind =
boilerplate_object->GetElementsKind();
@@ -5550,8 +5284,8 @@ RUNTIME_FUNCTION(Runtime_DebugCallbackSupportsStepping) {
}
CONVERT_ARG_CHECKED(Object, callback, 0);
// We do not step into the callback if it's a builtin or not even a function.
- return isolate->heap()->ToBoolean(
- callback->IsJSFunction() && !JSFunction::cast(callback)->IsBuiltin());
+ return isolate->heap()->ToBoolean(callback->IsJSFunction() &&
+ !JSFunction::cast(callback)->IsBuiltin());
}
@@ -5633,11 +5367,11 @@ RUNTIME_FUNCTION(Runtime_DeleteProperty) {
CONVERT_ARG_HANDLE_CHECKED(Name, key, 1);
CONVERT_STRICT_MODE_ARG_CHECKED(strict_mode, 2);
JSReceiver::DeleteMode delete_mode = strict_mode == STRICT
- ? JSReceiver::STRICT_DELETION : JSReceiver::NORMAL_DELETION;
+ ? JSReceiver::STRICT_DELETION
+ : JSReceiver::NORMAL_DELETION;
Handle<Object> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result,
- JSReceiver::DeleteProperty(object, key, delete_mode));
+ isolate, result, JSReceiver::DeleteProperty(object, key, delete_mode));
return *result;
}
@@ -5689,14 +5423,12 @@ RUNTIME_FUNCTION(Runtime_HasOwnProperty) {
return isolate->heap()->true_value();
}
Map* map = js_obj->map();
- if (!key_is_array_index &&
- !map->has_named_interceptor() &&
+ if (!key_is_array_index && !map->has_named_interceptor() &&
!HeapObject::cast(map->prototype())->map()->is_hidden_prototype()) {
return isolate->heap()->false_value();
}
// Slow case.
- return HasOwnPropertyImplementation(isolate,
- Handle<JSObject>(js_obj),
+ return HasOwnPropertyImplementation(isolate, Handle<JSObject>(js_obj),
Handle<Name>(key));
} else if (object->IsString() && key_is_array_index) {
// Well, there is one exception: Handle [] on strings.
@@ -5821,8 +5553,8 @@ RUNTIME_FUNCTION(Runtime_GetOwnPropertyNames) {
if (obj->IsJSGlobalProxy()) {
// Only collect names if access is permitted.
if (obj->IsAccessCheckNeeded() &&
- !isolate->MayNamedAccess(
- obj, isolate->factory()->undefined_value(), v8::ACCESS_KEYS)) {
+ !isolate->MayNamedAccess(obj, isolate->factory()->undefined_value(),
+ v8::ACCESS_KEYS)) {
isolate->ReportFailedAccessCheck(obj, v8::ACCESS_KEYS);
RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate);
return *isolate->factory()->NewJSArray(0);
@@ -5907,8 +5639,7 @@ RUNTIME_FUNCTION(Runtime_GetOwnPropertyNames) {
// hidden prototype duplicates.
if (hidden_strings > 0) {
Handle<FixedArray> old_names = names;
- names = isolate->factory()->NewFixedArray(
- names->length() - hidden_strings);
+ names = isolate->factory()->NewFixedArray(names->length() - hidden_strings);
int dest_pos = 0;
for (int i = 0; i < total_property_count; i++) {
Object* name = old_names->get(i);
@@ -6003,8 +5734,8 @@ RUNTIME_FUNCTION(Runtime_OwnKeys) {
if (object->IsJSGlobalProxy()) {
// Do access checks before going to the global object.
if (object->IsAccessCheckNeeded() &&
- !isolate->MayNamedAccess(
- object, isolate->factory()->undefined_value(), v8::ACCESS_KEYS)) {
+ !isolate->MayNamedAccess(object, isolate->factory()->undefined_value(),
+ v8::ACCESS_KEYS)) {
isolate->ReportFailedAccessCheck(object, v8::ACCESS_KEYS);
RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate);
return *isolate->factory()->NewJSArray(0);
@@ -6018,8 +5749,7 @@ RUNTIME_FUNCTION(Runtime_OwnKeys) {
Handle<FixedArray> contents;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, contents,
- JSReceiver::GetKeys(object, JSReceiver::OWN_ONLY));
+ isolate, contents, JSReceiver::GetKeys(object, JSReceiver::OWN_ONLY));
// Some fast paths through GetKeysInFixedArrayFor reuse a cached
// property array and since the result is mutable we have to create
@@ -6080,8 +5810,8 @@ RUNTIME_FUNCTION(Runtime_GetArgumentsProperty) {
// Convert the key to a string.
Handle<Object> converted;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, converted, Execution::ToString(isolate, raw_key));
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, converted,
+ Execution::ToString(isolate, raw_key));
Handle<String> key = Handle<String>::cast(converted);
// Try to convert the string key into an array index.
@@ -6212,7 +5942,7 @@ RUNTIME_FUNCTION(Runtime_Booleanize) {
}
-static bool AreDigits(const uint8_t*s, int from, int to) {
+static bool AreDigits(const uint8_t* s, int from, int to) {
for (int i = from; i < to; i++) {
if (s[i] < '0' || s[i] > '9') return false;
}
@@ -6221,7 +5951,7 @@ static bool AreDigits(const uint8_t*s, int from, int to) {
}
-static int ParseDecimalInteger(const uint8_t*s, int from, int to) {
+static int ParseDecimalInteger(const uint8_t* s, int from, int to) {
DCHECK(to - from < 10); // Overflow is not possible.
DCHECK(from < to);
int d = s[from] - '0';
@@ -6267,8 +5997,7 @@ RUNTIME_FUNCTION(Runtime_StringToNumber) {
if (minus) {
if (d == 0) return isolate->heap()->minus_zero_value();
d = -d;
- } else if (!subject->HasHashCode() &&
- len <= String::kMaxArrayIndexSize &&
+ } else if (!subject->HasHashCode() && len <= String::kMaxArrayIndexSize &&
(len == 1 || data[0] != '0')) {
// String hash is not calculated yet but all the data are present.
// Update the hash field to speed up sequential convertions.
@@ -6292,8 +6021,8 @@ RUNTIME_FUNCTION(Runtime_StringToNumber) {
flags |= ALLOW_OCTAL | ALLOW_BINARY;
}
- return *isolate->factory()->NewNumber(StringToDouble(
- isolate->unicode_cache(), *subject, flags));
+ return *isolate->factory()->NewNumber(
+ StringToDouble(isolate->unicode_cache(), *subject, flags));
}
@@ -6333,10 +6062,9 @@ RUNTIME_FUNCTION(Runtime_URIEscape) {
DCHECK(string->IsFlat());
Handle<String> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result,
- string->IsOneByteRepresentationUnderneath()
- ? URIEscape::Escape<uint8_t>(isolate, source)
- : URIEscape::Escape<uc16>(isolate, source));
+ isolate, result, string->IsOneByteRepresentationUnderneath()
+ ? URIEscape::Escape<uint8_t>(isolate, source)
+ : URIEscape::Escape<uc16>(isolate, source));
return *result;
}
@@ -6349,10 +6077,9 @@ RUNTIME_FUNCTION(Runtime_URIUnescape) {
DCHECK(string->IsFlat());
Handle<String> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result,
- string->IsOneByteRepresentationUnderneath()
- ? URIUnescape::Unescape<uint8_t>(isolate, source)
- : URIUnescape::Unescape<uc16>(isolate, source));
+ isolate, result, string->IsOneByteRepresentationUnderneath()
+ ? URIUnescape::Unescape<uint8_t>(isolate, source)
+ : URIUnescape::Unescape<uc16>(isolate, source));
return *result;
}
@@ -6374,8 +6101,8 @@ RUNTIME_FUNCTION(Runtime_BasicJSONStringify) {
CONVERT_ARG_HANDLE_CHECKED(Object, object, 0);
BasicJsonStringifier stringifier(isolate);
Handle<Object> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result, stringifier.Stringify(object));
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result,
+ stringifier.Stringify(object));
return *result;
}
@@ -6390,16 +6117,16 @@ RUNTIME_FUNCTION(Runtime_StringParseInt) {
subject = String::Flatten(subject);
double value;
- { DisallowHeapAllocation no_gc;
+ {
+ DisallowHeapAllocation no_gc;
String::FlatContent flat = subject->GetFlatContent();
// ECMA-262 section 15.1.2.3, empty string is NaN
if (flat.IsOneByte()) {
- value = StringToInt(
- isolate->unicode_cache(), flat.ToOneByteVector(), radix);
+ value =
+ StringToInt(isolate->unicode_cache(), flat.ToOneByteVector(), radix);
} else {
- value = StringToInt(
- isolate->unicode_cache(), flat.ToUC16Vector(), radix);
+ value = StringToInt(isolate->unicode_cache(), flat.ToUC16Vector(), radix);
}
}
@@ -6431,10 +6158,7 @@ static inline bool ToUpperOverflows(uc32 character) {
template <class Converter>
MUST_USE_RESULT static Object* ConvertCaseHelper(
- Isolate* isolate,
- String* string,
- SeqString* result,
- int result_length,
+ Isolate* isolate, String* string, SeqString* result, int result_length,
unibrow::Mapping<Converter, 128>* mapping) {
DisallowHeapAllocation no_gc;
// We try this twice, once with the assumption that the result is no longer
@@ -6450,8 +6174,7 @@ MUST_USE_RESULT static Object* ConvertCaseHelper(
// Convert all characters to upper case, assuming that they will fit
// in the buffer
- Access<ConsStringIteratorOp> op(
- isolate->runtime_state()->string_iterator());
+ Access<ConsStringIteratorOp> op(isolate->runtime_state()->string_iterator());
StringCharacterStream stream(string, op.value());
unibrow::uchar chars[Converter::kMaxWidth];
// We can assume that the string is not empty
@@ -6557,11 +6280,8 @@ static inline uintptr_t AsciiRangeMask(uintptr_t w, char m, char n) {
#ifdef DEBUG
-static bool CheckFastAsciiConvert(char* dst,
- const char* src,
- int length,
- bool changed,
- bool is_to_lower) {
+static bool CheckFastAsciiConvert(char* dst, const char* src, int length,
+ bool changed, bool is_to_lower) {
bool expected_changed = false;
for (int i = 0; i < length; i++) {
if (dst[i] == src[i]) continue;
@@ -6579,14 +6299,12 @@ static bool CheckFastAsciiConvert(char* dst,
#endif
-template<class Converter>
-static bool FastAsciiConvert(char* dst,
- const char* src,
- int length,
+template <class Converter>
+static bool FastAsciiConvert(char* dst, const char* src, int length,
bool* changed_out) {
#ifdef DEBUG
- char* saved_dst = dst;
- const char* saved_src = src;
+ char* saved_dst = dst;
+ const char* saved_src = src;
#endif
DisallowHeapAllocation no_gc;
// We rely on the distance between upper and lower case letters
@@ -6646,8 +6364,8 @@ static bool FastAsciiConvert(char* dst,
if ((or_acc & kAsciiMask) != 0) return false;
- DCHECK(CheckFastAsciiConvert(
- saved_dst, saved_src, length, changed, Converter::kIsToLower));
+ DCHECK(CheckFastAsciiConvert(saved_dst, saved_src, length, changed,
+ Converter::kIsToLower));
*changed_out = changed;
return true;
@@ -6658,8 +6376,7 @@ static bool FastAsciiConvert(char* dst,
template <class Converter>
MUST_USE_RESULT static Object* ConvertCase(
- Handle<String> s,
- Isolate* isolate,
+ Handle<String> s, Isolate* isolate,
unibrow::Mapping<Converter, 128>* mapping) {
s = String::Flatten(s);
int length = s->length();
@@ -6683,8 +6400,7 @@ MUST_USE_RESULT static Object* ConvertCase(
bool is_ascii = FastAsciiConvert<Converter>(
reinterpret_cast<char*>(result->GetChars()),
reinterpret_cast<const char*>(flat_content.ToOneByteVector().start()),
- length,
- &has_changed_character);
+ length, &has_changed_character);
// If not ASCII, we discard the result and take the 2 byte path.
if (is_ascii) return has_changed_character ? *result : *s;
}
@@ -6717,8 +6433,7 @@ RUNTIME_FUNCTION(Runtime_StringToLowerCase) {
HandleScope scope(isolate);
DCHECK(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(String, s, 0);
- return ConvertCase(
- s, isolate, isolate->runtime_state()->to_lower_mapping());
+ return ConvertCase(s, isolate, isolate->runtime_state()->to_lower_mapping());
}
@@ -6726,8 +6441,7 @@ RUNTIME_FUNCTION(Runtime_StringToUpperCase) {
HandleScope scope(isolate);
DCHECK(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(String, s, 0);
- return ConvertCase(
- s, isolate, isolate->runtime_state()->to_upper_mapping());
+ return ConvertCase(s, isolate, isolate->runtime_state()->to_upper_mapping());
}
@@ -6753,9 +6467,9 @@ RUNTIME_FUNCTION(Runtime_StringTrim) {
int right = length;
if (trimRight) {
- while (right > left &&
- unicode_cache->IsWhiteSpaceOrLineTerminator(
- string->Get(right - 1))) {
+ while (
+ right > left &&
+ unicode_cache->IsWhiteSpaceOrLineTerminator(string->Get(right - 1))) {
right--;
}
}
@@ -6778,16 +6492,13 @@ RUNTIME_FUNCTION(Runtime_StringSplit) {
if (limit == 0xffffffffu) {
Handle<Object> cached_answer(
- RegExpResultsCache::Lookup(isolate->heap(),
- *subject,
- *pattern,
+ RegExpResultsCache::Lookup(isolate->heap(), *subject, *pattern,
RegExpResultsCache::STRING_SPLIT_SUBSTRINGS),
isolate);
if (*cached_answer != Smi::FromInt(0)) {
// The cache FixedArray is a COW-array and can therefore be reused.
- Handle<JSArray> result =
- isolate->factory()->NewJSArrayWithElements(
- Handle<FixedArray>::cast(cached_answer));
+ Handle<JSArray> result = isolate->factory()->NewJSArrayWithElements(
+ Handle<FixedArray>::cast(cached_answer));
return *result;
}
}
@@ -6807,8 +6518,8 @@ RUNTIME_FUNCTION(Runtime_StringSplit) {
int initial_capacity = Min<uint32_t>(kMaxInitialListCapacity, limit);
ZoneList<int> indices(initial_capacity, zone_scope.zone());
- FindStringIndicesDispatch(isolate, *subject, *pattern,
- &indices, limit, zone_scope.zone());
+ FindStringIndicesDispatch(isolate, *subject, *pattern, &indices, limit,
+ zone_scope.zone());
if (static_cast<uint32_t>(indices.length()) < limit) {
indices.Add(subject_length, zone_scope.zone());
@@ -6843,10 +6554,7 @@ RUNTIME_FUNCTION(Runtime_StringSplit) {
if (limit == 0xffffffffu) {
if (result->HasFastObjectElements()) {
- RegExpResultsCache::Enter(isolate,
- subject,
- pattern,
- elements,
+ RegExpResultsCache::Enter(isolate, subject, pattern, elements,
RegExpResultsCache::STRING_SPLIT_SUBSTRINGS);
}
}
@@ -6912,8 +6620,7 @@ RUNTIME_FUNCTION(Runtime_StringToArray) {
position = CopyCachedOneByteCharsToArray(isolate->heap(), chars.start(),
*elements, length);
} else {
- MemsetPointer(elements->data_start(),
- isolate->heap()->undefined_value(),
+ MemsetPointer(elements->data_start(), isolate->heap()->undefined_value(),
length);
}
} else {
@@ -7121,8 +6828,7 @@ RUNTIME_FUNCTION(Runtime_StringAdd) {
template <typename sinkchar>
-static inline void StringBuilderConcatHelper(String* special,
- sinkchar* sink,
+static inline void StringBuilderConcatHelper(String* special, sinkchar* sink,
FixedArray* fixed_array,
int array_length) {
DisallowHeapAllocation no_gc;
@@ -7145,10 +6851,7 @@ static inline void StringBuilderConcatHelper(String* special,
pos = Smi::cast(obj)->value();
len = -encoded_slice;
}
- String::WriteToFlat(special,
- sink + position,
- pos,
- pos + len);
+ String::WriteToFlat(special, sink + position, pos, pos + len);
position += len;
} else {
String* string = String::cast(element);
@@ -7164,8 +6867,7 @@ static inline void StringBuilderConcatHelper(String* special,
// On illegal argument, -1 is returned.
static inline int StringBuilderConcatLength(int special_length,
FixedArray* fixed_array,
- int array_length,
- bool* one_byte) {
+ int array_length, bool* one_byte) {
DisallowHeapAllocation no_gc;
int position = 0;
for (int i = 0; i < array_length; i++) {
@@ -7244,7 +6946,8 @@ RUNTIME_FUNCTION(Runtime_StringBuilderConcat) {
int length;
bool one_byte = special->HasOnlyOneByteChars();
- { DisallowHeapAllocation no_gc;
+ {
+ DisallowHeapAllocation no_gc;
FixedArray* fixed_array = FixedArray::cast(array->elements());
if (fixed_array->length() < array_length) {
array_length = fixed_array->length();
@@ -7256,8 +6959,8 @@ RUNTIME_FUNCTION(Runtime_StringBuilderConcat) {
Object* first = fixed_array->get(0);
if (first->IsString()) return first;
}
- length = StringBuilderConcatLength(
- special_length, fixed_array, array_length, &one_byte);
+ length = StringBuilderConcatLength(special_length, fixed_array,
+ array_length, &one_byte);
}
if (length == -1) {
@@ -7267,20 +6970,16 @@ RUNTIME_FUNCTION(Runtime_StringBuilderConcat) {
if (one_byte) {
Handle<SeqOneByteString> answer;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, answer,
- isolate->factory()->NewRawOneByteString(length));
- StringBuilderConcatHelper(*special,
- answer->GetChars(),
+ isolate, answer, isolate->factory()->NewRawOneByteString(length));
+ StringBuilderConcatHelper(*special, answer->GetChars(),
FixedArray::cast(array->elements()),
array_length);
return *answer;
} else {
Handle<SeqTwoByteString> answer;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, answer,
- isolate->factory()->NewRawTwoByteString(length));
- StringBuilderConcatHelper(*special,
- answer->GetChars(),
+ isolate, answer, isolate->factory()->NewRawTwoByteString(length));
+ StringBuilderConcatHelper(*special, answer->GetChars(),
FixedArray::cast(array->elements()),
array_length);
return *answer;
@@ -7336,8 +7035,7 @@ RUNTIME_FUNCTION(Runtime_StringBuilderJoin) {
Handle<SeqTwoByteString> answer;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, answer,
- isolate->factory()->NewRawTwoByteString(length));
+ isolate, answer, isolate->factory()->NewRawTwoByteString(length));
DisallowHeapAllocation no_gc;
@@ -7388,13 +7086,12 @@ static void JoinSparseArrayWithSeparator(FixedArray* elements,
int string_length = string->length();
if (string->length() > 0) {
while (previous_separator_position < position) {
- String::WriteToFlat<Char>(separator, &buffer[cursor],
- 0, separator_length);
+ String::WriteToFlat<Char>(separator, &buffer[cursor], 0,
+ separator_length);
cursor += separator_length;
previous_separator_position++;
}
- String::WriteToFlat<Char>(string, &buffer[cursor],
- 0, string_length);
+ String::WriteToFlat<Char>(string, &buffer[cursor], 0, string_length);
cursor += string->length();
}
}
@@ -7404,8 +7101,8 @@ static void JoinSparseArrayWithSeparator(FixedArray* elements,
DCHECK(array_length <= 0x7fffffff); // Is int32_t.
int last_array_index = static_cast<int>(array_length - 1);
while (previous_separator_position < last_array_index) {
- String::WriteToFlat<Char>(separator, &buffer[cursor],
- 0, separator_length);
+ String::WriteToFlat<Char>(separator, &buffer[cursor], 0,
+ separator_length);
cursor += separator_length;
previous_separator_position++;
}
@@ -7442,7 +7139,8 @@ RUNTIME_FUNCTION(Runtime_SparseJoinWithSeparator) {
RUNTIME_ASSERT(elements->get(i + 1)->IsString());
}
- { DisallowHeapAllocation no_gc;
+ {
+ DisallowHeapAllocation no_gc;
for (int i = 0; i < elements_length; i += 2) {
String* string = String::cast(elements->get(i + 1));
int length = string->length();
@@ -7484,23 +7182,21 @@ RUNTIME_FUNCTION(Runtime_SparseJoinWithSeparator) {
}
if (is_one_byte) {
- Handle<SeqOneByteString> result = isolate->factory()->NewRawOneByteString(
- string_length).ToHandleChecked();
+ Handle<SeqOneByteString> result = isolate->factory()
+ ->NewRawOneByteString(string_length)
+ .ToHandleChecked();
JoinSparseArrayWithSeparator<uint8_t>(
- FixedArray::cast(elements_array->elements()),
- elements_length,
- array_length,
- *separator,
+ FixedArray::cast(elements_array->elements()), elements_length,
+ array_length, *separator,
Vector<uint8_t>(result->GetChars(), string_length));
return *result;
} else {
- Handle<SeqTwoByteString> result = isolate->factory()->NewRawTwoByteString(
- string_length).ToHandleChecked();
+ Handle<SeqTwoByteString> result = isolate->factory()
+ ->NewRawTwoByteString(string_length)
+ .ToHandleChecked();
JoinSparseArrayWithSeparator<uc16>(
- FixedArray::cast(elements_array->elements()),
- elements_length,
- array_length,
- *separator,
+ FixedArray::cast(elements_array->elements()), elements_length,
+ array_length, *separator,
Vector<uc16>(result->GetChars(), string_length));
return *result;
}
@@ -7651,10 +7347,9 @@ RUNTIME_FUNCTION(Runtime_SmiLexicographicCompare) {
}
static const uint32_t kPowersOf10[] = {
- 1, 10, 100, 1000, 10*1000, 100*1000,
- 1000*1000, 10*1000*1000, 100*1000*1000,
- 1000*1000*1000
- };
+ 1, 10, 100, 1000,
+ 10 * 1000, 100 * 1000, 1000 * 1000, 10 * 1000 * 1000,
+ 100 * 1000 * 1000, 1000 * 1000 * 1000};
// If the integers have the same number of decimal digits they can be
// compared directly as the numeric order is the same as the
@@ -7715,8 +7410,10 @@ RUNTIME_FUNCTION(Runtime_StringCompare) {
}
int d = x->Get(0) - y->Get(0);
- if (d < 0) return Smi::FromInt(LESS);
- else if (d > 0) return Smi::FromInt(GREATER);
+ if (d < 0)
+ return Smi::FromInt(LESS);
+ else if (d > 0)
+ return Smi::FromInt(GREATER);
// Slow case.
x = String::Flatten(x);
@@ -7763,14 +7460,14 @@ RUNTIME_FUNCTION(Runtime_StringCompare) {
}
-#define RUNTIME_UNARY_MATH(Name, name) \
-RUNTIME_FUNCTION(Runtime_Math##Name) { \
- HandleScope scope(isolate); \
- DCHECK(args.length() == 1); \
- isolate->counters()->math_##name()->Increment(); \
- CONVERT_DOUBLE_ARG_CHECKED(x, 0); \
- return *isolate->factory()->NewHeapNumber(std::name(x)); \
-}
+#define RUNTIME_UNARY_MATH(Name, name) \
+ RUNTIME_FUNCTION(Runtime_Math##Name) { \
+ HandleScope scope(isolate); \
+ DCHECK(args.length() == 1); \
+ isolate->counters()->math_##name()->Increment(); \
+ CONVERT_DOUBLE_ARG_CHECKED(x, 0); \
+ return *isolate->factory()->NewHeapNumber(std::name(x)); \
+ }
RUNTIME_UNARY_MATH(Acos, acos)
RUNTIME_UNARY_MATH(Asin, asin)
@@ -8000,23 +7697,22 @@ RUNTIME_FUNCTION(Runtime_DateSetValue) {
DateCache* date_cache = isolate->date_cache();
- Handle<Object> value;;
+ Handle<Object> value;
+ ;
bool is_value_nan = false;
if (std::isnan(time)) {
value = isolate->factory()->nan_value();
is_value_nan = true;
- } else if (!is_utc &&
- (time < -DateCache::kMaxTimeBeforeUTCInMs ||
- time > DateCache::kMaxTimeBeforeUTCInMs)) {
+ } else if (!is_utc && (time < -DateCache::kMaxTimeBeforeUTCInMs ||
+ time > DateCache::kMaxTimeBeforeUTCInMs)) {
value = isolate->factory()->nan_value();
is_value_nan = true;
} else {
time = is_utc ? time : date_cache->ToUTC(static_cast<int64_t>(time));
- if (time < -DateCache::kMaxTimeInMs ||
- time > DateCache::kMaxTimeInMs) {
+ if (time < -DateCache::kMaxTimeInMs || time > DateCache::kMaxTimeInMs) {
value = isolate->factory()->nan_value();
is_value_nan = true;
- } else {
+ } else {
value = isolate->factory()->NewNumber(DoubleToInteger(time));
}
}
@@ -8039,8 +7735,7 @@ static Handle<JSObject> NewSloppyArguments(Isolate* isolate,
int mapped_count = Min(argument_count, parameter_count);
Handle<FixedArray> parameter_map =
isolate->factory()->NewFixedArray(mapped_count + 2, NOT_TENURED);
- parameter_map->set_map(
- isolate->heap()->sloppy_arguments_elements_map());
+ parameter_map->set_map(isolate->heap()->sloppy_arguments_elements_map());
Handle<Map> map = Map::Copy(handle(result->map()));
map->set_elements_kind(SLOPPY_ARGUMENTS_ELEMENTS);
@@ -8095,8 +7790,9 @@ static Handle<JSObject> NewSloppyArguments(Isolate* isolate,
}
DCHECK(context_index >= 0);
arguments->set_the_hole(index);
- parameter_map->set(index + 2, Smi::FromInt(
- Context::MIN_CONTEXT_SLOTS + context_index));
+ parameter_map->set(
+ index + 2,
+ Smi::FromInt(Context::MIN_CONTEXT_SLOTS + context_index));
}
--index;
@@ -8197,18 +7893,17 @@ RUNTIME_FUNCTION(Runtime_NewClosure) {
// The caller ensures that we pretenure closures that are assigned
// directly to properties.
PretenureFlag pretenure_flag = pretenure ? TENURED : NOT_TENURED;
- return *isolate->factory()->NewFunctionFromSharedFunctionInfo(
- shared, context, pretenure_flag);
+ return *isolate->factory()->NewFunctionFromSharedFunctionInfo(shared, context,
+ pretenure_flag);
}
// Find the arguments of the JavaScript function invocation that called
// into C++ code. Collect these in a newly allocated array of handles (possibly
// prefixed by a number of empty handles).
-static SmartArrayPointer<Handle<Object> > GetCallerArguments(
- Isolate* isolate,
- int prefix_argc,
- int* total_argc) {
+static SmartArrayPointer<Handle<Object> > GetCallerArguments(Isolate* isolate,
+ int prefix_argc,
+ int* total_argc) {
// Find frame containing arguments passed to the caller.
JavaScriptFrameIterator it(isolate);
JavaScriptFrame* frame = it.frame();
@@ -8218,8 +7913,7 @@ static SmartArrayPointer<Handle<Object> > GetCallerArguments(
int inlined_jsframe_index = functions.length() - 1;
JSFunction* inlined_function = functions[inlined_jsframe_index];
SlotRefValueBuilder slot_refs(
- frame,
- inlined_jsframe_index,
+ frame, inlined_jsframe_index,
inlined_function->shared()->formal_parameter_count());
int args_count = slot_refs.args_length();
@@ -8314,9 +8008,8 @@ RUNTIME_FUNCTION(Runtime_FunctionBindArguments) {
PropertyAttributes attr =
static_cast<PropertyAttributes>(DONT_DELETE | DONT_ENUM | READ_ONLY);
RETURN_FAILURE_ON_EXCEPTION(
- isolate,
- JSObject::SetOwnPropertyIgnoreAttributes(
- bound_function, length_string, new_length, attr));
+ isolate, JSObject::SetOwnPropertyIgnoreAttributes(
+ bound_function, length_string, new_length, attr));
return *bound_function;
}
@@ -8359,8 +8052,8 @@ RUNTIME_FUNCTION(Runtime_NewObjectFromBound) {
SmartArrayPointer<Handle<Object> > param_data =
GetCallerArguments(isolate, bound_argc, &total_argc);
for (int i = 0; i < bound_argc; i++) {
- param_data[i] = Handle<Object>(bound_args->get(
- JSFunction::kBoundArgumentsStartIndex + i), isolate);
+ param_data[i] = Handle<Object>(
+ bound_args->get(JSFunction::kBoundArgumentsStartIndex + i), isolate);
}
if (!bound_function->IsJSFunction()) {
@@ -8372,19 +8065,18 @@ RUNTIME_FUNCTION(Runtime_NewObjectFromBound) {
Handle<Object> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result,
- Execution::New(Handle<JSFunction>::cast(bound_function),
- total_argc, param_data.get()));
+ isolate, result, Execution::New(Handle<JSFunction>::cast(bound_function),
+ total_argc, param_data.get()));
return *result;
}
static Object* Runtime_NewObjectHelper(Isolate* isolate,
- Handle<Object> constructor,
- Handle<AllocationSite> site) {
+ Handle<Object> constructor,
+ Handle<AllocationSite> site) {
// If the constructor isn't a proper function we throw a type error.
if (!constructor->IsJSFunction()) {
- Vector< Handle<Object> > arguments = HandleVector(&constructor, 1);
+ Vector<Handle<Object> > arguments = HandleVector(&constructor, 1);
THROW_NEW_ERROR_RETURN_FAILURE(isolate,
NewTypeError("not_constructor", arguments));
}
@@ -8394,7 +8086,7 @@ static Object* Runtime_NewObjectHelper(Isolate* isolate,
// If function should not have prototype, construction is not allowed. In this
// case generated code bailouts here, since function has no initial_map.
if (!function->should_have_prototype() && !function->shared()->bound()) {
- Vector< Handle<Object> > arguments = HandleVector(&constructor, 1);
+ Vector<Handle<Object> > arguments = HandleVector(&constructor, 1);
THROW_NEW_ERROR_RETURN_FAILURE(isolate,
NewTypeError("not_constructor", arguments));
}
@@ -8444,8 +8136,7 @@ RUNTIME_FUNCTION(Runtime_NewObject) {
HandleScope scope(isolate);
DCHECK(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(Object, constructor, 0);
- return Runtime_NewObjectHelper(isolate,
- constructor,
+ return Runtime_NewObjectHelper(isolate, constructor,
Handle<AllocationSite>::null());
}
@@ -8516,8 +8207,8 @@ RUNTIME_FUNCTION(Runtime_CompileOptimized) {
PrintF("[failed to optimize ");
function->PrintName();
PrintF(": is code optimizable: %s, is debugger enabled: %s]\n",
- function->shared()->optimization_disabled() ? "F" : "T",
- isolate->DebuggerHasBreakPoints() ? "T" : "F");
+ function->shared()->optimization_disabled() ? "F" : "T",
+ isolate->DebuggerHasBreakPoints() ? "T" : "F");
}
function->ReplaceCode(*unoptimized);
return function->code();
@@ -8545,8 +8236,7 @@ class ActivationsFinder : public ThreadVisitor {
bool has_code_activations_;
explicit ActivationsFinder(Code* code)
- : code_(code),
- has_code_activations_(false) { }
+ : code_(code), has_code_activations_(false) {}
void VisitThread(Isolate* isolate, ThreadLocalTop* top) {
JavaScriptFrameIterator it(isolate, top);
@@ -8697,8 +8387,7 @@ RUNTIME_FUNCTION(Runtime_OptimizeFunctionOnNextCall) {
function->MarkForOptimization();
Code* unoptimized = function->shared()->code();
- if (args.length() == 2 &&
- unoptimized->kind() == Code::FUNCTION) {
+ if (args.length() == 2 && unoptimized->kind() == Code::FUNCTION) {
CONVERT_ARG_HANDLE_CHECKED(String, type, 1);
if (type->IsOneByteEqualTo(STATIC_CHAR_VECTOR("osr")) && FLAG_use_osr) {
// Start patching from the currently patched loop nesting level.
@@ -8819,8 +8508,8 @@ RUNTIME_FUNCTION(Runtime_CompileForOnStackReplacement) {
caller_code = Handle<Code>(frame->LookupCode());
}
- uint32_t pc_offset = static_cast<uint32_t>(
- frame->pc() - caller_code->instruction_start());
+ uint32_t pc_offset =
+ static_cast<uint32_t>(frame->pc() - caller_code->instruction_start());
#ifdef DEBUG
DCHECK_EQ(frame->function(), *function);
@@ -8834,8 +8523,9 @@ RUNTIME_FUNCTION(Runtime_CompileForOnStackReplacement) {
Compiler::ConcurrencyMode mode =
isolate->concurrent_osr_enabled() &&
- (function->shared()->ast_node_count() > 512) ? Compiler::CONCURRENT
- : Compiler::NOT_CONCURRENT;
+ (function->shared()->ast_node_count() > 512)
+ ? Compiler::CONCURRENT
+ : Compiler::NOT_CONCURRENT;
Handle<Code> result = Handle<Code>::null();
OptimizedCompileJob* job = NULL;
@@ -8869,8 +8559,8 @@ RUNTIME_FUNCTION(Runtime_CompileForOnStackReplacement) {
function->PrintName();
PrintF(" at AST id %d]\n", ast_id.ToInt());
}
- MaybeHandle<Code> maybe_result = Compiler::GetOptimizedCode(
- function, caller_code, mode, ast_id);
+ MaybeHandle<Code> maybe_result =
+ Compiler::GetOptimizedCode(function, caller_code, mode, ast_id);
if (maybe_result.ToHandle(&result) &&
result.is_identical_to(isolate->builtins()->InOptimizationQueue())) {
// Optimization is queued. Return to check later.
@@ -8973,7 +8663,7 @@ RUNTIME_FUNCTION(Runtime_Call) {
}
for (int i = 0; i < argc; ++i) {
- argv[i] = Handle<Object>(args[1 + i], isolate);
+ argv[i] = Handle<Object>(args[1 + i], isolate);
}
Handle<JSReceiver> hfun(fun);
@@ -9013,8 +8703,7 @@ RUNTIME_FUNCTION(Runtime_Apply) {
for (int i = 0; i < argc; ++i) {
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, argv[i],
- Object::GetElement(isolate, arguments, offset + i));
+ isolate, argv[i], Object::GetElement(isolate, arguments, offset + i));
}
Handle<Object> result;
@@ -9099,8 +8788,8 @@ RUNTIME_FUNCTION(Runtime_PushWithContext) {
}
Handle<Context> current(isolate->context());
- Handle<Context> context = isolate->factory()->NewWithContext(
- function, current, extension_object);
+ Handle<Context> context =
+ isolate->factory()->NewWithContext(function, current, extension_object);
isolate->set_context(*context);
return *context;
}
@@ -9142,8 +8831,8 @@ RUNTIME_FUNCTION(Runtime_PushBlockContext) {
function = args.at<JSFunction>(1);
}
Handle<Context> current(isolate->context());
- Handle<Context> context = isolate->factory()->NewBlockContext(
- function, current, scope_info);
+ Handle<Context> context =
+ isolate->factory()->NewBlockContext(function, current, scope_info);
isolate->set_context(*context);
return *context;
}
@@ -9258,11 +8947,8 @@ RUNTIME_FUNCTION(Runtime_DeleteLookupSlot) {
PropertyAttributes attributes;
ContextLookupFlags flags = FOLLOW_CHAINS;
BindingFlags binding_flags;
- Handle<Object> holder = context->Lookup(name,
- flags,
- &index,
- &attributes,
- &binding_flags);
+ Handle<Object> holder =
+ context->Lookup(name, flags, &index, &attributes, &binding_flags);
// If the slot was not found the result is true.
if (holder.is_null()) {
@@ -9279,69 +8965,13 @@ RUNTIME_FUNCTION(Runtime_DeleteLookupSlot) {
// (respecting DONT_DELETE).
Handle<JSObject> object = Handle<JSObject>::cast(holder);
Handle<Object> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result,
- JSReceiver::DeleteProperty(object, name));
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result,
+ JSReceiver::DeleteProperty(object, name));
return *result;
}
-// A mechanism to return a pair of Object pointers in registers (if possible).
-// How this is achieved is calling convention-dependent.
-// All currently supported x86 compiles uses calling conventions that are cdecl
-// variants where a 64-bit value is returned in two 32-bit registers
-// (edx:eax on ia32, r1:r0 on ARM).
-// In AMD-64 calling convention a struct of two pointers is returned in rdx:rax.
-// In Win64 calling convention, a struct of two pointers is returned in memory,
-// allocated by the caller, and passed as a pointer in a hidden first parameter.
-#ifdef V8_HOST_ARCH_64_BIT
-struct ObjectPair {
- Object* x;
- Object* y;
-};
-
-
-static inline ObjectPair MakePair(Object* x, Object* y) {
- ObjectPair result = {x, y};
- // Pointers x and y returned in rax and rdx, in AMD-x64-abi.
- // In Win64 they are assigned to a hidden first argument.
- return result;
-}
-#elif V8_TARGET_ARCH_X64 && V8_TARGET_ARCH_32_BIT
-// For x32 a 128-bit struct return is done as rax and rdx from the ObjectPair
-// are used in the full codegen and Crankshaft compiler. An alternative is
-// using uint64_t and modifying full codegen and Crankshaft compiler.
-struct ObjectPair {
- Object* x;
- uint32_t x_upper;
- Object* y;
- uint32_t y_upper;
-};
-
-
-static inline ObjectPair MakePair(Object* x, Object* y) {
- ObjectPair result = {x, 0, y, 0};
- // Pointers x and y returned in rax and rdx, in x32-abi.
- return result;
-}
-#else
-typedef uint64_t ObjectPair;
-static inline ObjectPair MakePair(Object* x, Object* y) {
-#if defined(V8_TARGET_LITTLE_ENDIAN)
- return reinterpret_cast<uint32_t>(x) |
- (reinterpret_cast<ObjectPair>(y) << 32);
-#elif defined(V8_TARGET_BIG_ENDIAN)
- return reinterpret_cast<uint32_t>(y) |
- (reinterpret_cast<ObjectPair>(x) << 32);
-#else
-#error Unknown endianness
-#endif
-}
-#endif
-
-
-static Object* ComputeReceiverForNonGlobal(Isolate* isolate,
- JSObject* holder) {
+static Object* ComputeReceiverForNonGlobal(Isolate* isolate, JSObject* holder) {
DCHECK(!holder->IsGlobalObject());
Context* top = isolate->context();
// Get the context extension function.
@@ -9375,11 +9005,8 @@ static ObjectPair LoadLookupSlotHelper(Arguments args, Isolate* isolate,
PropertyAttributes attributes;
ContextLookupFlags flags = FOLLOW_CHAINS;
BindingFlags binding_flags;
- Handle<Object> holder = context->Lookup(name,
- flags,
- &index,
- &attributes,
- &binding_flags);
+ Handle<Object> holder =
+ context->Lookup(name, flags, &index, &attributes, &binding_flags);
if (isolate->has_pending_exception()) {
return MakePair(isolate->heap()->exception(), NULL);
}
@@ -9403,7 +9030,7 @@ static ObjectPair LoadLookupSlotHelper(Arguments args, Isolate* isolate,
if (maybe_error.ToHandle(&error)) isolate->Throw(*error);
return MakePair(isolate->heap()->exception(), NULL);
}
- // FALLTHROUGH
+ // FALLTHROUGH
case MUTABLE_IS_INITIALIZED:
case IMMUTABLE_IS_INITIALIZED:
case IMMUTABLE_IS_INITIALIZED_HARMONY:
@@ -9438,15 +9065,15 @@ static ObjectPair LoadLookupSlotHelper(Arguments args, Isolate* isolate,
object->IsGlobalObject()
? Object::cast(isolate->heap()->undefined_value())
: object->IsJSProxy() ? static_cast<Object*>(*object)
- : ComputeReceiverForNonGlobal(isolate, JSObject::cast(*object)),
+ : ComputeReceiverForNonGlobal(
+ isolate, JSObject::cast(*object)),
isolate);
// No need to unhole the value here. This is taken care of by the
// GetProperty function.
Handle<Object> value;
ASSIGN_RETURN_ON_EXCEPTION_VALUE(
- isolate, value,
- Object::GetProperty(object, name),
+ isolate, value, Object::GetProperty(object, name),
MakePair(isolate->heap()->exception(), NULL));
return MakePair(*value, *receiver_handle);
}
@@ -9489,11 +9116,8 @@ RUNTIME_FUNCTION(Runtime_StoreLookupSlot) {
PropertyAttributes attributes;
ContextLookupFlags flags = FOLLOW_CHAINS;
BindingFlags binding_flags;
- Handle<Object> holder = context->Lookup(name,
- flags,
- &index,
- &attributes,
- &binding_flags);
+ Handle<Object> holder =
+ context->Lookup(name, flags, &index, &attributes, &binding_flags);
// In case of JSProxy, an exception might have been thrown.
if (isolate->has_pending_exception()) return isolate->heap()->exception();
@@ -9638,7 +9262,8 @@ static int StackSize(Isolate* isolate) {
static void PrintTransition(Isolate* isolate, Object* result) {
// indentation
- { const int nmax = 80;
+ {
+ const int nmax = 80;
int n = StackSize(isolate);
if (n <= nmax)
PrintF("%4d:%*s", n, n, "");
@@ -9752,13 +9377,11 @@ RUNTIME_FUNCTION(Runtime_DateParseString) {
bool result;
String::FlatContent str_content = str->GetFlatContent();
if (str_content.IsOneByte()) {
- result = DateParser::Parse(str_content.ToOneByteVector(),
- *output_array,
+ result = DateParser::Parse(str_content.ToOneByteVector(), *output_array,
isolate->unicode_cache());
} else {
DCHECK(str_content.IsTwoByte());
- result = DateParser::Parse(str_content.ToUC16Vector(),
- *output_array,
+ result = DateParser::Parse(str_content.ToUC16Vector(), *output_array,
isolate->unicode_cache());
}
@@ -9779,8 +9402,8 @@ RUNTIME_FUNCTION(Runtime_DateLocalTimezone) {
x <= DateCache::kMaxTimeBeforeUTCInMs);
const char* zone =
isolate->date_cache()->LocalTimezone(static_cast<int64_t>(x));
- Handle<String> result = isolate->factory()->NewStringFromUtf8(
- CStrVector(zone)).ToHandleChecked();
+ Handle<String> result =
+ isolate->factory()->NewStringFromUtf8(CStrVector(zone)).ToHandleChecked();
return *result;
}
@@ -9846,10 +9469,10 @@ RUNTIME_FUNCTION(Runtime_ParseJson) {
source = String::Flatten(source);
// Optimized fast case where we only have Latin1 characters.
Handle<Object> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result,
- source->IsSeqOneByteString() ? JsonParser<true>::Parse(source)
- : JsonParser<false>::Parse(source));
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result,
+ source->IsSeqOneByteString()
+ ? JsonParser<true>::Parse(source)
+ : JsonParser<false>::Parse(source));
return *result;
}
@@ -9893,18 +9516,18 @@ RUNTIME_FUNCTION(Runtime_CompileString) {
// Compile source string in the native context.
ParseRestriction restriction = function_literal_only
- ? ONLY_SINGLE_FUNCTION_LITERAL : NO_PARSE_RESTRICTION;
+ ? ONLY_SINGLE_FUNCTION_LITERAL
+ : NO_PARSE_RESTRICTION;
Handle<JSFunction> fun;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, fun,
- Compiler::GetFunctionFromEval(
- source, context, SLOPPY, restriction, RelocInfo::kNoPosition));
+ Compiler::GetFunctionFromEval(source, context, SLOPPY, restriction,
+ RelocInfo::kNoPosition));
return *fun;
}
-static ObjectPair CompileGlobalEval(Isolate* isolate,
- Handle<String> source,
+static ObjectPair CompileGlobalEval(Isolate* isolate, Handle<String> source,
Handle<Object> receiver,
StrictMode strict_mode,
int scope_position) {
@@ -9930,8 +9553,8 @@ static ObjectPair CompileGlobalEval(Isolate* isolate,
Handle<JSFunction> compiled;
ASSIGN_RETURN_ON_EXCEPTION_VALUE(
isolate, compiled,
- Compiler::GetFunctionFromEval(
- source, context, strict_mode, restriction, scope_position),
+ Compiler::GetFunctionFromEval(source, context, strict_mode, restriction,
+ scope_position),
MakePair(isolate->heap()->exception(), NULL));
return MakePair(*compiled, *receiver);
}
@@ -9957,11 +9580,8 @@ RUNTIME_FUNCTION_RETURN_PAIR(Runtime_ResolvePossiblyDirectEval) {
DCHECK(args.smi_at(3) == SLOPPY || args.smi_at(3) == STRICT);
StrictMode strict_mode = static_cast<StrictMode>(args.smi_at(3));
DCHECK(args[4]->IsSmi());
- return CompileGlobalEval(isolate,
- args.at<String>(1),
- args.at<Object>(2),
- strict_mode,
- args.smi_at(4));
+ return CompileGlobalEval(isolate, args.at<String>(1), args.at<Object>(2),
+ strict_mode, args.smi_at(4));
}
@@ -10007,8 +9627,7 @@ RUNTIME_FUNCTION(Runtime_PushIfAbsent) {
// Strict not needed. Used for cycle detection in Array join implementation.
RETURN_FAILURE_ON_EXCEPTION(
- isolate,
- JSObject::SetFastElement(array, length, element, SLOPPY, true));
+ isolate, JSObject::SetFastElement(array, length, element, SLOPPY, true));
return isolate->heap()->true_value();
}
@@ -10026,19 +9645,16 @@ RUNTIME_FUNCTION(Runtime_PushIfAbsent) {
*/
class ArrayConcatVisitor {
public:
- ArrayConcatVisitor(Isolate* isolate,
- Handle<FixedArray> storage,
- bool fast_elements) :
- isolate_(isolate),
- storage_(Handle<FixedArray>::cast(
- isolate->global_handles()->Create(*storage))),
- index_offset_(0u),
- fast_elements_(fast_elements),
- exceeds_array_limit_(false) { }
-
- ~ArrayConcatVisitor() {
- clear_storage();
- }
+ ArrayConcatVisitor(Isolate* isolate, Handle<FixedArray> storage,
+ bool fast_elements)
+ : isolate_(isolate),
+ storage_(Handle<FixedArray>::cast(
+ isolate->global_handles()->Create(*storage))),
+ index_offset_(0u),
+ fast_elements_(fast_elements),
+ exceeds_array_limit_(false) {}
+
+ ~ArrayConcatVisitor() { clear_storage(); }
void visit(uint32_t i, Handle<Object> elm) {
if (i > JSObject::kMaxElementCount - index_offset_) {
@@ -10087,17 +9703,14 @@ class ArrayConcatVisitor {
}
}
- bool exceeds_array_limit() {
- return exceeds_array_limit_;
- }
+ bool exceeds_array_limit() { return exceeds_array_limit_; }
Handle<JSArray> ToArray() {
Handle<JSArray> array = isolate_->factory()->NewJSArray(0);
Handle<Object> length =
isolate_->factory()->NewNumber(static_cast<double>(index_offset_));
Handle<Map> map = JSObject::GetElementsTransitionMap(
- array,
- fast_elements_ ? FAST_HOLEY_ELEMENTS : DICTIONARY_ELEMENTS);
+ array, fast_elements_ ? FAST_HOLEY_ELEMENTS : DICTIONARY_ELEMENTS);
array->set_map(*map);
array->set_length(*length);
array->set_elements(*storage_);
@@ -10133,8 +9746,8 @@ class ArrayConcatVisitor {
}
inline void set_storage(FixedArray* storage) {
- storage_ = Handle<FixedArray>::cast(
- isolate_->global_handles()->Create(storage));
+ storage_ =
+ Handle<FixedArray>::cast(isolate_->global_handles()->Create(storage));
}
Isolate* isolate_;
@@ -10195,11 +9808,11 @@ static uint32_t EstimateElementCount(Handle<JSArray> array) {
break;
}
case SLOPPY_ARGUMENTS_ELEMENTS:
-#define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \
- case EXTERNAL_##TYPE##_ELEMENTS: \
- case TYPE##_ELEMENTS: \
+#define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \
+ case EXTERNAL_##TYPE##_ELEMENTS: \
+ case TYPE##_ELEMENTS:
- TYPED_ARRAYS(TYPED_ARRAY_CASE)
+ TYPED_ARRAYS(TYPED_ARRAY_CASE)
#undef TYPED_ARRAY_CASE
// External arrays are always dense.
return length;
@@ -10210,8 +9823,7 @@ static uint32_t EstimateElementCount(Handle<JSArray> array) {
}
-
-template<class ExternalArrayClass, class ElementType>
+template <class ExternalArrayClass, class ElementType>
static void IterateExternalArrayElements(Isolate* isolate,
Handle<JSObject> receiver,
bool elements_are_ints,
@@ -10262,8 +9874,7 @@ static int compareUInt32(const uint32_t* ap, const uint32_t* bp) {
}
-static void CollectElementIndices(Handle<JSObject> object,
- uint32_t range,
+static void CollectElementIndices(Handle<JSObject> object, uint32_t range,
List<uint32_t>* indices) {
Isolate* isolate = object->GetIsolate();
ElementsKind kind = object->GetElementsKind();
@@ -10317,26 +9928,26 @@ static void CollectElementIndices(Handle<JSObject> object,
break;
}
#define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \
- case TYPE##_ELEMENTS: \
- case EXTERNAL_##TYPE##_ELEMENTS:
+ case TYPE##_ELEMENTS: \
+ case EXTERNAL_##TYPE##_ELEMENTS:
TYPED_ARRAYS(TYPED_ARRAY_CASE)
#undef TYPED_ARRAY_CASE
- {
- uint32_t length = static_cast<uint32_t>(
- FixedArrayBase::cast(object->elements())->length());
- if (range <= length) {
- length = range;
- // We will add all indices, so we might as well clear it first
- // and avoid duplicates.
- indices->Clear();
- }
- for (uint32_t i = 0; i < length; i++) {
- indices->Add(i);
+ {
+ uint32_t length = static_cast<uint32_t>(
+ FixedArrayBase::cast(object->elements())->length());
+ if (range <= length) {
+ length = range;
+ // We will add all indices, so we might as well clear it first
+ // and avoid duplicates.
+ indices->Clear();
+ }
+ for (uint32_t i = 0; i < length; i++) {
+ indices->Add(i);
+ }
+ if (length == range) return; // All indices accounted for already.
+ break;
}
- if (length == range) return; // All indices accounted for already.
- break;
- }
case SLOPPY_ARGUMENTS_ELEMENTS: {
MaybeHandle<Object> length_obj =
Object::GetProperty(object, isolate->factory()->length_string());
@@ -10373,8 +9984,7 @@ static void CollectElementIndices(Handle<JSObject> object,
* length.
* Returns false if any access threw an exception, otherwise true.
*/
-static bool IterateElements(Isolate* isolate,
- Handle<JSArray> receiver,
+static bool IterateElements(Isolate* isolate, Handle<JSArray> receiver,
ArrayConcatVisitor* visitor) {
uint32_t length = static_cast<uint32_t>(receiver->length()->Number());
switch (receiver->GetElementsKind()) {
@@ -10458,8 +10068,7 @@ static bool IterateElements(Isolate* isolate,
uint32_t index = indices[j];
Handle<Object> element;
ASSIGN_RETURN_ON_EXCEPTION_VALUE(
- isolate, element,
- Object::GetElement(isolate, receiver, index),
+ isolate, element, Object::GetElement(isolate, receiver, index),
false);
visitor->visit(index, element);
// Skip to next different index (i.e., omit duplicates).
@@ -10470,8 +10079,8 @@ static bool IterateElements(Isolate* isolate,
break;
}
case EXTERNAL_UINT8_CLAMPED_ELEMENTS: {
- Handle<ExternalUint8ClampedArray> pixels(ExternalUint8ClampedArray::cast(
- receiver->elements()));
+ Handle<ExternalUint8ClampedArray> pixels(
+ ExternalUint8ClampedArray::cast(receiver->elements()));
for (uint32_t j = 0; j < length; j++) {
Handle<Smi> e(Smi::FromInt(pixels->get_scalar(j)), isolate);
visitor->visit(j, e);
@@ -10581,14 +10190,12 @@ RUNTIME_FUNCTION(Runtime_ArrayConcat) {
element_estimate = 1;
}
// Avoid overflows by capping at kMaxElementCount.
- if (JSObject::kMaxElementCount - estimate_result_length <
- length_estimate) {
+ if (JSObject::kMaxElementCount - estimate_result_length < length_estimate) {
estimate_result_length = JSObject::kMaxElementCount;
} else {
estimate_result_length += length_estimate;
}
- if (JSObject::kMaxElementCount - estimate_nof_elements <
- element_estimate) {
+ if (JSObject::kMaxElementCount - estimate_nof_elements < element_estimate) {
estimate_nof_elements = JSObject::kMaxElementCount;
} else {
estimate_nof_elements += element_estimate;
@@ -10644,8 +10251,7 @@ RUNTIME_FUNCTION(Runtime_ArrayConcat) {
}
case FAST_HOLEY_SMI_ELEMENTS:
case FAST_SMI_ELEMENTS: {
- FixedArray* elements(
- FixedArray::cast(array->elements()));
+ FixedArray* elements(FixedArray::cast(array->elements()));
for (uint32_t i = 0; i < length; i++) {
Object* element = elements->get(i);
if (element->IsTheHole()) {
@@ -10686,12 +10292,12 @@ RUNTIME_FUNCTION(Runtime_ArrayConcat) {
if (fast_case) {
// The backing storage array must have non-existing elements to preserve
// holes across concat operations.
- storage = isolate->factory()->NewFixedArrayWithHoles(
- estimate_result_length);
+ storage =
+ isolate->factory()->NewFixedArrayWithHoles(estimate_result_length);
} else {
// TODO(126): move 25% pre-allocation logic into Dictionary::Allocate
- uint32_t at_least_space_for = estimate_nof_elements +
- (estimate_nof_elements >> 2);
+ uint32_t at_least_space_for =
+ estimate_nof_elements + (estimate_nof_elements >> 2);
storage = Handle<FixedArray>::cast(
SeededNumberDictionary::New(isolate, at_least_space_for));
}
@@ -10903,8 +10509,7 @@ static StackFrame::Id UnwrapFrameId(int wrapped) {
RUNTIME_FUNCTION(Runtime_SetDebugEventListener) {
SealHandleScope shs(isolate);
DCHECK(args.length() == 2);
- RUNTIME_ASSERT(args[0]->IsJSFunction() ||
- args[0]->IsUndefined() ||
+ RUNTIME_ASSERT(args[0]->IsJSFunction() || args[0]->IsUndefined() ||
args[0]->IsNull());
CONVERT_ARG_HANDLE_CHECKED(Object, callback, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, data, 1);
@@ -10997,8 +10602,8 @@ RUNTIME_FUNCTION(Runtime_DebugGetPropertyDetails) {
isolate, element_or_char,
Runtime::GetElementOrCharAt(isolate, obj, index));
details->set(0, *element_or_char);
- details->set(
- 1, PropertyDetails(NONE, NORMAL, Representation::None()).AsSmi());
+ details->set(1,
+ PropertyDetails(NONE, NORMAL, Representation::None()).AsSmi());
return *isolate->factory()->NewJSArrayWithElements(details);
}
@@ -11091,8 +10696,8 @@ RUNTIME_FUNCTION(Runtime_DebugNamedInterceptorPropertyValue) {
CONVERT_ARG_HANDLE_CHECKED(Name, name, 1);
Handle<Object> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result, JSObject::GetProperty(obj, name));
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result,
+ JSObject::GetProperty(obj, name));
return *result;
}
@@ -11157,8 +10762,7 @@ RUNTIME_FUNCTION(Runtime_GetFrameCount) {
class FrameInspector {
public:
- FrameInspector(JavaScriptFrame* frame,
- int inlined_jsframe_index,
+ FrameInspector(JavaScriptFrame* frame, int inlined_jsframe_index,
Isolate* isolate)
: frame_(frame), deoptimized_frame_(NULL), isolate_(isolate) {
// Calculate the deoptimized frame.
@@ -11174,41 +10778,35 @@ class FrameInspector {
~FrameInspector() {
// Get rid of the calculated deoptimized frame if any.
if (deoptimized_frame_ != NULL) {
- Deoptimizer::DeleteDebuggerInspectableFrame(deoptimized_frame_,
- isolate_);
+ Deoptimizer::DeleteDebuggerInspectableFrame(deoptimized_frame_, isolate_);
}
}
int GetParametersCount() {
- return is_optimized_
- ? deoptimized_frame_->parameters_count()
- : frame_->ComputeParametersCount();
+ return is_optimized_ ? deoptimized_frame_->parameters_count()
+ : frame_->ComputeParametersCount();
}
int expression_count() { return deoptimized_frame_->expression_count(); }
Object* GetFunction() {
- return is_optimized_
- ? deoptimized_frame_->GetFunction()
- : frame_->function();
+ return is_optimized_ ? deoptimized_frame_->GetFunction()
+ : frame_->function();
}
Object* GetParameter(int index) {
- return is_optimized_
- ? deoptimized_frame_->GetParameter(index)
- : frame_->GetParameter(index);
+ return is_optimized_ ? deoptimized_frame_->GetParameter(index)
+ : frame_->GetParameter(index);
}
Object* GetExpression(int index) {
- return is_optimized_
- ? deoptimized_frame_->GetExpression(index)
- : frame_->GetExpression(index);
+ return is_optimized_ ? deoptimized_frame_->GetExpression(index)
+ : frame_->GetExpression(index);
}
int GetSourcePosition() {
- return is_optimized_
- ? deoptimized_frame_->GetSourcePosition()
- : frame_->LookupCode()->SourcePosition(frame_->pc());
+ return is_optimized_ ? deoptimized_frame_->GetSourcePosition()
+ : frame_->LookupCode()->SourcePosition(frame_->pc());
}
bool IsConstructor() {
return is_optimized_ && !is_bottommost_
- ? deoptimized_frame_->HasConstructStub()
- : frame_->IsConstructor();
+ ? deoptimized_frame_->HasConstructStub()
+ : frame_->IsConstructor();
}
Object* GetContext() {
return is_optimized_ ? deoptimized_frame_->GetContext() : frame_->context();
@@ -11340,8 +10938,7 @@ RUNTIME_FUNCTION(Runtime_GetFrameDetails) {
for (int slot = 0; slot < scope_info->LocalCount(); ++slot) {
// Hide compiler-introduced temporary variables, whether on the stack or on
// the context.
- if (scope_info->LocalIsSynthetic(slot))
- local_count--;
+ if (scope_info->LocalIsSynthetic(slot)) local_count--;
}
Handle<FixedArray> locals =
@@ -11352,8 +10949,7 @@ RUNTIME_FUNCTION(Runtime_GetFrameDetails) {
int i = 0;
for (; i < scope_info->StackLocalCount(); ++i) {
// Use the value from the stack.
- if (scope_info->LocalIsSynthetic(i))
- continue;
+ if (scope_info->LocalIsSynthetic(i)) continue;
locals->set(local * 2, scope_info->LocalName(i));
locals->set(local * 2 + 1, frame_inspector.GetExpression(i));
local++;
@@ -11363,8 +10959,7 @@ RUNTIME_FUNCTION(Runtime_GetFrameDetails) {
Handle<Context> context(
Context::cast(frame_inspector.GetContext())->declaration_context());
for (; i < scope_info->LocalCount(); ++i) {
- if (scope_info->LocalIsSynthetic(i))
- continue;
+ if (scope_info->LocalIsSynthetic(i)) continue;
Handle<String> name(scope_info->LocalName(i));
VariableMode mode;
InitializationFlag init_flag;
@@ -11403,8 +10998,7 @@ RUNTIME_FUNCTION(Runtime_GetFrameDetails) {
// entering the debug break exit frame.
if (internal_frame_sp != NULL) {
return_value =
- Handle<Object>(Memory::Object_at(internal_frame_sp),
- isolate);
+ Handle<Object>(Memory::Object_at(internal_frame_sp), isolate);
break;
}
}
@@ -11435,8 +11029,7 @@ RUNTIME_FUNCTION(Runtime_GetFrameDetails) {
// Calculate the size of the result.
int details_size = kFrameDetailsFirstDynamicIndex +
- 2 * (argument_count + local_count) +
- (at_return ? 1 : 0);
+ 2 * (argument_count + local_count) + (at_return ? 1 : 0);
Handle<FixedArray> details = isolate->factory()->NewFixedArray(details_size);
// Add the frame id.
@@ -11449,8 +11042,7 @@ RUNTIME_FUNCTION(Runtime_GetFrameDetails) {
details->set(kFrameDetailsArgumentCountIndex, Smi::FromInt(argument_count));
// Add the locals count
- details->set(kFrameDetailsLocalCountIndex,
- Smi::FromInt(local_count));
+ details->set(kFrameDetailsLocalCountIndex, Smi::FromInt(local_count));
// Add the source position.
if (position != RelocInfo::kNoPosition) {
@@ -11514,8 +11106,7 @@ RUNTIME_FUNCTION(Runtime_GetFrameDetails) {
// THIS MUST BE DONE LAST SINCE WE MIGHT ADVANCE
// THE FRAME ITERATOR TO WRAP THE RECEIVER.
Handle<Object> receiver(it.frame()->receiver(), isolate);
- if (!receiver->IsJSObject() &&
- shared->strict_mode() == SLOPPY &&
+ if (!receiver->IsJSObject() && shared->strict_mode() == SLOPPY &&
!function->IsBuiltin()) {
// If the receiver is not a JSObject and the function is not a
// builtin or strict-mode we have hit an optimization where a
@@ -11557,9 +11148,7 @@ static bool ParameterIsShadowedByContextLocal(Handle<ScopeInfo> info,
// frame.
MUST_USE_RESULT
static MaybeHandle<JSObject> MaterializeStackLocalsWithFrameInspector(
- Isolate* isolate,
- Handle<JSObject> target,
- Handle<JSFunction> function,
+ Isolate* isolate, Handle<JSObject> target, Handle<JSFunction> function,
FrameInspector* frame_inspector) {
Handle<SharedFunctionInfo> shared(function->shared());
Handle<ScopeInfo> scope_info(shared->scope_info());
@@ -11577,10 +11166,9 @@ static MaybeHandle<JSObject> MaterializeStackLocalsWithFrameInspector(
isolate);
DCHECK(!value->IsTheHole());
- RETURN_ON_EXCEPTION(
- isolate,
- Runtime::SetObjectProperty(isolate, target, name, value, SLOPPY),
- JSObject);
+ RETURN_ON_EXCEPTION(isolate, Runtime::SetObjectProperty(
+ isolate, target, name, value, SLOPPY),
+ JSObject);
}
// Second fill all stack locals.
@@ -11590,10 +11178,9 @@ static MaybeHandle<JSObject> MaterializeStackLocalsWithFrameInspector(
Handle<Object> value(frame_inspector->GetExpression(i), isolate);
if (value->IsTheHole()) continue;
- RETURN_ON_EXCEPTION(
- isolate,
- Runtime::SetObjectProperty(isolate, target, name, value, SLOPPY),
- JSObject);
+ RETURN_ON_EXCEPTION(isolate, Runtime::SetObjectProperty(
+ isolate, target, name, value, SLOPPY),
+ JSObject);
}
return target;
@@ -11634,17 +11221,15 @@ static void UpdateStackLocalsFromMaterializedObject(Isolate* isolate,
if (frame->GetExpression(i)->IsTheHole()) continue;
HandleScope scope(isolate);
Handle<Object> value = Object::GetPropertyOrElement(
- target,
- handle(scope_info->StackLocalName(i), isolate)).ToHandleChecked();
+ target, handle(scope_info->StackLocalName(i),
+ isolate)).ToHandleChecked();
frame->SetExpression(i, *value);
}
}
MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeLocalContext(
- Isolate* isolate,
- Handle<JSObject> target,
- Handle<JSFunction> function,
+ Isolate* isolate, Handle<JSObject> target, Handle<JSFunction> function,
JavaScriptFrame* frame) {
HandleScope scope(isolate);
Handle<SharedFunctionInfo> shared(function->shared());
@@ -11655,8 +11240,8 @@ MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeLocalContext(
// Third fill all context locals.
Handle<Context> frame_context(Context::cast(frame->context()));
Handle<Context> function_context(frame_context->declaration_context());
- if (!ScopeInfo::CopyContextLocalsToScopeObject(
- scope_info, function_context, target)) {
+ if (!ScopeInfo::CopyContextLocalsToScopeObject(scope_info, function_context,
+ target)) {
return MaybeHandle<JSObject>();
}
@@ -11668,8 +11253,7 @@ MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeLocalContext(
Handle<JSObject> ext(JSObject::cast(function_context->extension()));
Handle<FixedArray> keys;
ASSIGN_RETURN_ON_EXCEPTION(
- isolate, keys,
- JSReceiver::GetKeys(ext, JSReceiver::INCLUDE_PROTOS),
+ isolate, keys, JSReceiver::GetKeys(ext, JSReceiver::INCLUDE_PROTOS),
JSObject);
for (int i = 0; i < keys->length(); i++) {
@@ -11679,10 +11263,9 @@ MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeLocalContext(
Handle<Object> value;
ASSIGN_RETURN_ON_EXCEPTION(
isolate, value, Object::GetPropertyOrElement(ext, key), JSObject);
- RETURN_ON_EXCEPTION(
- isolate,
- Runtime::SetObjectProperty(isolate, target, key, value, SLOPPY),
- JSObject);
+ RETURN_ON_EXCEPTION(isolate, Runtime::SetObjectProperty(
+ isolate, target, key, value, SLOPPY),
+ JSObject);
}
}
}
@@ -11692,9 +11275,7 @@ MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeLocalContext(
MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeLocalScope(
- Isolate* isolate,
- JavaScriptFrame* frame,
- int inlined_jsframe_index) {
+ Isolate* isolate, JavaScriptFrame* frame, int inlined_jsframe_index) {
FrameInspector frame_inspector(frame, inlined_jsframe_index, isolate);
Handle<JSFunction> function(JSFunction::cast(frame_inspector.GetFunction()));
@@ -11702,8 +11283,8 @@ MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeLocalScope(
isolate->factory()->NewJSObject(isolate->object_function());
ASSIGN_RETURN_ON_EXCEPTION(
isolate, local_scope,
- MaterializeStackLocalsWithFrameInspector(
- isolate, local_scope, function, &frame_inspector),
+ MaterializeStackLocalsWithFrameInspector(isolate, local_scope, function,
+ &frame_inspector),
JSObject);
return MaterializeLocalContext(isolate, local_scope, function, frame);
@@ -11711,8 +11292,7 @@ MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeLocalScope(
// Set the context local variable value.
-static bool SetContextLocalValue(Isolate* isolate,
- Handle<ScopeInfo> scope_info,
+static bool SetContextLocalValue(Isolate* isolate, Handle<ScopeInfo> scope_info,
Handle<Context> context,
Handle<String> variable_name,
Handle<Object> new_value) {
@@ -11733,8 +11313,7 @@ static bool SetContextLocalValue(Isolate* isolate,
}
-static bool SetLocalVariableValue(Isolate* isolate,
- JavaScriptFrame* frame,
+static bool SetLocalVariableValue(Isolate* isolate, JavaScriptFrame* frame,
int inlined_jsframe_index,
Handle<String> variable_name,
Handle<Object> new_value) {
@@ -11772,8 +11351,8 @@ static bool SetLocalVariableValue(Isolate* isolate,
// Context locals.
Handle<Context> frame_context(Context::cast(frame->context()));
Handle<Context> function_context(frame_context->declaration_context());
- if (SetContextLocalValue(
- isolate, scope_info, function_context, variable_name, new_value)) {
+ if (SetContextLocalValue(isolate, scope_info, function_context,
+ variable_name, new_value)) {
return true;
}
@@ -11803,8 +11382,7 @@ static bool SetLocalVariableValue(Isolate* isolate,
// Create a plain JSObject which materializes the closure content for the
// context.
MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeClosure(
- Isolate* isolate,
- Handle<Context> context) {
+ Isolate* isolate, Handle<Context> context) {
DCHECK(context->IsFunctionContext());
Handle<SharedFunctionInfo> shared(context->closure()->shared());
@@ -11816,8 +11394,8 @@ MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeClosure(
isolate->factory()->NewJSObject(isolate->object_function());
// Fill all context locals to the context extension.
- if (!ScopeInfo::CopyContextLocalsToScopeObject(
- scope_info, context, closure_scope)) {
+ if (!ScopeInfo::CopyContextLocalsToScopeObject(scope_info, context,
+ closure_scope)) {
return MaybeHandle<JSObject>();
}
@@ -11827,8 +11405,8 @@ MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeClosure(
Handle<JSObject> ext(JSObject::cast(context->extension()));
Handle<FixedArray> keys;
ASSIGN_RETURN_ON_EXCEPTION(
- isolate, keys,
- JSReceiver::GetKeys(ext, JSReceiver::INCLUDE_PROTOS), JSObject);
+ isolate, keys, JSReceiver::GetKeys(ext, JSReceiver::INCLUDE_PROTOS),
+ JSObject);
for (int i = 0; i < keys->length(); i++) {
HandleScope scope(isolate);
@@ -11838,10 +11416,9 @@ MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeClosure(
Handle<Object> value;
ASSIGN_RETURN_ON_EXCEPTION(
isolate, value, Object::GetPropertyOrElement(ext, key), JSObject);
- RETURN_ON_EXCEPTION(
- isolate,
- Runtime::DefineObjectProperty(closure_scope, key, value, NONE),
- JSObject);
+ RETURN_ON_EXCEPTION(isolate, Runtime::DefineObjectProperty(
+ closure_scope, key, value, NONE),
+ JSObject);
}
}
@@ -11850,8 +11427,7 @@ MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeClosure(
// This method copies structure of MaterializeClosure method above.
-static bool SetClosureVariableValue(Isolate* isolate,
- Handle<Context> context,
+static bool SetClosureVariableValue(Isolate* isolate, Handle<Context> context,
Handle<String> variable_name,
Handle<Object> new_value) {
DCHECK(context->IsFunctionContext());
@@ -11860,8 +11436,8 @@ static bool SetClosureVariableValue(Isolate* isolate,
Handle<ScopeInfo> scope_info(shared->scope_info());
// Context locals to the context extension.
- if (SetContextLocalValue(
- isolate, scope_info, context, variable_name, new_value)) {
+ if (SetContextLocalValue(isolate, scope_info, context, variable_name,
+ new_value)) {
return true;
}
@@ -11873,8 +11449,8 @@ static bool SetClosureVariableValue(Isolate* isolate,
DCHECK(maybe.has_value);
if (maybe.value) {
// We don't expect this to do anything except replacing property value.
- Runtime::DefineObjectProperty(
- ext, variable_name, new_value, NONE).Assert();
+ Runtime::DefineObjectProperty(ext, variable_name, new_value, NONE)
+ .Assert();
return true;
}
}
@@ -11886,24 +11462,21 @@ static bool SetClosureVariableValue(Isolate* isolate,
// Create a plain JSObject which materializes the scope for the specified
// catch context.
MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeCatchScope(
- Isolate* isolate,
- Handle<Context> context) {
+ Isolate* isolate, Handle<Context> context) {
DCHECK(context->IsCatchContext());
Handle<String> name(String::cast(context->extension()));
Handle<Object> thrown_object(context->get(Context::THROWN_OBJECT_INDEX),
isolate);
Handle<JSObject> catch_scope =
isolate->factory()->NewJSObject(isolate->object_function());
- RETURN_ON_EXCEPTION(
- isolate,
- Runtime::DefineObjectProperty(catch_scope, name, thrown_object, NONE),
- JSObject);
+ RETURN_ON_EXCEPTION(isolate, Runtime::DefineObjectProperty(
+ catch_scope, name, thrown_object, NONE),
+ JSObject);
return catch_scope;
}
-static bool SetCatchVariableValue(Isolate* isolate,
- Handle<Context> context,
+static bool SetCatchVariableValue(Isolate* isolate, Handle<Context> context,
Handle<String> variable_name,
Handle<Object> new_value) {
DCHECK(context->IsCatchContext());
@@ -11919,8 +11492,7 @@ static bool SetCatchVariableValue(Isolate* isolate,
// Create a plain JSObject which materializes the block scope for the specified
// block context.
MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeBlockScope(
- Isolate* isolate,
- Handle<Context> context) {
+ Isolate* isolate, Handle<Context> context) {
DCHECK(context->IsBlockContext());
Handle<ScopeInfo> scope_info(ScopeInfo::cast(context->extension()));
@@ -11930,8 +11502,8 @@ MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeBlockScope(
isolate->factory()->NewJSObject(isolate->object_function());
// Fill all context locals.
- if (!ScopeInfo::CopyContextLocalsToScopeObject(
- scope_info, context, block_scope)) {
+ if (!ScopeInfo::CopyContextLocalsToScopeObject(scope_info, context,
+ block_scope)) {
return MaybeHandle<JSObject>();
}
@@ -11942,8 +11514,7 @@ MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeBlockScope(
// Create a plain JSObject which materializes the module scope for the specified
// module context.
MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeModuleScope(
- Isolate* isolate,
- Handle<Context> context) {
+ Isolate* isolate, Handle<Context> context) {
DCHECK(context->IsModuleContext());
Handle<ScopeInfo> scope_info(ScopeInfo::cast(context->extension()));
@@ -11953,8 +11524,8 @@ MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeModuleScope(
isolate->factory()->NewJSObject(isolate->object_function());
// Fill all context locals.
- if (!ScopeInfo::CopyContextLocalsToScopeObject(
- scope_info, context, module_scope)) {
+ if (!ScopeInfo::CopyContextLocalsToScopeObject(scope_info, context,
+ module_scope)) {
return MaybeHandle<JSObject>();
}
@@ -11978,18 +11549,15 @@ class ScopeIterator {
ScopeTypeModule
};
- ScopeIterator(Isolate* isolate,
- JavaScriptFrame* frame,
- int inlined_jsframe_index,
- bool ignore_nested_scopes = false)
- : isolate_(isolate),
- frame_(frame),
- inlined_jsframe_index_(inlined_jsframe_index),
- function_(frame->function()),
- context_(Context::cast(frame->context())),
- nested_scope_chain_(4),
- failed_(false) {
-
+ ScopeIterator(Isolate* isolate, JavaScriptFrame* frame,
+ int inlined_jsframe_index, bool ignore_nested_scopes = false)
+ : isolate_(isolate),
+ frame_(frame),
+ inlined_jsframe_index_(inlined_jsframe_index),
+ function_(frame->function()),
+ context_(Context::cast(frame->context())),
+ nested_scope_chain_(4),
+ failed_(false) {
// Catch the case when the debugger stops in an internal function.
Handle<SharedFunctionInfo> shared_info(function_->shared());
Handle<ScopeInfo> scope_info(shared_info->scope_info());
@@ -12072,14 +11640,13 @@ class ScopeIterator {
}
}
- ScopeIterator(Isolate* isolate,
- Handle<JSFunction> function)
- : isolate_(isolate),
- frame_(NULL),
- inlined_jsframe_index_(0),
- function_(function),
- context_(function->context()),
- failed_(false) {
+ ScopeIterator(Isolate* isolate, Handle<JSFunction> function)
+ : isolate_(isolate),
+ frame_(NULL),
+ inlined_jsframe_index_(0),
+ function_(function),
+ context_(function->context()),
+ failed_(false) {
if (function->IsBuiltin()) {
context_ = Handle<Context>();
}
@@ -12121,8 +11688,7 @@ class ScopeIterator {
Handle<ScopeInfo> scope_info = nested_scope_chain_.last();
switch (scope_info->scope_type()) {
case FUNCTION_SCOPE:
- DCHECK(context_->IsFunctionContext() ||
- !scope_info->HasContext());
+ DCHECK(context_->IsFunctionContext() || !scope_info->HasContext());
return ScopeTypeLocal;
case MODULE_SCOPE:
DCHECK(context_->IsModuleContext());
@@ -12137,8 +11703,7 @@ class ScopeIterator {
DCHECK(context_->IsCatchContext());
return ScopeTypeCatch;
case BLOCK_SCOPE:
- DCHECK(!scope_info->HasContext() ||
- context_->IsBlockContext());
+ DCHECK(!scope_info->HasContext() || context_->IsBlockContext());
return ScopeTypeBlock;
case EVAL_SCOPE:
UNREACHABLE();
@@ -12199,15 +11764,15 @@ class ScopeIterator {
break;
case ScopeIterator::ScopeTypeLocal:
return SetLocalVariableValue(isolate_, frame_, inlined_jsframe_index_,
- variable_name, new_value);
+ variable_name, new_value);
case ScopeIterator::ScopeTypeWith:
break;
case ScopeIterator::ScopeTypeCatch:
- return SetCatchVariableValue(isolate_, CurrentContext(),
- variable_name, new_value);
+ return SetCatchVariableValue(isolate_, CurrentContext(), variable_name,
+ new_value);
case ScopeIterator::ScopeTypeClosure:
return SetClosureVariableValue(isolate_, CurrentContext(),
- variable_name, new_value);
+ variable_name, new_value);
case ScopeIterator::ScopeTypeBlock:
// TODO(2399): should we implement it?
break;
@@ -12234,8 +11799,7 @@ class ScopeIterator {
// be an actual context.
Handle<Context> CurrentContext() {
DCHECK(!failed_);
- if (Type() == ScopeTypeGlobal ||
- nested_scope_chain_.is_empty()) {
+ if (Type() == ScopeTypeGlobal || nested_scope_chain_.is_empty()) {
return context_;
} else if (nested_scope_chain_.last()->HasContext()) {
return context_;
@@ -12344,9 +11908,7 @@ RUNTIME_FUNCTION(Runtime_GetScopeCount) {
// Count the visible scopes.
int n = 0;
- for (ScopeIterator it(isolate, frame, 0);
- !it.Done();
- it.Next()) {
+ for (ScopeIterator it(isolate, frame, 0); !it.Done(); it.Next()) {
n++;
}
@@ -12372,10 +11934,8 @@ RUNTIME_FUNCTION(Runtime_GetStepInPositions) {
JavaScriptFrame* frame = frame_it.frame();
- Handle<JSFunction> fun =
- Handle<JSFunction>(frame->function());
- Handle<SharedFunctionInfo> shared =
- Handle<SharedFunctionInfo>(fun->shared());
+ Handle<JSFunction> fun = Handle<JSFunction>(frame->function());
+ Handle<SharedFunctionInfo> shared = Handle<SharedFunctionInfo>(fun->shared());
if (!isolate->debug()->EnsureDebugInfo(shared, fun)) {
return isolate->heap()->undefined_value();
@@ -12414,17 +11974,15 @@ RUNTIME_FUNCTION(Runtime_GetStepInPositions) {
if (break_location_iterator.IsStepInLocation(isolate)) {
Smi* position_value = Smi::FromInt(break_location_iterator.position());
RETURN_FAILURE_ON_EXCEPTION(
- isolate,
- JSObject::SetElement(array, len,
- Handle<Object>(position_value, isolate),
- NONE, SLOPPY));
+ isolate, JSObject::SetElement(
+ array, len, Handle<Object>(position_value, isolate),
+ NONE, SLOPPY));
len++;
}
}
// Advance iterator.
break_location_iterator.Next();
- if (current_statement_pos !=
- break_location_iterator.statement_position()) {
+ if (current_statement_pos != break_location_iterator.statement_position()) {
break;
}
}
@@ -12438,8 +11996,7 @@ static const int kScopeDetailsSize = 2;
MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeScopeDetails(
- Isolate* isolate,
- ScopeIterator* it) {
+ Isolate* isolate, ScopeIterator* it) {
// Calculate the size of the result.
int details_size = kScopeDetailsSize;
Handle<FixedArray> details = isolate->factory()->NewFixedArray(details_size);
@@ -12447,8 +12004,8 @@ MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeScopeDetails(
// Fill in scope details.
details->set(kScopeDetailsTypeIndex, Smi::FromInt(it->Type()));
Handle<JSObject> scope_object;
- ASSIGN_RETURN_ON_EXCEPTION(
- isolate, scope_object, it->ScopeObject(), JSObject);
+ ASSIGN_RETURN_ON_EXCEPTION(isolate, scope_object, it->ScopeObject(),
+ JSObject);
details->set(kScopeDetailsObjectIndex, *scope_object);
return isolate->factory()->NewJSArrayWithElements(details);
@@ -12489,8 +12046,8 @@ RUNTIME_FUNCTION(Runtime_GetScopeDetails) {
return isolate->heap()->undefined_value();
}
Handle<JSObject> details;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, details, MaterializeScopeDetails(isolate, &it));
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, details,
+ MaterializeScopeDetails(isolate, &it));
return *details;
}
@@ -12528,8 +12085,8 @@ RUNTIME_FUNCTION(Runtime_GetAllScopesDetails) {
ScopeIterator it(isolate, frame, inlined_jsframe_index, ignore_nested_scopes);
for (; !it.Done(); it.Next()) {
Handle<JSObject> details;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, details, MaterializeScopeDetails(isolate, &it));
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, details,
+ MaterializeScopeDetails(isolate, &it));
result.Add(details);
}
@@ -12577,8 +12134,8 @@ RUNTIME_FUNCTION(Runtime_GetFunctionScopeDetails) {
}
Handle<JSObject> details;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, details, MaterializeScopeDetails(isolate, &it));
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, details,
+ MaterializeScopeDetails(isolate, &it));
return *details;
}
@@ -12647,9 +12204,7 @@ RUNTIME_FUNCTION(Runtime_DebugPrintScopes) {
// Print the scopes for the top frame.
StackFrameLocator locator(isolate);
JavaScriptFrame* frame = locator.FindJavaScriptFrame(0);
- for (ScopeIterator it(isolate, frame, 0);
- !it.Done();
- it.Next()) {
+ for (ScopeIterator it(isolate, frame, 0); !it.Done(); it.Next()) {
it.DebugPrint();
}
#endif
@@ -12665,10 +12220,8 @@ RUNTIME_FUNCTION(Runtime_GetThreadCount) {
// Count all archived V8 threads.
int n = 0;
- for (ThreadState* thread =
- isolate->thread_manager()->FirstThreadStateInUse();
- thread != NULL;
- thread = thread->Next()) {
+ for (ThreadState* thread = isolate->thread_manager()->FirstThreadStateInUse();
+ thread != NULL; thread = thread->Next()) {
n++;
}
@@ -12710,8 +12263,7 @@ RUNTIME_FUNCTION(Runtime_GetThreadDetails) {
} else {
// Find the thread with the requested index.
int n = 1;
- ThreadState* thread =
- isolate->thread_manager()->FirstThreadStateInUse();
+ ThreadState* thread = isolate->thread_manager()->FirstThreadStateInUse();
while (index != n && thread != NULL) {
thread = thread->Next();
n++;
@@ -12739,7 +12291,7 @@ RUNTIME_FUNCTION(Runtime_SetDisableBreak) {
DCHECK(args.length() == 1);
CONVERT_BOOLEAN_ARG_CHECKED(disable_break, 0);
isolate->debug()->set_disable_break(disable_break);
- return isolate->heap()->undefined_value();
+ return isolate->heap()->undefined_value();
}
@@ -12821,8 +12373,7 @@ RUNTIME_FUNCTION(Runtime_SetScriptBreakPoint) {
// Set break point.
if (!isolate->debug()->SetBreakPointForScript(script, break_point_object_arg,
- &source_position,
- alignment)) {
+ &source_position, alignment)) {
return isolate->heap()->undefined_value();
}
@@ -12901,10 +12452,8 @@ RUNTIME_FUNCTION(Runtime_PrepareStep) {
// Get the step action and check validity.
StepAction step_action = static_cast<StepAction>(NumberToInt32(args[1]));
- if (step_action != StepIn &&
- step_action != StepNext &&
- step_action != StepOut &&
- step_action != StepInMin &&
+ if (step_action != StepIn && step_action != StepNext &&
+ step_action != StepOut && step_action != StepInMin &&
step_action != StepMin) {
return isolate->Throw(isolate->heap()->illegal_argument_string());
}
@@ -12925,8 +12474,7 @@ RUNTIME_FUNCTION(Runtime_PrepareStep) {
// Prepare step.
isolate->debug()->PrepareStep(static_cast<StepAction>(step_action),
- step_count,
- frame_id);
+ step_count, frame_id);
return isolate->heap()->undefined_value();
}
@@ -12943,9 +12491,7 @@ RUNTIME_FUNCTION(Runtime_ClearStepping) {
// Helper function to find or create the arguments object for
// Runtime_DebugEvaluate.
MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeArgumentsObject(
- Isolate* isolate,
- Handle<JSObject> target,
- Handle<JSFunction> function) {
+ Isolate* isolate, Handle<JSObject> target, Handle<JSFunction> function) {
// Do not materialize the arguments object for eval or top-level code.
// Skip if "arguments" is already taken.
if (!function->shared()->is_function()) return target;
@@ -12955,13 +12501,12 @@ MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeArgumentsObject(
if (maybe.value) return target;
// FunctionGetArguments can't throw an exception.
- Handle<JSObject> arguments = Handle<JSObject>::cast(
- Accessors::FunctionGetArguments(function));
+ Handle<JSObject> arguments =
+ Handle<JSObject>::cast(Accessors::FunctionGetArguments(function));
Handle<String> arguments_str = isolate->factory()->arguments_string();
- RETURN_ON_EXCEPTION(
- isolate,
- Runtime::DefineObjectProperty(target, arguments_str, arguments, NONE),
- JSObject);
+ RETURN_ON_EXCEPTION(isolate, Runtime::DefineObjectProperty(
+ target, arguments_str, arguments, NONE),
+ JSObject);
return target;
}
@@ -12980,18 +12525,14 @@ static MaybeHandle<Object> DebugEvaluate(Isolate* isolate,
Handle<JSFunction> eval_fun;
ASSIGN_RETURN_ON_EXCEPTION(
- isolate, eval_fun,
- Compiler::GetFunctionFromEval(source,
- context,
- SLOPPY,
- NO_PARSE_RESTRICTION,
- RelocInfo::kNoPosition),
+ isolate, eval_fun, Compiler::GetFunctionFromEval(source, context, SLOPPY,
+ NO_PARSE_RESTRICTION,
+ RelocInfo::kNoPosition),
Object);
Handle<Object> result;
ASSIGN_RETURN_ON_EXCEPTION(
- isolate, result,
- Execution::Call(isolate, eval_fun, receiver, 0, NULL),
+ isolate, result, Execution::Call(isolate, eval_fun, receiver, 0, NULL),
Object);
// Skip the global proxy as it has no properties and always delegates to the
@@ -13064,8 +12605,8 @@ RUNTIME_FUNCTION(Runtime_DebugEvaluate) {
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, materialized,
- MaterializeStackLocalsWithFrameInspector(
- isolate, materialized, function, &frame_inspector));
+ MaterializeStackLocalsWithFrameInspector(isolate, materialized, function,
+ &frame_inspector));
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, materialized,
@@ -13081,8 +12622,8 @@ RUNTIME_FUNCTION(Runtime_DebugEvaluate) {
DebugEvaluate(isolate, context, context_extension, receiver, source));
// Write back potential changes to materialized stack locals to the stack.
- UpdateStackLocalsFromMaterializedObject(
- isolate, materialized, function, frame, inlined_jsframe_index);
+ UpdateStackLocalsFromMaterializedObject(isolate, materialized, function,
+ frame, inlined_jsframe_index);
return *result;
}
@@ -13154,8 +12695,7 @@ RUNTIME_FUNCTION(Runtime_DebugGetLoadedScripts) {
// Helper function used by Runtime_DebugReferencedBy below.
-static int DebugReferencedBy(HeapIterator* iterator,
- JSObject* target,
+static int DebugReferencedBy(HeapIterator* iterator, JSObject* target,
Object* instance_filter, int max_references,
FixedArray* instances, int instances_size,
JSFunction* arguments_function) {
@@ -13248,9 +12788,8 @@ RUNTIME_FUNCTION(Runtime_DebugReferencedBy) {
heap->CollectAllGarbage(Heap::kMakeHeapIterableMask, "%DebugConstructedBy");
{
HeapIterator heap_iterator(heap);
- count = DebugReferencedBy(&heap_iterator,
- *target, *instance_filter, max_references,
- NULL, 0, *arguments_function);
+ count = DebugReferencedBy(&heap_iterator, *target, *instance_filter,
+ max_references, NULL, 0, *arguments_function);
}
// Allocate an array to hold the result.
@@ -13259,9 +12798,9 @@ RUNTIME_FUNCTION(Runtime_DebugReferencedBy) {
// Fill the referencing objects.
{
HeapIterator heap_iterator(heap);
- count = DebugReferencedBy(&heap_iterator,
- *target, *instance_filter, max_references,
- *instances, count, *arguments_function);
+ count = DebugReferencedBy(&heap_iterator, *target, *instance_filter,
+ max_references, *instances, count,
+ *arguments_function);
}
// Return result as JS array.
@@ -13274,10 +12813,8 @@ RUNTIME_FUNCTION(Runtime_DebugReferencedBy) {
// Helper function used by Runtime_DebugConstructedBy below.
-static int DebugConstructedBy(HeapIterator* iterator,
- JSFunction* constructor,
- int max_references,
- FixedArray* instances,
+static int DebugConstructedBy(HeapIterator* iterator, JSFunction* constructor,
+ int max_references, FixedArray* instances,
int instances_size) {
DisallowHeapAllocation no_allocation;
@@ -13326,11 +12863,8 @@ RUNTIME_FUNCTION(Runtime_DebugConstructedBy) {
heap->CollectAllGarbage(Heap::kMakeHeapIterableMask, "%DebugConstructedBy");
{
HeapIterator heap_iterator(heap);
- count = DebugConstructedBy(&heap_iterator,
- *constructor,
- max_references,
- NULL,
- 0);
+ count = DebugConstructedBy(&heap_iterator, *constructor, max_references,
+ NULL, 0);
}
// Allocate an array to hold the result.
@@ -13339,11 +12873,8 @@ RUNTIME_FUNCTION(Runtime_DebugConstructedBy) {
// Fill the referencing objects.
{
HeapIterator heap_iterator2(heap);
- count = DebugConstructedBy(&heap_iterator2,
- *constructor,
- max_references,
- *instances,
- count);
+ count = DebugConstructedBy(&heap_iterator2, *constructor, max_references,
+ *instances, count);
}
// Return result as JS array.
@@ -13440,8 +12971,7 @@ static int FindSharedFunctionInfosForScript(HeapIterator* iterator,
DisallowHeapAllocation no_allocation;
int counter = 0;
int buffer_size = buffer->length();
- for (HeapObject* obj = iterator->next();
- obj != NULL;
+ for (HeapObject* obj = iterator->next(); obj != NULL;
obj = iterator->next()) {
DCHECK(obj != NULL);
if (!obj->IsSharedFunctionInfo()) {
@@ -13540,7 +13070,7 @@ RUNTIME_FUNCTION(Runtime_LiveEditReplaceScript) {
Handle<Script> original_script(Script::cast(original_script_value->value()));
Handle<Object> old_script = LiveEdit::ChangeScriptSource(
- original_script, new_source, old_script_name);
+ original_script, new_source, old_script_name);
if (old_script->IsScript()) {
Handle<Script> script_handle = Handle<Script>::cast(old_script);
@@ -13617,8 +13147,8 @@ RUNTIME_FUNCTION(Runtime_LiveEditReplaceRefToNestedFunction) {
RUNTIME_ASSERT(orig_wrapper->value()->IsSharedFunctionInfo());
RUNTIME_ASSERT(subst_wrapper->value()->IsSharedFunctionInfo());
- LiveEdit::ReplaceRefToNestedFunction(
- parent_wrapper, orig_wrapper, subst_wrapper);
+ LiveEdit::ReplaceRefToNestedFunction(parent_wrapper, orig_wrapper,
+ subst_wrapper);
return isolate->heap()->undefined_value();
}
@@ -13760,18 +13290,12 @@ RUNTIME_FUNCTION(Runtime_ExecuteInDebugContext) {
MaybeHandle<Object> maybe_result;
if (without_debugger) {
- maybe_result = Execution::Call(isolate,
- function,
- handle(function->global_proxy()),
- 0,
- NULL);
+ maybe_result = Execution::Call(isolate, function,
+ handle(function->global_proxy()), 0, NULL);
} else {
DebugScope debug_scope(isolate->debug());
- maybe_result = Execution::Call(isolate,
- function,
- handle(function->global_proxy()),
- 0,
- NULL);
+ maybe_result = Execution::Call(isolate, function,
+ handle(function->global_proxy()), 0, NULL);
}
Handle<Object> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, maybe_result);
@@ -13813,777 +13337,55 @@ RUNTIME_FUNCTION(Runtime_GetHeapUsage) {
}
-#ifdef V8_I18N_SUPPORT
-RUNTIME_FUNCTION(Runtime_CanonicalizeLanguageTag) {
- HandleScope scope(isolate);
- Factory* factory = isolate->factory();
-
- DCHECK(args.length() == 1);
- CONVERT_ARG_HANDLE_CHECKED(String, locale_id_str, 0);
-
- v8::String::Utf8Value locale_id(v8::Utils::ToLocal(locale_id_str));
-
- // Return value which denotes invalid language tag.
- const char* const kInvalidTag = "invalid-tag";
-
- UErrorCode error = U_ZERO_ERROR;
- char icu_result[ULOC_FULLNAME_CAPACITY];
- int icu_length = 0;
-
- uloc_forLanguageTag(*locale_id, icu_result, ULOC_FULLNAME_CAPACITY,
- &icu_length, &error);
- if (U_FAILURE(error) || icu_length == 0) {
- return *factory->NewStringFromAsciiChecked(kInvalidTag);
+// Finds the script object from the script data. NOTE: This operation uses
+// heap traversal to find the function generated for the source position
+// for the requested break point. For lazily compiled functions several heap
+// traversals might be required rendering this operation as a rather slow
+// operation. However for setting break points which is normally done through
+// some kind of user interaction the performance is not crucial.
+static Handle<Object> Runtime_GetScriptFromScriptName(
+ Handle<String> script_name) {
+ // Scan the heap for Script objects to find the script with the requested
+ // script data.
+ Handle<Script> script;
+ Factory* factory = script_name->GetIsolate()->factory();
+ Heap* heap = script_name->GetHeap();
+ HeapIterator iterator(heap);
+ HeapObject* obj = NULL;
+ while (script.is_null() && ((obj = iterator.next()) != NULL)) {
+ // If a script is found check if it has the script data requested.
+ if (obj->IsScript()) {
+ if (Script::cast(obj)->name()->IsString()) {
+ if (String::cast(Script::cast(obj)->name())->Equals(*script_name)) {
+ script = Handle<Script>(Script::cast(obj));
+ }
+ }
+ }
}
- char result[ULOC_FULLNAME_CAPACITY];
-
- // Force strict BCP47 rules.
- uloc_toLanguageTag(icu_result, result, ULOC_FULLNAME_CAPACITY, TRUE, &error);
-
- if (U_FAILURE(error)) {
- return *factory->NewStringFromAsciiChecked(kInvalidTag);
- }
+ // If no script with the requested script data is found return undefined.
+ if (script.is_null()) return factory->undefined_value();
- return *factory->NewStringFromAsciiChecked(result);
+ // Return the script found.
+ return Script::GetWrapper(script);
}
-RUNTIME_FUNCTION(Runtime_AvailableLocalesOf) {
+// Get the script object from script data. NOTE: Regarding performance
+// see the NOTE for GetScriptFromScriptData.
+// args[0]: script data for the script to find the source for
+RUNTIME_FUNCTION(Runtime_GetScript) {
HandleScope scope(isolate);
- Factory* factory = isolate->factory();
DCHECK(args.length() == 1);
- CONVERT_ARG_HANDLE_CHECKED(String, service, 0);
- const icu::Locale* available_locales = NULL;
- int32_t count = 0;
+ CONVERT_ARG_CHECKED(String, script_name, 0);
- if (service->IsUtf8EqualTo(CStrVector("collator"))) {
- available_locales = icu::Collator::getAvailableLocales(count);
- } else if (service->IsUtf8EqualTo(CStrVector("numberformat"))) {
- available_locales = icu::NumberFormat::getAvailableLocales(count);
- } else if (service->IsUtf8EqualTo(CStrVector("dateformat"))) {
- available_locales = icu::DateFormat::getAvailableLocales(count);
- } else if (service->IsUtf8EqualTo(CStrVector("breakiterator"))) {
- available_locales = icu::BreakIterator::getAvailableLocales(count);
- }
-
- UErrorCode error = U_ZERO_ERROR;
- char result[ULOC_FULLNAME_CAPACITY];
- Handle<JSObject> locales =
- factory->NewJSObject(isolate->object_function());
-
- for (int32_t i = 0; i < count; ++i) {
- const char* icu_name = available_locales[i].getName();
-
- error = U_ZERO_ERROR;
- // No need to force strict BCP47 rules.
- uloc_toLanguageTag(icu_name, result, ULOC_FULLNAME_CAPACITY, FALSE, &error);
- if (U_FAILURE(error)) {
- // This shouldn't happen, but lets not break the user.
- continue;
- }
-
- RETURN_FAILURE_ON_EXCEPTION(isolate,
- JSObject::SetOwnPropertyIgnoreAttributes(
- locales,
- factory->NewStringFromAsciiChecked(result),
- factory->NewNumber(i),
- NONE));
- }
-
- return *locales;
-}
-
-
-RUNTIME_FUNCTION(Runtime_GetDefaultICULocale) {
- HandleScope scope(isolate);
- Factory* factory = isolate->factory();
-
- DCHECK(args.length() == 0);
-
- icu::Locale default_locale;
-
- // Set the locale
- char result[ULOC_FULLNAME_CAPACITY];
- UErrorCode status = U_ZERO_ERROR;
- uloc_toLanguageTag(
- default_locale.getName(), result, ULOC_FULLNAME_CAPACITY, FALSE, &status);
- if (U_SUCCESS(status)) {
- return *factory->NewStringFromAsciiChecked(result);
- }
-
- return *factory->NewStringFromStaticChars("und");
-}
-
-
-RUNTIME_FUNCTION(Runtime_GetLanguageTagVariants) {
- HandleScope scope(isolate);
- Factory* factory = isolate->factory();
-
- DCHECK(args.length() == 1);
-
- CONVERT_ARG_HANDLE_CHECKED(JSArray, input, 0);
-
- uint32_t length = static_cast<uint32_t>(input->length()->Number());
- // Set some limit to prevent fuzz tests from going OOM.
- // Can be bumped when callers' requirements change.
- RUNTIME_ASSERT(length < 100);
- Handle<FixedArray> output = factory->NewFixedArray(length);
- Handle<Name> maximized = factory->NewStringFromStaticChars("maximized");
- Handle<Name> base = factory->NewStringFromStaticChars("base");
- for (unsigned int i = 0; i < length; ++i) {
- Handle<Object> locale_id;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, locale_id, Object::GetElement(isolate, input, i));
- if (!locale_id->IsString()) {
- return isolate->Throw(*factory->illegal_argument_string());
- }
-
- v8::String::Utf8Value utf8_locale_id(
- v8::Utils::ToLocal(Handle<String>::cast(locale_id)));
-
- UErrorCode error = U_ZERO_ERROR;
-
- // Convert from BCP47 to ICU format.
- // de-DE-u-co-phonebk -> de_DE@collation=phonebook
- char icu_locale[ULOC_FULLNAME_CAPACITY];
- int icu_locale_length = 0;
- uloc_forLanguageTag(*utf8_locale_id, icu_locale, ULOC_FULLNAME_CAPACITY,
- &icu_locale_length, &error);
- if (U_FAILURE(error) || icu_locale_length == 0) {
- return isolate->Throw(*factory->illegal_argument_string());
- }
-
- // Maximize the locale.
- // de_DE@collation=phonebook -> de_Latn_DE@collation=phonebook
- char icu_max_locale[ULOC_FULLNAME_CAPACITY];
- uloc_addLikelySubtags(
- icu_locale, icu_max_locale, ULOC_FULLNAME_CAPACITY, &error);
-
- // Remove extensions from maximized locale.
- // de_Latn_DE@collation=phonebook -> de_Latn_DE
- char icu_base_max_locale[ULOC_FULLNAME_CAPACITY];
- uloc_getBaseName(
- icu_max_locale, icu_base_max_locale, ULOC_FULLNAME_CAPACITY, &error);
-
- // Get original name without extensions.
- // de_DE@collation=phonebook -> de_DE
- char icu_base_locale[ULOC_FULLNAME_CAPACITY];
- uloc_getBaseName(
- icu_locale, icu_base_locale, ULOC_FULLNAME_CAPACITY, &error);
-
- // Convert from ICU locale format to BCP47 format.
- // de_Latn_DE -> de-Latn-DE
- char base_max_locale[ULOC_FULLNAME_CAPACITY];
- uloc_toLanguageTag(icu_base_max_locale, base_max_locale,
- ULOC_FULLNAME_CAPACITY, FALSE, &error);
-
- // de_DE -> de-DE
- char base_locale[ULOC_FULLNAME_CAPACITY];
- uloc_toLanguageTag(
- icu_base_locale, base_locale, ULOC_FULLNAME_CAPACITY, FALSE, &error);
-
- if (U_FAILURE(error)) {
- return isolate->Throw(*factory->illegal_argument_string());
- }
-
- Handle<JSObject> result = factory->NewJSObject(isolate->object_function());
- Handle<String> value = factory->NewStringFromAsciiChecked(base_max_locale);
- JSObject::AddProperty(result, maximized, value, NONE);
- value = factory->NewStringFromAsciiChecked(base_locale);
- JSObject::AddProperty(result, base, value, NONE);
- output->set(i, *result);
- }
-
- Handle<JSArray> result = factory->NewJSArrayWithElements(output);
- result->set_length(Smi::FromInt(length));
- return *result;
-}
-
-
-RUNTIME_FUNCTION(Runtime_IsInitializedIntlObject) {
- HandleScope scope(isolate);
-
- DCHECK(args.length() == 1);
-
- CONVERT_ARG_HANDLE_CHECKED(Object, input, 0);
-
- if (!input->IsJSObject()) return isolate->heap()->false_value();
- Handle<JSObject> obj = Handle<JSObject>::cast(input);
-
- Handle<String> marker = isolate->factory()->intl_initialized_marker_string();
- Handle<Object> tag(obj->GetHiddenProperty(marker), isolate);
- return isolate->heap()->ToBoolean(!tag->IsTheHole());
-}
-
-
-RUNTIME_FUNCTION(Runtime_IsInitializedIntlObjectOfType) {
- HandleScope scope(isolate);
-
- DCHECK(args.length() == 2);
-
- CONVERT_ARG_HANDLE_CHECKED(Object, input, 0);
- CONVERT_ARG_HANDLE_CHECKED(String, expected_type, 1);
-
- if (!input->IsJSObject()) return isolate->heap()->false_value();
- Handle<JSObject> obj = Handle<JSObject>::cast(input);
-
- Handle<String> marker = isolate->factory()->intl_initialized_marker_string();
- Handle<Object> tag(obj->GetHiddenProperty(marker), isolate);
- return isolate->heap()->ToBoolean(
- tag->IsString() && String::cast(*tag)->Equals(*expected_type));
-}
-
-
-RUNTIME_FUNCTION(Runtime_MarkAsInitializedIntlObjectOfType) {
- HandleScope scope(isolate);
-
- DCHECK(args.length() == 3);
-
- CONVERT_ARG_HANDLE_CHECKED(JSObject, input, 0);
- CONVERT_ARG_HANDLE_CHECKED(String, type, 1);
- CONVERT_ARG_HANDLE_CHECKED(JSObject, impl, 2);
-
- Handle<String> marker = isolate->factory()->intl_initialized_marker_string();
- JSObject::SetHiddenProperty(input, marker, type);
-
- marker = isolate->factory()->intl_impl_object_string();
- JSObject::SetHiddenProperty(input, marker, impl);
-
- return isolate->heap()->undefined_value();
-}
-
-
-RUNTIME_FUNCTION(Runtime_GetImplFromInitializedIntlObject) {
- HandleScope scope(isolate);
-
- DCHECK(args.length() == 1);
-
- CONVERT_ARG_HANDLE_CHECKED(Object, input, 0);
-
- if (!input->IsJSObject()) {
- Vector< Handle<Object> > arguments = HandleVector(&input, 1);
- THROW_NEW_ERROR_RETURN_FAILURE(isolate,
- NewTypeError("not_intl_object", arguments));
- }
-
- Handle<JSObject> obj = Handle<JSObject>::cast(input);
-
- Handle<String> marker = isolate->factory()->intl_impl_object_string();
- Handle<Object> impl(obj->GetHiddenProperty(marker), isolate);
- if (impl->IsTheHole()) {
- Vector< Handle<Object> > arguments = HandleVector(&obj, 1);
- THROW_NEW_ERROR_RETURN_FAILURE(isolate,
- NewTypeError("not_intl_object", arguments));
- }
- return *impl;
-}
-
-
-RUNTIME_FUNCTION(Runtime_CreateDateTimeFormat) {
- HandleScope scope(isolate);
-
- DCHECK(args.length() == 3);
-
- CONVERT_ARG_HANDLE_CHECKED(String, locale, 0);
- CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1);
- CONVERT_ARG_HANDLE_CHECKED(JSObject, resolved, 2);
-
- Handle<ObjectTemplateInfo> date_format_template =
- I18N::GetTemplate(isolate);
-
- // Create an empty object wrapper.
- Handle<JSObject> local_object;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, local_object,
- Execution::InstantiateObject(date_format_template));
-
- // Set date time formatter as internal field of the resulting JS object.
- icu::SimpleDateFormat* date_format = DateFormat::InitializeDateTimeFormat(
- isolate, locale, options, resolved);
-
- if (!date_format) return isolate->ThrowIllegalOperation();
-
- local_object->SetInternalField(0, reinterpret_cast<Smi*>(date_format));
-
- Factory* factory = isolate->factory();
- Handle<String> key = factory->NewStringFromStaticChars("dateFormat");
- Handle<String> value = factory->NewStringFromStaticChars("valid");
- JSObject::AddProperty(local_object, key, value, NONE);
-
- // Make object handle weak so we can delete the data format once GC kicks in.
- Handle<Object> wrapper = isolate->global_handles()->Create(*local_object);
- GlobalHandles::MakeWeak(wrapper.location(),
- reinterpret_cast<void*>(wrapper.location()),
- DateFormat::DeleteDateFormat);
- return *local_object;
-}
-
-
-RUNTIME_FUNCTION(Runtime_InternalDateFormat) {
- HandleScope scope(isolate);
-
- DCHECK(args.length() == 2);
-
- CONVERT_ARG_HANDLE_CHECKED(JSObject, date_format_holder, 0);
- CONVERT_ARG_HANDLE_CHECKED(JSDate, date, 1);
-
- Handle<Object> value;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, value, Execution::ToNumber(isolate, date));
-
- icu::SimpleDateFormat* date_format =
- DateFormat::UnpackDateFormat(isolate, date_format_holder);
- if (!date_format) return isolate->ThrowIllegalOperation();
-
- icu::UnicodeString result;
- date_format->format(value->Number(), result);
-
- Handle<String> result_str;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result_str,
- isolate->factory()->NewStringFromTwoByte(
- Vector<const uint16_t>(
- reinterpret_cast<const uint16_t*>(result.getBuffer()),
- result.length())));
- return *result_str;
-}
-
-
-RUNTIME_FUNCTION(Runtime_InternalDateParse) {
- HandleScope scope(isolate);
-
- DCHECK(args.length() == 2);
-
- CONVERT_ARG_HANDLE_CHECKED(JSObject, date_format_holder, 0);
- CONVERT_ARG_HANDLE_CHECKED(String, date_string, 1);
-
- v8::String::Utf8Value utf8_date(v8::Utils::ToLocal(date_string));
- icu::UnicodeString u_date(icu::UnicodeString::fromUTF8(*utf8_date));
- icu::SimpleDateFormat* date_format =
- DateFormat::UnpackDateFormat(isolate, date_format_holder);
- if (!date_format) return isolate->ThrowIllegalOperation();
-
- UErrorCode status = U_ZERO_ERROR;
- UDate date = date_format->parse(u_date, status);
- if (U_FAILURE(status)) return isolate->heap()->undefined_value();
-
- Handle<Object> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result,
- Execution::NewDate(isolate, static_cast<double>(date)));
- DCHECK(result->IsJSDate());
- return *result;
-}
-
-
-RUNTIME_FUNCTION(Runtime_CreateNumberFormat) {
- HandleScope scope(isolate);
-
- DCHECK(args.length() == 3);
-
- CONVERT_ARG_HANDLE_CHECKED(String, locale, 0);
- CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1);
- CONVERT_ARG_HANDLE_CHECKED(JSObject, resolved, 2);
-
- Handle<ObjectTemplateInfo> number_format_template =
- I18N::GetTemplate(isolate);
-
- // Create an empty object wrapper.
- Handle<JSObject> local_object;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, local_object,
- Execution::InstantiateObject(number_format_template));
-
- // Set number formatter as internal field of the resulting JS object.
- icu::DecimalFormat* number_format = NumberFormat::InitializeNumberFormat(
- isolate, locale, options, resolved);
-
- if (!number_format) return isolate->ThrowIllegalOperation();
-
- local_object->SetInternalField(0, reinterpret_cast<Smi*>(number_format));
-
- Factory* factory = isolate->factory();
- Handle<String> key = factory->NewStringFromStaticChars("numberFormat");
- Handle<String> value = factory->NewStringFromStaticChars("valid");
- JSObject::AddProperty(local_object, key, value, NONE);
-
- Handle<Object> wrapper = isolate->global_handles()->Create(*local_object);
- GlobalHandles::MakeWeak(wrapper.location(),
- reinterpret_cast<void*>(wrapper.location()),
- NumberFormat::DeleteNumberFormat);
- return *local_object;
-}
-
-
-RUNTIME_FUNCTION(Runtime_InternalNumberFormat) {
- HandleScope scope(isolate);
-
- DCHECK(args.length() == 2);
-
- CONVERT_ARG_HANDLE_CHECKED(JSObject, number_format_holder, 0);
- CONVERT_ARG_HANDLE_CHECKED(Object, number, 1);
-
- Handle<Object> value;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, value, Execution::ToNumber(isolate, number));
-
- icu::DecimalFormat* number_format =
- NumberFormat::UnpackNumberFormat(isolate, number_format_holder);
- if (!number_format) return isolate->ThrowIllegalOperation();
-
- icu::UnicodeString result;
- number_format->format(value->Number(), result);
-
- Handle<String> result_str;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result_str,
- isolate->factory()->NewStringFromTwoByte(
- Vector<const uint16_t>(
- reinterpret_cast<const uint16_t*>(result.getBuffer()),
- result.length())));
- return *result_str;
-}
-
-
-RUNTIME_FUNCTION(Runtime_InternalNumberParse) {
- HandleScope scope(isolate);
-
- DCHECK(args.length() == 2);
-
- CONVERT_ARG_HANDLE_CHECKED(JSObject, number_format_holder, 0);
- CONVERT_ARG_HANDLE_CHECKED(String, number_string, 1);
-
- v8::String::Utf8Value utf8_number(v8::Utils::ToLocal(number_string));
- icu::UnicodeString u_number(icu::UnicodeString::fromUTF8(*utf8_number));
- icu::DecimalFormat* number_format =
- NumberFormat::UnpackNumberFormat(isolate, number_format_holder);
- if (!number_format) return isolate->ThrowIllegalOperation();
-
- UErrorCode status = U_ZERO_ERROR;
- icu::Formattable result;
- // ICU 4.6 doesn't support parseCurrency call. We need to wait for ICU49
- // to be part of Chrome.
- // TODO(cira): Include currency parsing code using parseCurrency call.
- // We need to check if the formatter parses all currencies or only the
- // one it was constructed with (it will impact the API - how to return ISO
- // code and the value).
- number_format->parse(u_number, result, status);
- if (U_FAILURE(status)) return isolate->heap()->undefined_value();
-
- switch (result.getType()) {
- case icu::Formattable::kDouble:
- return *isolate->factory()->NewNumber(result.getDouble());
- case icu::Formattable::kLong:
- return *isolate->factory()->NewNumberFromInt(result.getLong());
- case icu::Formattable::kInt64:
- return *isolate->factory()->NewNumber(
- static_cast<double>(result.getInt64()));
- default:
- return isolate->heap()->undefined_value();
- }
-}
-
-
-RUNTIME_FUNCTION(Runtime_CreateCollator) {
- HandleScope scope(isolate);
-
- DCHECK(args.length() == 3);
-
- CONVERT_ARG_HANDLE_CHECKED(String, locale, 0);
- CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1);
- CONVERT_ARG_HANDLE_CHECKED(JSObject, resolved, 2);
-
- Handle<ObjectTemplateInfo> collator_template = I18N::GetTemplate(isolate);
-
- // Create an empty object wrapper.
- Handle<JSObject> local_object;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, local_object, Execution::InstantiateObject(collator_template));
-
- // Set collator as internal field of the resulting JS object.
- icu::Collator* collator = Collator::InitializeCollator(
- isolate, locale, options, resolved);
-
- if (!collator) return isolate->ThrowIllegalOperation();
-
- local_object->SetInternalField(0, reinterpret_cast<Smi*>(collator));
-
- Factory* factory = isolate->factory();
- Handle<String> key = factory->NewStringFromStaticChars("collator");
- Handle<String> value = factory->NewStringFromStaticChars("valid");
- JSObject::AddProperty(local_object, key, value, NONE);
-
- Handle<Object> wrapper = isolate->global_handles()->Create(*local_object);
- GlobalHandles::MakeWeak(wrapper.location(),
- reinterpret_cast<void*>(wrapper.location()),
- Collator::DeleteCollator);
- return *local_object;
-}
-
-
-RUNTIME_FUNCTION(Runtime_InternalCompare) {
- HandleScope scope(isolate);
-
- DCHECK(args.length() == 3);
-
- CONVERT_ARG_HANDLE_CHECKED(JSObject, collator_holder, 0);
- CONVERT_ARG_HANDLE_CHECKED(String, string1, 1);
- CONVERT_ARG_HANDLE_CHECKED(String, string2, 2);
-
- icu::Collator* collator = Collator::UnpackCollator(isolate, collator_holder);
- if (!collator) return isolate->ThrowIllegalOperation();
-
- v8::String::Value string_value1(v8::Utils::ToLocal(string1));
- v8::String::Value string_value2(v8::Utils::ToLocal(string2));
- const UChar* u_string1 = reinterpret_cast<const UChar*>(*string_value1);
- const UChar* u_string2 = reinterpret_cast<const UChar*>(*string_value2);
- UErrorCode status = U_ZERO_ERROR;
- UCollationResult result = collator->compare(u_string1,
- string_value1.length(),
- u_string2,
- string_value2.length(),
- status);
- if (U_FAILURE(status)) return isolate->ThrowIllegalOperation();
-
- return *isolate->factory()->NewNumberFromInt(result);
-}
-
-
-RUNTIME_FUNCTION(Runtime_StringNormalize) {
- HandleScope scope(isolate);
- static const UNormalizationMode normalizationForms[] =
- { UNORM_NFC, UNORM_NFD, UNORM_NFKC, UNORM_NFKD };
-
- DCHECK(args.length() == 2);
-
- 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) < arraysize(normalizationForms));
-
- v8::String::Value string_value(v8::Utils::ToLocal(stringValue));
- const UChar* u_value = reinterpret_cast<const UChar*>(*string_value);
-
- // TODO(mnita): check Normalizer2 (not available in ICU 46)
- UErrorCode status = U_ZERO_ERROR;
- icu::UnicodeString result;
- icu::Normalizer::normalize(u_value, normalizationForms[form_id], 0,
- result, status);
- if (U_FAILURE(status)) {
- return isolate->heap()->undefined_value();
- }
-
- Handle<String> result_str;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result_str,
- isolate->factory()->NewStringFromTwoByte(
- Vector<const uint16_t>(
- reinterpret_cast<const uint16_t*>(result.getBuffer()),
- result.length())));
- return *result_str;
-}
-
-
-RUNTIME_FUNCTION(Runtime_CreateBreakIterator) {
- HandleScope scope(isolate);
-
- DCHECK(args.length() == 3);
-
- CONVERT_ARG_HANDLE_CHECKED(String, locale, 0);
- CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1);
- CONVERT_ARG_HANDLE_CHECKED(JSObject, resolved, 2);
-
- Handle<ObjectTemplateInfo> break_iterator_template =
- I18N::GetTemplate2(isolate);
-
- // Create an empty object wrapper.
- Handle<JSObject> local_object;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, local_object,
- Execution::InstantiateObject(break_iterator_template));
-
- // Set break iterator as internal field of the resulting JS object.
- icu::BreakIterator* break_iterator = BreakIterator::InitializeBreakIterator(
- isolate, locale, options, resolved);
-
- if (!break_iterator) return isolate->ThrowIllegalOperation();
-
- local_object->SetInternalField(0, reinterpret_cast<Smi*>(break_iterator));
- // Make sure that the pointer to adopted text is NULL.
- local_object->SetInternalField(1, reinterpret_cast<Smi*>(NULL));
-
- Factory* factory = isolate->factory();
- Handle<String> key = factory->NewStringFromStaticChars("breakIterator");
- Handle<String> value = factory->NewStringFromStaticChars("valid");
- JSObject::AddProperty(local_object, key, value, NONE);
-
- // Make object handle weak so we can delete the break iterator once GC kicks
- // in.
- Handle<Object> wrapper = isolate->global_handles()->Create(*local_object);
- GlobalHandles::MakeWeak(wrapper.location(),
- reinterpret_cast<void*>(wrapper.location()),
- BreakIterator::DeleteBreakIterator);
- return *local_object;
-}
-
-
-RUNTIME_FUNCTION(Runtime_BreakIteratorAdoptText) {
- HandleScope scope(isolate);
-
- DCHECK(args.length() == 2);
-
- CONVERT_ARG_HANDLE_CHECKED(JSObject, break_iterator_holder, 0);
- CONVERT_ARG_HANDLE_CHECKED(String, text, 1);
-
- icu::BreakIterator* break_iterator =
- BreakIterator::UnpackBreakIterator(isolate, break_iterator_holder);
- if (!break_iterator) return isolate->ThrowIllegalOperation();
-
- icu::UnicodeString* u_text = reinterpret_cast<icu::UnicodeString*>(
- break_iterator_holder->GetInternalField(1));
- delete u_text;
-
- v8::String::Value text_value(v8::Utils::ToLocal(text));
- u_text = new icu::UnicodeString(
- reinterpret_cast<const UChar*>(*text_value), text_value.length());
- break_iterator_holder->SetInternalField(1, reinterpret_cast<Smi*>(u_text));
-
- break_iterator->setText(*u_text);
-
- return isolate->heap()->undefined_value();
-}
-
-
-RUNTIME_FUNCTION(Runtime_BreakIteratorFirst) {
- HandleScope scope(isolate);
-
- DCHECK(args.length() == 1);
-
- CONVERT_ARG_HANDLE_CHECKED(JSObject, break_iterator_holder, 0);
-
- icu::BreakIterator* break_iterator =
- BreakIterator::UnpackBreakIterator(isolate, break_iterator_holder);
- if (!break_iterator) return isolate->ThrowIllegalOperation();
-
- return *isolate->factory()->NewNumberFromInt(break_iterator->first());
-}
-
-
-RUNTIME_FUNCTION(Runtime_BreakIteratorNext) {
- HandleScope scope(isolate);
-
- DCHECK(args.length() == 1);
-
- CONVERT_ARG_HANDLE_CHECKED(JSObject, break_iterator_holder, 0);
-
- icu::BreakIterator* break_iterator =
- BreakIterator::UnpackBreakIterator(isolate, break_iterator_holder);
- if (!break_iterator) return isolate->ThrowIllegalOperation();
-
- return *isolate->factory()->NewNumberFromInt(break_iterator->next());
-}
-
-
-RUNTIME_FUNCTION(Runtime_BreakIteratorCurrent) {
- HandleScope scope(isolate);
-
- DCHECK(args.length() == 1);
-
- CONVERT_ARG_HANDLE_CHECKED(JSObject, break_iterator_holder, 0);
-
- icu::BreakIterator* break_iterator =
- BreakIterator::UnpackBreakIterator(isolate, break_iterator_holder);
- if (!break_iterator) return isolate->ThrowIllegalOperation();
-
- return *isolate->factory()->NewNumberFromInt(break_iterator->current());
-}
-
-
-RUNTIME_FUNCTION(Runtime_BreakIteratorBreakType) {
- HandleScope scope(isolate);
-
- DCHECK(args.length() == 1);
-
- CONVERT_ARG_HANDLE_CHECKED(JSObject, break_iterator_holder, 0);
-
- icu::BreakIterator* break_iterator =
- BreakIterator::UnpackBreakIterator(isolate, break_iterator_holder);
- if (!break_iterator) return isolate->ThrowIllegalOperation();
-
- // TODO(cira): Remove cast once ICU fixes base BreakIterator class.
- icu::RuleBasedBreakIterator* rule_based_iterator =
- static_cast<icu::RuleBasedBreakIterator*>(break_iterator);
- int32_t status = rule_based_iterator->getRuleStatus();
- // Keep return values in sync with JavaScript BreakType enum.
- if (status >= UBRK_WORD_NONE && status < UBRK_WORD_NONE_LIMIT) {
- return *isolate->factory()->NewStringFromStaticChars("none");
- } else if (status >= UBRK_WORD_NUMBER && status < UBRK_WORD_NUMBER_LIMIT) {
- return *isolate->factory()->number_string();
- } else if (status >= UBRK_WORD_LETTER && status < UBRK_WORD_LETTER_LIMIT) {
- return *isolate->factory()->NewStringFromStaticChars("letter");
- } else if (status >= UBRK_WORD_KANA && status < UBRK_WORD_KANA_LIMIT) {
- return *isolate->factory()->NewStringFromStaticChars("kana");
- } else if (status >= UBRK_WORD_IDEO && status < UBRK_WORD_IDEO_LIMIT) {
- return *isolate->factory()->NewStringFromStaticChars("ideo");
- } else {
- return *isolate->factory()->NewStringFromStaticChars("unknown");
- }
-}
-#endif // V8_I18N_SUPPORT
-
-
-// Finds the script object from the script data. NOTE: This operation uses
-// heap traversal to find the function generated for the source position
-// for the requested break point. For lazily compiled functions several heap
-// traversals might be required rendering this operation as a rather slow
-// operation. However for setting break points which is normally done through
-// some kind of user interaction the performance is not crucial.
-static Handle<Object> Runtime_GetScriptFromScriptName(
- Handle<String> script_name) {
- // Scan the heap for Script objects to find the script with the requested
- // script data.
- Handle<Script> script;
- Factory* factory = script_name->GetIsolate()->factory();
- Heap* heap = script_name->GetHeap();
- HeapIterator iterator(heap);
- HeapObject* obj = NULL;
- while (script.is_null() && ((obj = iterator.next()) != NULL)) {
- // If a script is found check if it has the script data requested.
- if (obj->IsScript()) {
- if (Script::cast(obj)->name()->IsString()) {
- if (String::cast(Script::cast(obj)->name())->Equals(*script_name)) {
- script = Handle<Script>(Script::cast(obj));
- }
- }
- }
- }
-
- // If no script with the requested script data is found return undefined.
- if (script.is_null()) return factory->undefined_value();
-
- // Return the script found.
- return Script::GetWrapper(script);
-}
-
-
-// Get the script object from script data. NOTE: Regarding performance
-// see the NOTE for GetScriptFromScriptData.
-// args[0]: script data for the script to find the source for
-RUNTIME_FUNCTION(Runtime_GetScript) {
- HandleScope scope(isolate);
-
- DCHECK(args.length() == 1);
-
- CONVERT_ARG_CHECKED(String, script_name, 0);
-
- // Find the requested script.
- Handle<Object> result =
- Runtime_GetScriptFromScriptName(Handle<String>(script_name));
- return *result;
-}
+ // Find the requested script.
+ Handle<Object> result =
+ Runtime_GetScriptFromScriptName(Handle<String>(script_name));
+ return *result;
+}
// Collect the raw data for a stack trace. Returns an array of 4
@@ -14679,8 +13481,8 @@ RUNTIME_FUNCTION(Runtime_Abort) {
SealHandleScope shs(isolate);
DCHECK(args.length() == 1);
CONVERT_SMI_ARG_CHECKED(message_id, 0);
- const char* message = GetBailoutReason(
- static_cast<BailoutReason>(message_id));
+ const char* message =
+ GetBailoutReason(static_cast<BailoutReason>(message_id));
base::OS::PrintError("abort: %s\n", message);
isolate->PrintStack(stderr);
base::OS::Abort();
@@ -14770,8 +13572,7 @@ RUNTIME_FUNCTION(Runtime_GetFromCache) {
return cache->get(finger_index + 1);
}
- for (int i = finger_index - 2;
- i >= JSFunctionResultCache::kEntriesIndex;
+ for (int i = finger_index - 2; i >= JSFunctionResultCache::kEntriesIndex;
i -= 2) {
o = cache->get(i);
if (o == key) {
@@ -14800,11 +13601,11 @@ RUNTIME_FUNCTION(Runtime_GetFromCache) {
Handle<Object> value;
{
Handle<JSFunction> factory(JSFunction::cast(
- cache_handle->get(JSFunctionResultCache::kFactoryIndex)));
+ cache_handle->get(JSFunctionResultCache::kFactoryIndex)));
// TODO(antonm): consider passing a receiver when constructing a cache.
Handle<JSObject> receiver(isolate->global_proxy());
// This handle is nor shared, nor used later, so it's safe.
- Handle<Object> argv[] = { key_handle };
+ Handle<Object> argv[] = {key_handle};
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, value,
Execution::Call(isolate, factory, receiver, arraysize(argv), argv));
@@ -14873,10 +13674,9 @@ RUNTIME_FUNCTION(Runtime_MessageGetScript) {
RUNTIME_FUNCTION(Runtime_ListNatives) {
HandleScope scope(isolate);
DCHECK(args.length() == 0);
-#define COUNT_ENTRY(Name, argc, ressize) + 1
- int entry_count = 0
- RUNTIME_FUNCTION_LIST(COUNT_ENTRY)
- INLINE_FUNCTION_LIST(COUNT_ENTRY)
+#define COUNT_ENTRY(Name, argc, ressize) +1
+ int entry_count =
+ 0 RUNTIME_FUNCTION_LIST(COUNT_ENTRY) INLINE_FUNCTION_LIST(COUNT_ENTRY)
INLINE_OPTIMIZED_FUNCTION_LIST(COUNT_ENTRY);
#undef COUNT_ENTRY
Factory* factory = isolate->factory();
@@ -14918,10 +13718,10 @@ RUNTIME_FUNCTION(Runtime_IS_VAR) {
}
-#define ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(Name) \
- RUNTIME_FUNCTION(Runtime_Has##Name) { \
- CONVERT_ARG_CHECKED(JSObject, obj, 0); \
- return isolate->heap()->ToBoolean(obj->Has##Name()); \
+#define ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(Name) \
+ RUNTIME_FUNCTION(Runtime_Has##Name) { \
+ CONVERT_ARG_CHECKED(JSObject, obj, 0); \
+ return isolate->heap()->ToBoolean(obj->Has##Name()); \
}
ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastSmiElements)
@@ -14938,10 +13738,10 @@ ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastProperties)
#undef ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION
-#define TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION(Type, type, TYPE, ctype, size) \
- RUNTIME_FUNCTION(Runtime_HasExternal##Type##Elements) { \
- CONVERT_ARG_CHECKED(JSObject, obj, 0); \
- return isolate->heap()->ToBoolean(obj->HasExternal##Type##Elements()); \
+#define TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION(Type, type, TYPE, ctype, size) \
+ RUNTIME_FUNCTION(Runtime_HasExternal##Type##Elements) { \
+ CONVERT_ARG_CHECKED(JSObject, obj, 0); \
+ return isolate->heap()->ToBoolean(obj->HasExternal##Type##Elements()); \
}
TYPED_ARRAYS(TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION)
@@ -14949,10 +13749,10 @@ TYPED_ARRAYS(TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION)
#undef TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION
-#define FIXED_TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION(Type, type, TYPE, ctype, s) \
- RUNTIME_FUNCTION(Runtime_HasFixed##Type##Elements) { \
- CONVERT_ARG_CHECKED(JSObject, obj, 0); \
- return isolate->heap()->ToBoolean(obj->HasFixed##Type##Elements()); \
+#define FIXED_TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION(Type, type, TYPE, ctype, s) \
+ RUNTIME_FUNCTION(Runtime_HasFixed##Type##Elements) { \
+ CONVERT_ARG_CHECKED(JSObject, obj, 0); \
+ return isolate->heap()->ToBoolean(obj->HasFixed##Type##Elements()); \
}
TYPED_ARRAYS(FIXED_TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION)
@@ -15105,9 +13905,9 @@ RUNTIME_FUNCTION(Runtime_GetObjectContextNotifierPerformChange) {
static Object* ArrayConstructorCommon(Isolate* isolate,
- Handle<JSFunction> constructor,
- Handle<AllocationSite> site,
- Arguments* caller_args) {
+ Handle<JSFunction> constructor,
+ Handle<AllocationSite> site,
+ Arguments* caller_args) {
Factory* factory = isolate->factory();
bool holey = false;
@@ -15171,8 +13971,7 @@ static Object* ArrayConstructorCommon(Isolate* isolate,
RETURN_FAILURE_ON_EXCEPTION(
isolate, ArrayConstructInitializeElements(array, caller_args));
if (!site.is_null() &&
- (old_kind != array->GetElementsKind() ||
- !can_use_type_feedback)) {
+ (old_kind != array->GetElementsKind() || !can_use_type_feedback)) {
// The arguments passed in caused a transition. This kind of complexity
// can't be dealt with in the inlined hydrogen array constructor case.
// We must mark the allocationsite as un-inlinable.
@@ -15193,9 +13992,8 @@ RUNTIME_FUNCTION(Runtime_ArrayConstructor) {
bool no_caller_args = args.length() == 2;
DCHECK(no_caller_args || args.length() == 4);
int parameters_start = no_caller_args ? 0 : 1;
- Arguments* caller_args = no_caller_args
- ? &empty_args
- : reinterpret_cast<Arguments*>(args[0]);
+ Arguments* caller_args =
+ no_caller_args ? &empty_args : reinterpret_cast<Arguments*>(args[0]);
CONVERT_ARG_HANDLE_CHECKED(JSFunction, constructor, parameters_start);
CONVERT_ARG_HANDLE_CHECKED(Object, type_info, parameters_start + 1);
#ifdef DEBUG
@@ -15212,10 +14010,7 @@ RUNTIME_FUNCTION(Runtime_ArrayConstructor) {
DCHECK(!site->SitePointsToLiteral());
}
- return ArrayConstructorCommon(isolate,
- constructor,
- site,
- caller_args);
+ return ArrayConstructorCommon(isolate, constructor, site, caller_args);
}
@@ -15225,9 +14020,8 @@ RUNTIME_FUNCTION(Runtime_InternalArrayConstructor) {
bool no_caller_args = args.length() == 1;
DCHECK(no_caller_args || args.length() == 3);
int parameters_start = no_caller_args ? 0 : 1;
- Arguments* caller_args = no_caller_args
- ? &empty_args
- : reinterpret_cast<Arguments*>(args[0]);
+ Arguments* caller_args =
+ no_caller_args ? &empty_args : reinterpret_cast<Arguments*>(args[0]);
CONVERT_ARG_HANDLE_CHECKED(JSFunction, constructor, parameters_start);
#ifdef DEBUG
if (!no_caller_args) {
@@ -15235,10 +14029,8 @@ RUNTIME_FUNCTION(Runtime_InternalArrayConstructor) {
DCHECK(arg_count == caller_args->length());
}
#endif
- return ArrayConstructorCommon(isolate,
- constructor,
- Handle<AllocationSite>::null(),
- caller_args);
+ return ArrayConstructorCommon(isolate, constructor,
+ Handle<AllocationSite>::null(), caller_args);
}
@@ -15700,11 +14492,8 @@ RUNTIME_FUNCTION(RuntimeReference_DebugIsActive) {
static const Runtime::Function kIntrinsicFunctions[] = {
- RUNTIME_FUNCTION_LIST(F)
- INLINE_OPTIMIZED_FUNCTION_LIST(F)
- INLINE_FUNCTION_LIST(I)
- INLINE_OPTIMIZED_FUNCTION_LIST(IO)
-};
+ RUNTIME_FUNCTION_LIST(F) INLINE_OPTIMIZED_FUNCTION_LIST(F)
+ INLINE_FUNCTION_LIST(I) INLINE_OPTIMIZED_FUNCTION_LIST(IO)};
#undef IO
#undef I
@@ -15719,8 +14508,7 @@ void Runtime::InitializeIntrinsicFunctionNames(Isolate* isolate,
const char* name = kIntrinsicFunctions[i].name;
if (name == NULL) continue;
Handle<NameDictionary> new_dict = NameDictionary::Add(
- dict,
- isolate->factory()->InternalizeUtf8String(name),
+ dict, isolate->factory()->InternalizeUtf8String(name),
Handle<Smi>(Smi::FromInt(i), isolate),
PropertyDetails(NONE, NORMAL, Representation::None()));
// The dictionary does not need to grow.
@@ -15754,5 +14542,5 @@ const Runtime::Function* Runtime::FunctionForEntry(Address entry) {
const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) {
return &(kIntrinsicFunctions[static_cast<int>(id)]);
}
-
-} } // namespace v8::internal
+}
+} // namespace v8::internal
« no previous file with comments | « src/runtime/runtime.h ('k') | src/runtime/runtime-i18n.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698