| Index: src/runtime.cc
|
| ===================================================================
|
| --- src/runtime.cc (revision 7267)
|
| +++ src/runtime.cc (working copy)
|
| @@ -59,7 +59,7 @@
|
|
|
|
|
| #define RUNTIME_ASSERT(value) \
|
| - if (!(value)) return Top::ThrowIllegalOperation();
|
| + if (!(value)) return isolate->ThrowIllegalOperation();
|
|
|
| // 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
|
| @@ -100,16 +100,15 @@
|
| RUNTIME_ASSERT(obj->IsNumber()); \
|
| type name = NumberTo##Type(obj);
|
|
|
| -// Non-reentrant string buffer for efficient general use in this file.
|
| -static StaticResource<StringInputBuffer> runtime_string_input_buffer;
|
|
|
| +MUST_USE_RESULT static MaybeObject* DeepCopyBoilerplate(Isolate* isolate,
|
| + JSObject* boilerplate) {
|
| + StackLimitCheck check(isolate);
|
| + if (check.HasOverflowed()) return isolate->StackOverflow();
|
|
|
| -MUST_USE_RESULT static MaybeObject* DeepCopyBoilerplate(JSObject* boilerplate) {
|
| - StackLimitCheck check;
|
| - if (check.HasOverflowed()) return Top::StackOverflow();
|
| -
|
| + Heap* heap = isolate->heap();
|
| Object* result;
|
| - { MaybeObject* maybe_result = Heap::CopyJSObject(boilerplate);
|
| + { MaybeObject* maybe_result = heap->CopyJSObject(boilerplate);
|
| if (!maybe_result->ToObject(&result)) return maybe_result;
|
| }
|
| JSObject* copy = JSObject::cast(result);
|
| @@ -121,7 +120,7 @@
|
| Object* value = properties->get(i);
|
| if (value->IsJSObject()) {
|
| JSObject* js_object = JSObject::cast(value);
|
| - { MaybeObject* maybe_result = DeepCopyBoilerplate(js_object);
|
| + { MaybeObject* maybe_result = DeepCopyBoilerplate(isolate, js_object);
|
| if (!maybe_result->ToObject(&result)) return maybe_result;
|
| }
|
| properties->set(i, result);
|
| @@ -132,7 +131,7 @@
|
| Object* value = copy->InObjectPropertyAt(i);
|
| if (value->IsJSObject()) {
|
| JSObject* js_object = JSObject::cast(value);
|
| - { MaybeObject* maybe_result = DeepCopyBoilerplate(js_object);
|
| + { MaybeObject* maybe_result = DeepCopyBoilerplate(isolate, js_object);
|
| if (!maybe_result->ToObject(&result)) return maybe_result;
|
| }
|
| copy->InObjectPropertyAtPut(i, result);
|
| @@ -140,7 +139,7 @@
|
| }
|
| } else {
|
| { MaybeObject* maybe_result =
|
| - Heap::AllocateFixedArray(copy->NumberOfLocalProperties(NONE));
|
| + heap->AllocateFixedArray(copy->NumberOfLocalProperties(NONE));
|
| if (!maybe_result->ToObject(&result)) return maybe_result;
|
| }
|
| FixedArray* names = FixedArray::cast(result);
|
| @@ -158,7 +157,7 @@
|
| copy->GetProperty(key_string, &attributes)->ToObjectUnchecked();
|
| if (value->IsJSObject()) {
|
| JSObject* js_object = JSObject::cast(value);
|
| - { MaybeObject* maybe_result = DeepCopyBoilerplate(js_object);
|
| + { MaybeObject* maybe_result = DeepCopyBoilerplate(isolate, js_object);
|
| if (!maybe_result->ToObject(&result)) return maybe_result;
|
| }
|
| { MaybeObject* maybe_result =
|
| @@ -176,8 +175,8 @@
|
| switch (copy->GetElementsKind()) {
|
| case JSObject::FAST_ELEMENTS: {
|
| FixedArray* elements = FixedArray::cast(copy->elements());
|
| - if (elements->map() == Heap::fixed_cow_array_map()) {
|
| - Counters::cow_arrays_created_runtime.Increment();
|
| + if (elements->map() == heap->fixed_cow_array_map()) {
|
| + isolate->counters()->cow_arrays_created_runtime()->Increment();
|
| #ifdef DEBUG
|
| for (int i = 0; i < elements->length(); i++) {
|
| ASSERT(!elements->get(i)->IsJSObject());
|
| @@ -188,7 +187,8 @@
|
| Object* value = elements->get(i);
|
| if (value->IsJSObject()) {
|
| JSObject* js_object = JSObject::cast(value);
|
| - { MaybeObject* maybe_result = DeepCopyBoilerplate(js_object);
|
| + { MaybeObject* maybe_result = DeepCopyBoilerplate(isolate,
|
| + js_object);
|
| if (!maybe_result->ToObject(&result)) return maybe_result;
|
| }
|
| elements->set(i, result);
|
| @@ -206,7 +206,8 @@
|
| Object* value = element_dictionary->ValueAt(i);
|
| if (value->IsJSObject()) {
|
| JSObject* js_object = JSObject::cast(value);
|
| - { MaybeObject* maybe_result = DeepCopyBoilerplate(js_object);
|
| + { MaybeObject* maybe_result = DeepCopyBoilerplate(isolate,
|
| + js_object);
|
| if (!maybe_result->ToObject(&result)) return maybe_result;
|
| }
|
| element_dictionary->ValueAtPut(i, result);
|
| @@ -223,15 +224,19 @@
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_CloneLiteralBoilerplate(Arguments args) {
|
| +static MaybeObject* Runtime_CloneLiteralBoilerplate(
|
| + RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| CONVERT_CHECKED(JSObject, boilerplate, args[0]);
|
| - return DeepCopyBoilerplate(boilerplate);
|
| + return DeepCopyBoilerplate(isolate, boilerplate);
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_CloneShallowLiteralBoilerplate(Arguments args) {
|
| +static MaybeObject* Runtime_CloneShallowLiteralBoilerplate(
|
| + RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| CONVERT_CHECKED(JSObject, boilerplate, args[0]);
|
| - return Heap::CopyJSObject(boilerplate);
|
| + return isolate->heap()->CopyJSObject(boilerplate);
|
| }
|
|
|
|
|
| @@ -239,6 +244,7 @@
|
| Handle<Context> context,
|
| Handle<FixedArray> constant_properties,
|
| bool* is_result_from_cache) {
|
| + Isolate* isolate = context->GetIsolate();
|
| int properties_length = constant_properties->length();
|
| int number_of_properties = properties_length / 2;
|
| if (FLAG_canonicalize_object_literal_maps) {
|
| @@ -265,7 +271,8 @@
|
| if ((number_of_symbol_keys == number_of_properties) &&
|
| (number_of_symbol_keys < kMaxKeys)) {
|
| // Create the fixed array with the key.
|
| - Handle<FixedArray> keys = Factory::NewFixedArray(number_of_symbol_keys);
|
| + Handle<FixedArray> keys =
|
| + isolate->factory()->NewFixedArray(number_of_symbol_keys);
|
| if (number_of_symbol_keys > 0) {
|
| int index = 0;
|
| for (int p = 0; p < properties_length; p += 2) {
|
| @@ -277,22 +284,24 @@
|
| ASSERT(index == number_of_symbol_keys);
|
| }
|
| *is_result_from_cache = true;
|
| - return Factory::ObjectLiteralMapFromCache(context, keys);
|
| + return isolate->factory()->ObjectLiteralMapFromCache(context, keys);
|
| }
|
| }
|
| *is_result_from_cache = false;
|
| - return Factory::CopyMap(
|
| + return isolate->factory()->CopyMap(
|
| Handle<Map>(context->object_function()->initial_map()),
|
| number_of_properties);
|
| }
|
|
|
|
|
| static Handle<Object> CreateLiteralBoilerplate(
|
| + Isolate* isolate,
|
| Handle<FixedArray> literals,
|
| Handle<FixedArray> constant_properties);
|
|
|
|
|
| static Handle<Object> CreateObjectLiteralBoilerplate(
|
| + Isolate* isolate,
|
| Handle<FixedArray> literals,
|
| Handle<FixedArray> constant_properties,
|
| bool should_have_fast_elements) {
|
| @@ -310,7 +319,7 @@
|
| constant_properties,
|
| &is_result_from_cache);
|
|
|
| - Handle<JSObject> boilerplate = Factory::NewJSObjectFromMap(map);
|
| + Handle<JSObject> boilerplate = isolate->factory()->NewJSObjectFromMap(map);
|
|
|
| // Normalize the elements of the boilerplate to save space if needed.
|
| if (!should_have_fast_elements) NormalizeElements(boilerplate);
|
| @@ -321,13 +330,13 @@
|
| length / 2,
|
| !is_result_from_cache);
|
| for (int index = 0; index < length; index +=2) {
|
| - Handle<Object> key(constant_properties->get(index+0));
|
| - Handle<Object> value(constant_properties->get(index+1));
|
| + 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 literal.
|
| Handle<FixedArray> array = Handle<FixedArray>::cast(value);
|
| - value = CreateLiteralBoilerplate(literals, array);
|
| + value = CreateLiteralBoilerplate(isolate, literals, array);
|
| if (value.is_null()) return value;
|
| }
|
| Handle<Object> result;
|
| @@ -358,7 +367,8 @@
|
| char arr[100];
|
| Vector<char> buffer(arr, ARRAY_SIZE(arr));
|
| const char* str = DoubleToCString(num, buffer);
|
| - Handle<String> name = Factory::NewStringFromAscii(CStrVector(str));
|
| + Handle<String> name =
|
| + isolate->factory()->NewStringFromAscii(CStrVector(str));
|
| result = SetLocalPropertyIgnoreAttributes(boilerplate, name,
|
| value, NONE);
|
| }
|
| @@ -375,16 +385,18 @@
|
|
|
|
|
| static Handle<Object> CreateArrayLiteralBoilerplate(
|
| + Isolate* isolate,
|
| Handle<FixedArray> literals,
|
| Handle<FixedArray> elements) {
|
| // Create the JSArray.
|
| Handle<JSFunction> constructor(
|
| JSFunction::GlobalContextFromLiterals(*literals)->array_function());
|
| - Handle<Object> object = Factory::NewJSObject(constructor);
|
| + Handle<Object> object = isolate->factory()->NewJSObject(constructor);
|
|
|
| - const bool is_cow = (elements->map() == Heap::fixed_cow_array_map());
|
| + const bool is_cow =
|
| + (elements->map() == isolate->heap()->fixed_cow_array_map());
|
| Handle<FixedArray> copied_elements =
|
| - is_cow ? elements : Factory::CopyFixedArray(elements);
|
| + is_cow ? elements : isolate->factory()->CopyFixedArray(elements);
|
|
|
| Handle<FixedArray> content = Handle<FixedArray>::cast(copied_elements);
|
| if (is_cow) {
|
| @@ -401,7 +413,7 @@
|
| // simple object literal.
|
| Handle<FixedArray> fa(FixedArray::cast(content->get(i)));
|
| Handle<Object> result =
|
| - CreateLiteralBoilerplate(literals, fa);
|
| + CreateLiteralBoilerplate(isolate, literals, fa);
|
| if (result.is_null()) return result;
|
| content->set(i, *result);
|
| }
|
| @@ -415,16 +427,17 @@
|
|
|
|
|
| static Handle<Object> CreateLiteralBoilerplate(
|
| + Isolate* isolate,
|
| Handle<FixedArray> literals,
|
| Handle<FixedArray> array) {
|
| Handle<FixedArray> elements = CompileTimeValue::GetElements(array);
|
| switch (CompileTimeValue::GetType(array)) {
|
| case CompileTimeValue::OBJECT_LITERAL_FAST_ELEMENTS:
|
| - return CreateObjectLiteralBoilerplate(literals, elements, true);
|
| + return CreateObjectLiteralBoilerplate(isolate, literals, elements, true);
|
| case CompileTimeValue::OBJECT_LITERAL_SLOW_ELEMENTS:
|
| - return CreateObjectLiteralBoilerplate(literals, elements, false);
|
| + return CreateObjectLiteralBoilerplate(isolate, literals, elements, false);
|
| case CompileTimeValue::ARRAY_LITERAL:
|
| - return CreateArrayLiteralBoilerplate(literals, elements);
|
| + return CreateArrayLiteralBoilerplate(isolate, literals, elements);
|
| default:
|
| UNREACHABLE();
|
| return Handle<Object>::null();
|
| @@ -432,19 +445,22 @@
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_CreateArrayLiteralBoilerplate(Arguments args) {
|
| +static MaybeObject* Runtime_CreateArrayLiteralBoilerplate(
|
| + RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| // Takes a FixedArray of elements containing the literal elements of
|
| // the array literal and produces JSArray with those elements.
|
| // Additionally takes the literals array of the surrounding function
|
| // which contains the context from which to get the Array function
|
| // to use for creating the array literal.
|
| - HandleScope scope;
|
| + HandleScope scope(isolate);
|
| ASSERT(args.length() == 3);
|
| CONVERT_ARG_CHECKED(FixedArray, literals, 0);
|
| CONVERT_SMI_CHECKED(literals_index, args[1]);
|
| CONVERT_ARG_CHECKED(FixedArray, elements, 2);
|
|
|
| - Handle<Object> object = CreateArrayLiteralBoilerplate(literals, elements);
|
| + Handle<Object> object =
|
| + CreateArrayLiteralBoilerplate(isolate, literals, elements);
|
| if (object.is_null()) return Failure::Exception();
|
|
|
| // Update the functions literal and return the boilerplate.
|
| @@ -453,8 +469,9 @@
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_CreateObjectLiteral(Arguments args) {
|
| - HandleScope scope;
|
| +static MaybeObject* Runtime_CreateObjectLiteral(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| + HandleScope scope(isolate);
|
| ASSERT(args.length() == 4);
|
| CONVERT_ARG_CHECKED(FixedArray, literals, 0);
|
| CONVERT_SMI_CHECKED(literals_index, args[1]);
|
| @@ -463,21 +480,24 @@
|
| bool should_have_fast_elements = fast_elements == 1;
|
|
|
| // Check if boilerplate exists. If not, create it first.
|
| - Handle<Object> boilerplate(literals->get(literals_index));
|
| - if (*boilerplate == Heap::undefined_value()) {
|
| - boilerplate = CreateObjectLiteralBoilerplate(literals,
|
| + Handle<Object> boilerplate(literals->get(literals_index), isolate);
|
| + if (*boilerplate == isolate->heap()->undefined_value()) {
|
| + boilerplate = CreateObjectLiteralBoilerplate(isolate,
|
| + literals,
|
| constant_properties,
|
| should_have_fast_elements);
|
| if (boilerplate.is_null()) return Failure::Exception();
|
| // Update the functions literal and return the boilerplate.
|
| literals->set(literals_index, *boilerplate);
|
| }
|
| - return DeepCopyBoilerplate(JSObject::cast(*boilerplate));
|
| + return DeepCopyBoilerplate(isolate, JSObject::cast(*boilerplate));
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_CreateObjectLiteralShallow(Arguments args) {
|
| - HandleScope scope;
|
| +static MaybeObject* Runtime_CreateObjectLiteralShallow(
|
| + RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| + HandleScope scope(isolate);
|
| ASSERT(args.length() == 4);
|
| CONVERT_ARG_CHECKED(FixedArray, literals, 0);
|
| CONVERT_SMI_CHECKED(literals_index, args[1]);
|
| @@ -486,70 +506,77 @@
|
| bool should_have_fast_elements = fast_elements == 1;
|
|
|
| // Check if boilerplate exists. If not, create it first.
|
| - Handle<Object> boilerplate(literals->get(literals_index));
|
| - if (*boilerplate == Heap::undefined_value()) {
|
| - boilerplate = CreateObjectLiteralBoilerplate(literals,
|
| + Handle<Object> boilerplate(literals->get(literals_index), isolate);
|
| + if (*boilerplate == isolate->heap()->undefined_value()) {
|
| + boilerplate = CreateObjectLiteralBoilerplate(isolate,
|
| + literals,
|
| constant_properties,
|
| should_have_fast_elements);
|
| if (boilerplate.is_null()) return Failure::Exception();
|
| // Update the functions literal and return the boilerplate.
|
| literals->set(literals_index, *boilerplate);
|
| }
|
| - return Heap::CopyJSObject(JSObject::cast(*boilerplate));
|
| + return isolate->heap()->CopyJSObject(JSObject::cast(*boilerplate));
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_CreateArrayLiteral(Arguments args) {
|
| - HandleScope scope;
|
| +static MaybeObject* Runtime_CreateArrayLiteral(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| + HandleScope scope(isolate);
|
| ASSERT(args.length() == 3);
|
| CONVERT_ARG_CHECKED(FixedArray, literals, 0);
|
| CONVERT_SMI_CHECKED(literals_index, args[1]);
|
| CONVERT_ARG_CHECKED(FixedArray, elements, 2);
|
|
|
| // Check if boilerplate exists. If not, create it first.
|
| - Handle<Object> boilerplate(literals->get(literals_index));
|
| - if (*boilerplate == Heap::undefined_value()) {
|
| - boilerplate = CreateArrayLiteralBoilerplate(literals, elements);
|
| + Handle<Object> boilerplate(literals->get(literals_index), isolate);
|
| + if (*boilerplate == isolate->heap()->undefined_value()) {
|
| + boilerplate = CreateArrayLiteralBoilerplate(isolate, literals, elements);
|
| if (boilerplate.is_null()) return Failure::Exception();
|
| // Update the functions literal and return the boilerplate.
|
| literals->set(literals_index, *boilerplate);
|
| }
|
| - return DeepCopyBoilerplate(JSObject::cast(*boilerplate));
|
| + return DeepCopyBoilerplate(isolate, JSObject::cast(*boilerplate));
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_CreateArrayLiteralShallow(Arguments args) {
|
| - HandleScope scope;
|
| +static MaybeObject* Runtime_CreateArrayLiteralShallow(
|
| + RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| + HandleScope scope(isolate);
|
| ASSERT(args.length() == 3);
|
| CONVERT_ARG_CHECKED(FixedArray, literals, 0);
|
| CONVERT_SMI_CHECKED(literals_index, args[1]);
|
| CONVERT_ARG_CHECKED(FixedArray, elements, 2);
|
|
|
| // Check if boilerplate exists. If not, create it first.
|
| - Handle<Object> boilerplate(literals->get(literals_index));
|
| - if (*boilerplate == Heap::undefined_value()) {
|
| - boilerplate = CreateArrayLiteralBoilerplate(literals, elements);
|
| + Handle<Object> boilerplate(literals->get(literals_index), isolate);
|
| + if (*boilerplate == isolate->heap()->undefined_value()) {
|
| + boilerplate = CreateArrayLiteralBoilerplate(isolate, literals, elements);
|
| if (boilerplate.is_null()) return Failure::Exception();
|
| // Update the functions literal and return the boilerplate.
|
| literals->set(literals_index, *boilerplate);
|
| }
|
| if (JSObject::cast(*boilerplate)->elements()->map() ==
|
| - Heap::fixed_cow_array_map()) {
|
| - Counters::cow_arrays_created_runtime.Increment();
|
| + isolate->heap()->fixed_cow_array_map()) {
|
| + COUNTERS->cow_arrays_created_runtime()->Increment();
|
| }
|
| - return Heap::CopyJSObject(JSObject::cast(*boilerplate));
|
| + return isolate->heap()->CopyJSObject(JSObject::cast(*boilerplate));
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_CreateCatchExtensionObject(Arguments args) {
|
| +static MaybeObject* Runtime_CreateCatchExtensionObject(
|
| + RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| ASSERT(args.length() == 2);
|
| CONVERT_CHECKED(String, key, args[0]);
|
| Object* value = args[1];
|
| // Create a catch context extension object.
|
| JSFunction* constructor =
|
| - Top::context()->global_context()->context_extension_function();
|
| + isolate->context()->global_context()->
|
| + context_extension_function();
|
| Object* object;
|
| - { MaybeObject* maybe_object = Heap::AllocateJSObject(constructor);
|
| + { MaybeObject* maybe_object = isolate->heap()->AllocateJSObject(constructor);
|
| if (!maybe_object->ToObject(&object)) return maybe_object;
|
| }
|
| // Assign the exception value to the catch variable and make sure
|
| @@ -564,16 +591,18 @@
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_ClassOf(Arguments args) {
|
| +static MaybeObject* Runtime_ClassOf(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 1);
|
| Object* obj = args[0];
|
| - if (!obj->IsJSObject()) return Heap::null_value();
|
| + if (!obj->IsJSObject()) return isolate->heap()->null_value();
|
| return JSObject::cast(obj)->class_name();
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_IsInPrototypeChain(Arguments args) {
|
| +static MaybeObject* Runtime_IsInPrototypeChain(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 2);
|
| // See ECMA-262, section 15.3.5.3, page 88 (steps 5 - 8).
|
| @@ -581,15 +610,16 @@
|
| Object* V = args[1];
|
| while (true) {
|
| Object* prototype = V->GetPrototype();
|
| - if (prototype->IsNull()) return Heap::false_value();
|
| - if (O == prototype) return Heap::true_value();
|
| + if (prototype->IsNull()) return isolate->heap()->false_value();
|
| + if (O == prototype) return isolate->heap()->true_value();
|
| V = prototype;
|
| }
|
| }
|
|
|
|
|
| // Inserts an object as the hidden prototype of another object.
|
| -static MaybeObject* Runtime_SetHiddenPrototype(Arguments args) {
|
| +static MaybeObject* Runtime_SetHiddenPrototype(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 2);
|
| CONVERT_CHECKED(JSObject, jsobject, args[0]);
|
| @@ -627,15 +657,16 @@
|
| new_map->set_prototype(proto);
|
| jsobject->set_map(new_map);
|
|
|
| - return Heap::undefined_value();
|
| + return isolate->heap()->undefined_value();
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_IsConstructCall(Arguments args) {
|
| +static MaybeObject* Runtime_IsConstructCall(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 0);
|
| JavaScriptFrameIterator it;
|
| - return Heap::ToBoolean(it.frame()->IsConstructor());
|
| + return isolate->heap()->ToBoolean(it.frame()->IsConstructor());
|
| }
|
|
|
|
|
| @@ -682,9 +713,10 @@
|
|
|
| JSObject* holder = result->holder();
|
| JSObject* current = obj;
|
| + Isolate* isolate = obj->GetIsolate();
|
| while (true) {
|
| if (current->IsAccessCheckNeeded() &&
|
| - !Top::MayNamedAccess(current, name, access_type)) {
|
| + !isolate->MayNamedAccess(current, name, access_type)) {
|
| // Access check callback denied the access, but some properties
|
| // can have a special permissions which override callbacks descision
|
| // (currently see v8::AccessControl).
|
| @@ -721,7 +753,7 @@
|
| break;
|
| }
|
|
|
| - Top::ReportFailedAccessCheck(current, access_type);
|
| + isolate->ReportFailedAccessCheck(current, access_type);
|
| return false;
|
| }
|
|
|
| @@ -731,7 +763,7 @@
|
| uint32_t index,
|
| v8::AccessType access_type) {
|
| if (obj->IsAccessCheckNeeded() &&
|
| - !Top::MayIndexedAccess(obj, index, access_type)) {
|
| + !obj->GetIsolate()->MayIndexedAccess(obj, index, access_type)) {
|
| return false;
|
| }
|
|
|
| @@ -758,11 +790,13 @@
|
| // [false, value, Writeable, Enumerable, Configurable]
|
| // if args[1] is an accessor on args[0]
|
| // [true, GetFunction, SetFunction, Enumerable, Configurable]
|
| -static MaybeObject* Runtime_GetOwnProperty(Arguments args) {
|
| +static MaybeObject* Runtime_GetOwnProperty(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| ASSERT(args.length() == 2);
|
| - HandleScope scope;
|
| - Handle<FixedArray> elms = Factory::NewFixedArray(DESCRIPTOR_SIZE);
|
| - Handle<JSArray> desc = Factory::NewJSArrayWithElements(elms);
|
| + Heap* heap = isolate->heap();
|
| + HandleScope scope(isolate);
|
| + Handle<FixedArray> elms = isolate->factory()->NewFixedArray(DESCRIPTOR_SIZE);
|
| + Handle<JSArray> desc = isolate->factory()->NewJSArrayWithElements(elms);
|
| LookupResult result;
|
| CONVERT_ARG_CHECKED(JSObject, obj, 0);
|
| CONVERT_ARG_CHECKED(String, name, 1);
|
| @@ -772,7 +806,7 @@
|
| if (name->AsArrayIndex(&index)) {
|
| switch (obj->HasLocalElement(index)) {
|
| case JSObject::UNDEFINED_ELEMENT:
|
| - return Heap::undefined_value();
|
| + return heap->undefined_value();
|
|
|
| case JSObject::STRING_CHARACTER_ELEMENT: {
|
| // Special handling of string objects according to ECMAScript 5
|
| @@ -783,23 +817,23 @@
|
| Handle<String> str(String::cast(js_value->value()));
|
| Handle<String> substr = SubString(str, index, index + 1, NOT_TENURED);
|
|
|
| - elms->set(IS_ACCESSOR_INDEX, Heap::false_value());
|
| + elms->set(IS_ACCESSOR_INDEX, heap->false_value());
|
| elms->set(VALUE_INDEX, *substr);
|
| - elms->set(WRITABLE_INDEX, Heap::false_value());
|
| - elms->set(ENUMERABLE_INDEX, Heap::false_value());
|
| - elms->set(CONFIGURABLE_INDEX, Heap::false_value());
|
| + elms->set(WRITABLE_INDEX, heap->false_value());
|
| + elms->set(ENUMERABLE_INDEX, heap->false_value());
|
| + elms->set(CONFIGURABLE_INDEX, heap->false_value());
|
| return *desc;
|
| }
|
|
|
| case JSObject::INTERCEPTED_ELEMENT:
|
| case JSObject::FAST_ELEMENT: {
|
| - elms->set(IS_ACCESSOR_INDEX, Heap::false_value());
|
| + elms->set(IS_ACCESSOR_INDEX, heap->false_value());
|
| Handle<Object> value = GetElement(obj, index);
|
| - RETURN_IF_EMPTY_HANDLE(value);
|
| + RETURN_IF_EMPTY_HANDLE(isolate, value);
|
| elms->set(VALUE_INDEX, *value);
|
| - elms->set(WRITABLE_INDEX, Heap::true_value());
|
| - elms->set(ENUMERABLE_INDEX, Heap::true_value());
|
| - elms->set(CONFIGURABLE_INDEX, Heap::true_value());
|
| + elms->set(WRITABLE_INDEX, heap->true_value());
|
| + elms->set(ENUMERABLE_INDEX, heap->true_value());
|
| + elms->set(CONFIGURABLE_INDEX, heap->true_value());
|
| return *desc;
|
| }
|
|
|
| @@ -807,7 +841,7 @@
|
| Handle<JSObject> holder = obj;
|
| if (obj->IsJSGlobalProxy()) {
|
| Object* proto = obj->GetPrototype();
|
| - if (proto->IsNull()) return Heap::undefined_value();
|
| + if (proto->IsNull()) return heap->undefined_value();
|
| ASSERT(proto->IsJSGlobalObject());
|
| holder = Handle<JSObject>(JSObject::cast(proto));
|
| }
|
| @@ -820,7 +854,7 @@
|
| // This is an accessor property with getter and/or setter.
|
| FixedArray* callbacks =
|
| FixedArray::cast(dictionary->ValueAt(entry));
|
| - elms->set(IS_ACCESSOR_INDEX, Heap::true_value());
|
| + elms->set(IS_ACCESSOR_INDEX, heap->true_value());
|
| if (CheckElementAccess(*obj, index, v8::ACCESS_GET)) {
|
| elms->set(GETTER_INDEX, callbacks->get(0));
|
| }
|
| @@ -831,19 +865,19 @@
|
| }
|
| case NORMAL: {
|
| // This is a data property.
|
| - elms->set(IS_ACCESSOR_INDEX, Heap::false_value());
|
| + elms->set(IS_ACCESSOR_INDEX, heap->false_value());
|
| Handle<Object> value = GetElement(obj, index);
|
| ASSERT(!value.is_null());
|
| elms->set(VALUE_INDEX, *value);
|
| - elms->set(WRITABLE_INDEX, Heap::ToBoolean(!details.IsReadOnly()));
|
| + elms->set(WRITABLE_INDEX, heap->ToBoolean(!details.IsReadOnly()));
|
| break;
|
| }
|
| default:
|
| UNREACHABLE();
|
| break;
|
| }
|
| - elms->set(ENUMERABLE_INDEX, Heap::ToBoolean(!details.IsDontEnum()));
|
| - elms->set(CONFIGURABLE_INDEX, Heap::ToBoolean(!details.IsDontDelete()));
|
| + elms->set(ENUMERABLE_INDEX, heap->ToBoolean(!details.IsDontEnum()));
|
| + elms->set(CONFIGURABLE_INDEX, heap->ToBoolean(!details.IsDontDelete()));
|
| return *desc;
|
| }
|
| }
|
| @@ -853,22 +887,22 @@
|
| GetOwnPropertyImplementation(*obj, *name, &result);
|
|
|
| if (!result.IsProperty()) {
|
| - return Heap::undefined_value();
|
| + return heap->undefined_value();
|
| }
|
|
|
| if (!CheckAccess(*obj, *name, &result, v8::ACCESS_HAS)) {
|
| - return Heap::false_value();
|
| + return heap->false_value();
|
| }
|
|
|
| - elms->set(ENUMERABLE_INDEX, Heap::ToBoolean(!result.IsDontEnum()));
|
| - elms->set(CONFIGURABLE_INDEX, Heap::ToBoolean(!result.IsDontDelete()));
|
| + elms->set(ENUMERABLE_INDEX, heap->ToBoolean(!result.IsDontEnum()));
|
| + elms->set(CONFIGURABLE_INDEX, heap->ToBoolean(!result.IsDontDelete()));
|
|
|
| bool is_js_accessor = (result.type() == CALLBACKS) &&
|
| (result.GetCallbackObject()->IsFixedArray());
|
|
|
| if (is_js_accessor) {
|
| // __defineGetter__/__defineSetter__ callback.
|
| - elms->set(IS_ACCESSOR_INDEX, Heap::true_value());
|
| + elms->set(IS_ACCESSOR_INDEX, heap->true_value());
|
|
|
| FixedArray* structure = FixedArray::cast(result.GetCallbackObject());
|
| if (CheckAccess(*obj, *name, &result, v8::ACCESS_GET)) {
|
| @@ -878,8 +912,8 @@
|
| elms->set(SETTER_INDEX, structure->get(1));
|
| }
|
| } else {
|
| - elms->set(IS_ACCESSOR_INDEX, Heap::false_value());
|
| - elms->set(WRITABLE_INDEX, Heap::ToBoolean(!result.IsReadOnly()));
|
| + elms->set(IS_ACCESSOR_INDEX, heap->false_value());
|
| + elms->set(WRITABLE_INDEX, heap->ToBoolean(!result.IsReadOnly()));
|
|
|
| PropertyAttributes attrs;
|
| Object* value;
|
| @@ -894,29 +928,32 @@
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_PreventExtensions(Arguments args) {
|
| +static MaybeObject* Runtime_PreventExtensions(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| ASSERT(args.length() == 1);
|
| CONVERT_CHECKED(JSObject, obj, args[0]);
|
| return obj->PreventExtensions();
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_IsExtensible(Arguments args) {
|
| +static MaybeObject* Runtime_IsExtensible(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| ASSERT(args.length() == 1);
|
| CONVERT_CHECKED(JSObject, obj, args[0]);
|
| if (obj->IsJSGlobalProxy()) {
|
| Object* proto = obj->GetPrototype();
|
| - if (proto->IsNull()) return Heap::false_value();
|
| + if (proto->IsNull()) return isolate->heap()->false_value();
|
| ASSERT(proto->IsJSGlobalObject());
|
| obj = JSObject::cast(proto);
|
| }
|
| - return obj->map()->is_extensible() ? Heap::true_value()
|
| - : Heap::false_value();
|
| + return obj->map()->is_extensible() ? isolate->heap()->true_value()
|
| + : isolate->heap()->false_value();
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_RegExpCompile(Arguments args) {
|
| - HandleScope scope;
|
| +static MaybeObject* Runtime_RegExpCompile(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| + HandleScope scope(isolate);
|
| ASSERT(args.length() == 3);
|
| CONVERT_ARG_CHECKED(JSRegExp, re, 0);
|
| CONVERT_ARG_CHECKED(String, pattern, 1);
|
| @@ -927,23 +964,26 @@
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_CreateApiFunction(Arguments args) {
|
| - HandleScope scope;
|
| +static MaybeObject* Runtime_CreateApiFunction(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| + HandleScope scope(isolate);
|
| ASSERT(args.length() == 1);
|
| CONVERT_ARG_CHECKED(FunctionTemplateInfo, data, 0);
|
| - return *Factory::CreateApiFunction(data);
|
| + return *isolate->factory()->CreateApiFunction(data);
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_IsTemplate(Arguments args) {
|
| +static MaybeObject* Runtime_IsTemplate(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| ASSERT(args.length() == 1);
|
| Object* arg = args[0];
|
| bool result = arg->IsObjectTemplateInfo() || arg->IsFunctionTemplateInfo();
|
| - return Heap::ToBoolean(result);
|
| + return isolate->heap()->ToBoolean(result);
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_GetTemplateField(Arguments args) {
|
| +static MaybeObject* Runtime_GetTemplateField(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| ASSERT(args.length() == 2);
|
| CONVERT_CHECKED(HeapObject, templ, args[0]);
|
| CONVERT_CHECKED(Smi, field, args[1]);
|
| @@ -962,7 +1002,8 @@
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_DisableAccessChecks(Arguments args) {
|
| +static MaybeObject* Runtime_DisableAccessChecks(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| ASSERT(args.length() == 1);
|
| CONVERT_CHECKED(HeapObject, object, args[0]);
|
| Map* old_map = object->map();
|
| @@ -977,11 +1018,13 @@
|
| Map::cast(new_map)->set_is_access_check_needed(false);
|
| object->set_map(Map::cast(new_map));
|
| }
|
| - return needs_access_checks ? Heap::true_value() : Heap::false_value();
|
| + return needs_access_checks ? isolate->heap()->true_value()
|
| + : isolate->heap()->false_value();
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_EnableAccessChecks(Arguments args) {
|
| +static MaybeObject* Runtime_EnableAccessChecks(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| ASSERT(args.length() == 1);
|
| CONVERT_CHECKED(HeapObject, object, args[0]);
|
| Map* old_map = object->map();
|
| @@ -995,24 +1038,29 @@
|
| Map::cast(new_map)->set_is_access_check_needed(true);
|
| object->set_map(Map::cast(new_map));
|
| }
|
| - return Heap::undefined_value();
|
| + return isolate->heap()->undefined_value();
|
| }
|
|
|
|
|
| -static Failure* ThrowRedeclarationError(const char* type, Handle<String> name) {
|
| - HandleScope scope;
|
| - Handle<Object> type_handle = Factory::NewStringFromAscii(CStrVector(type));
|
| +static Failure* ThrowRedeclarationError(Isolate* isolate,
|
| + const char* type,
|
| + Handle<String> name) {
|
| + HandleScope scope(isolate);
|
| + Handle<Object> type_handle =
|
| + isolate->factory()->NewStringFromAscii(CStrVector(type));
|
| Handle<Object> args[2] = { type_handle, name };
|
| Handle<Object> error =
|
| - Factory::NewTypeError("redeclaration", HandleVector(args, 2));
|
| - return Top::Throw(*error);
|
| + isolate->factory()->NewTypeError("redeclaration", HandleVector(args, 2));
|
| + return isolate->Throw(*error);
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_DeclareGlobals(Arguments args) {
|
| +static MaybeObject* Runtime_DeclareGlobals(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| ASSERT(args.length() == 4);
|
| - HandleScope scope;
|
| - Handle<GlobalObject> global = Handle<GlobalObject>(Top::context()->global());
|
| + HandleScope scope(isolate);
|
| + Handle<GlobalObject> global = Handle<GlobalObject>(
|
| + isolate->context()->global());
|
|
|
| Handle<Context> context = args.at<Context>(0);
|
| CONVERT_ARG_CHECKED(FixedArray, pairs, 1);
|
| @@ -1030,9 +1078,9 @@
|
| // Traverse the name/value pairs and set the properties.
|
| int length = pairs->length();
|
| for (int i = 0; i < length; i += 2) {
|
| - HandleScope scope;
|
| + HandleScope scope(isolate);
|
| Handle<String> name(String::cast(pairs->get(i)));
|
| - Handle<Object> value(pairs->get(i + 1));
|
| + Handle<Object> value(pairs->get(i + 1), isolate);
|
|
|
| // We have to declare a global const property. To capture we only
|
| // assign to it when evaluating the assignment for "const x =
|
| @@ -1062,7 +1110,7 @@
|
| // Check if the existing property conflicts with regards to const.
|
| if (is_local && (is_read_only || is_const_property)) {
|
| const char* type = (is_read_only) ? "const" : "var";
|
| - return ThrowRedeclarationError(type, name);
|
| + return ThrowRedeclarationError(isolate, type, name);
|
| };
|
| // The property already exists without conflicting: Go to
|
| // the next declaration.
|
| @@ -1074,12 +1122,12 @@
|
| // For const properties, we treat a callback with this name
|
| // even in the prototype as a conflicting declaration.
|
| if (is_const_property && (lookup.type() == CALLBACKS)) {
|
| - return ThrowRedeclarationError("const", name);
|
| + return ThrowRedeclarationError(isolate, "const", name);
|
| }
|
| // Otherwise, we check for locally conflicting declarations.
|
| if (is_local && (is_read_only || is_const_property)) {
|
| const char* type = (is_read_only) ? "const" : "var";
|
| - return ThrowRedeclarationError(type, name);
|
| + return ThrowRedeclarationError(isolate, type, name);
|
| }
|
| // The property already exists without conflicting: Go to
|
| // the next declaration.
|
| @@ -1091,7 +1139,9 @@
|
| Handle<SharedFunctionInfo> shared =
|
| Handle<SharedFunctionInfo>::cast(value);
|
| Handle<JSFunction> function =
|
| - Factory::NewFunctionFromSharedFunctionInfo(shared, context, TENURED);
|
| + isolate->factory()->NewFunctionFromSharedFunctionInfo(shared,
|
| + context,
|
| + TENURED);
|
| value = function;
|
| }
|
|
|
| @@ -1113,7 +1163,7 @@
|
| (lookup.type() != INTERCEPTOR) &&
|
| (lookup.IsReadOnly() || is_const_property)) {
|
| const char* type = (lookup.IsReadOnly()) ? "const" : "var";
|
| - return ThrowRedeclarationError(type, name);
|
| + return ThrowRedeclarationError(isolate, type, name);
|
| }
|
|
|
| // Safari does not allow the invocation of callback setters for
|
| @@ -1129,12 +1179,14 @@
|
| attributes = static_cast<PropertyAttributes>(
|
| attributes | (lookup.GetAttributes() & DONT_DELETE));
|
| }
|
| - RETURN_IF_EMPTY_HANDLE(SetLocalPropertyIgnoreAttributes(global,
|
| + RETURN_IF_EMPTY_HANDLE(isolate,
|
| + SetLocalPropertyIgnoreAttributes(global,
|
| name,
|
| value,
|
| attributes));
|
| } else {
|
| - RETURN_IF_EMPTY_HANDLE(SetProperty(global,
|
| + RETURN_IF_EMPTY_HANDLE(isolate,
|
| + SetProperty(global,
|
| name,
|
| value,
|
| attributes,
|
| @@ -1142,13 +1194,14 @@
|
| }
|
| }
|
|
|
| - ASSERT(!Top::has_pending_exception());
|
| - return Heap::undefined_value();
|
| + ASSERT(!isolate->has_pending_exception());
|
| + return isolate->heap()->undefined_value();
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_DeclareContextSlot(Arguments args) {
|
| - HandleScope scope;
|
| +static MaybeObject* Runtime_DeclareContextSlot(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| + HandleScope scope(isolate);
|
| ASSERT(args.length() == 4);
|
|
|
| CONVERT_ARG_CHECKED(Context, context, 0);
|
| @@ -1156,7 +1209,7 @@
|
| PropertyAttributes mode =
|
| static_cast<PropertyAttributes>(Smi::cast(args[2])->value());
|
| RUNTIME_ASSERT(mode == READ_ONLY || mode == NONE);
|
| - Handle<Object> initial_value(args[3]);
|
| + Handle<Object> initial_value(args[3], isolate);
|
|
|
| // Declarations are always done in the function context.
|
| context = Handle<Context>(context->fcontext());
|
| @@ -1175,7 +1228,7 @@
|
| // Functions are not read-only.
|
| ASSERT(mode != READ_ONLY || initial_value->IsTheHole());
|
| const char* type = ((attributes & READ_ONLY) != 0) ? "const" : "var";
|
| - return ThrowRedeclarationError(type, name);
|
| + return ThrowRedeclarationError(isolate, type, name);
|
| }
|
|
|
| // Initialize it if necessary.
|
| @@ -1200,6 +1253,7 @@
|
| // Slow case: The property is not in the FixedArray part of the context.
|
| Handle<JSObject> context_ext = Handle<JSObject>::cast(holder);
|
| RETURN_IF_EMPTY_HANDLE(
|
| + isolate,
|
| SetProperty(context_ext, name, initial_value,
|
| mode, kNonStrictMode));
|
| }
|
| @@ -1216,7 +1270,8 @@
|
| } else {
|
| // The function context's extension context does not exists - allocate
|
| // it.
|
| - context_ext = Factory::NewJSObject(Top::context_extension_function());
|
| + context_ext = isolate->factory()->NewJSObject(
|
| + isolate->context_extension_function());
|
| // And store it in the extension slot.
|
| context->set_extension(*context_ext);
|
| }
|
| @@ -1226,7 +1281,7 @@
|
| // or undefined, and use the correct mode (e.g. READ_ONLY attribute for
|
| // constant declarations).
|
| ASSERT(!context_ext->HasLocalProperty(*name));
|
| - Handle<Object> value(Heap::undefined_value());
|
| + Handle<Object> value(isolate->heap()->undefined_value(), isolate);
|
| if (*initial_value != NULL) value = initial_value;
|
| // Declaring a const context slot is a conflicting declaration if
|
| // there is a callback with that name in a prototype. It is
|
| @@ -1239,18 +1294,20 @@
|
| LookupResult lookup;
|
| context_ext->Lookup(*name, &lookup);
|
| if (lookup.IsProperty() && (lookup.type() == CALLBACKS)) {
|
| - return ThrowRedeclarationError("const", name);
|
| + return ThrowRedeclarationError(isolate, "const", name);
|
| }
|
| }
|
| - RETURN_IF_EMPTY_HANDLE(SetProperty(context_ext, name, value, mode,
|
| + RETURN_IF_EMPTY_HANDLE(isolate,
|
| + SetProperty(context_ext, name, value, mode,
|
| kNonStrictMode));
|
| }
|
|
|
| - return Heap::undefined_value();
|
| + return isolate->heap()->undefined_value();
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_InitializeVarGlobal(Arguments args) {
|
| +static MaybeObject* Runtime_InitializeVarGlobal(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation nha;
|
| // args[0] == name
|
| // args[1] == strict_mode
|
| @@ -1262,7 +1319,7 @@
|
| bool assign = args.length() == 3;
|
|
|
| CONVERT_ARG_CHECKED(String, name, 0);
|
| - GlobalObject* global = Top::context()->global();
|
| + GlobalObject* global = isolate->context()->global();
|
| RUNTIME_ASSERT(args[1]->IsSmi());
|
| StrictModeFlag strict_mode =
|
| static_cast<StrictModeFlag>(Smi::cast(args[1])->value());
|
| @@ -1288,8 +1345,8 @@
|
| if (lookup.IsReadOnly()) {
|
| // If we found readonly property on one of hidden prototypes,
|
| // just shadow it.
|
| - if (real_holder != Top::context()->global()) break;
|
| - return ThrowRedeclarationError("const", name);
|
| + if (real_holder != isolate->context()->global()) break;
|
| + return ThrowRedeclarationError(isolate, "const", name);
|
| }
|
|
|
| // Determine if this is a redeclaration of an intercepted read-only
|
| @@ -1297,7 +1354,7 @@
|
| bool found = true;
|
| PropertyType type = lookup.type();
|
| if (type == INTERCEPTOR) {
|
| - HandleScope handle_scope;
|
| + HandleScope handle_scope(isolate);
|
| Handle<JSObject> holder(real_holder);
|
| PropertyAttributes intercepted = holder->GetPropertyAttribute(*name);
|
| real_holder = *holder;
|
| @@ -1310,19 +1367,19 @@
|
| // overwrite it with a variable declaration we must throw a
|
| // re-declaration error. However if we found readonly property
|
| // on one of hidden prototypes, just shadow it.
|
| - if (real_holder != Top::context()->global()) break;
|
| - return ThrowRedeclarationError("const", name);
|
| + if (real_holder != isolate->context()->global()) break;
|
| + return ThrowRedeclarationError(isolate, "const", name);
|
| }
|
| }
|
|
|
| if (found && !assign) {
|
| // The global property is there and we're not assigning any value
|
| // to it. Just return.
|
| - return Heap::undefined_value();
|
| + return isolate->heap()->undefined_value();
|
| }
|
|
|
| // Assign the value (or undefined) to the property.
|
| - Object* value = (assign) ? args[2] : Heap::undefined_value();
|
| + Object* value = (assign) ? args[2] : isolate->heap()->undefined_value();
|
| return real_holder->SetProperty(
|
| &lookup, *name, value, attributes, strict_mode);
|
| }
|
| @@ -1337,15 +1394,16 @@
|
| real_holder = JSObject::cast(proto);
|
| }
|
|
|
| - global = Top::context()->global();
|
| + global = isolate->context()->global();
|
| if (assign) {
|
| return global->SetProperty(*name, args[2], attributes, strict_mode);
|
| }
|
| - return Heap::undefined_value();
|
| + return isolate->heap()->undefined_value();
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_InitializeConstGlobal(Arguments args) {
|
| +static MaybeObject* Runtime_InitializeConstGlobal(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| // All constants are declared with an initial value. The name
|
| // of the constant is the first argument and the initial value
|
| // is the second.
|
| @@ -1354,7 +1412,7 @@
|
| Handle<Object> value = args.at<Object>(1);
|
|
|
| // Get the current global object from top.
|
| - GlobalObject* global = Top::context()->global();
|
| + GlobalObject* global = isolate->context()->global();
|
|
|
| // According to ECMA-262, section 12.2, page 62, the property must
|
| // not be deletable. Since it's a const, it must be READ_ONLY too.
|
| @@ -1379,7 +1437,7 @@
|
| // need to ask it for the property attributes.
|
| if (!lookup.IsReadOnly()) {
|
| if (lookup.type() != INTERCEPTOR) {
|
| - return ThrowRedeclarationError("var", name);
|
| + return ThrowRedeclarationError(isolate, "var", name);
|
| }
|
|
|
| PropertyAttributes intercepted = global->GetPropertyAttribute(*name);
|
| @@ -1387,20 +1445,21 @@
|
| // Throw re-declaration error if the intercepted property is present
|
| // but not read-only.
|
| if (intercepted != ABSENT && (intercepted & READ_ONLY) == 0) {
|
| - return ThrowRedeclarationError("var", name);
|
| + return ThrowRedeclarationError(isolate, "var", name);
|
| }
|
|
|
| // Restore global object from context (in case of GC) and continue
|
| // with setting the value because the property is either absent or
|
| // read-only. We also have to do redo the lookup.
|
| - HandleScope handle_scope;
|
| - Handle<GlobalObject> global(Top::context()->global());
|
| + HandleScope handle_scope(isolate);
|
| + Handle<GlobalObject> global(isolate->context()->global());
|
|
|
| // BUG 1213575: Handle the case where we have to set a read-only
|
| // property through an interceptor and only do it if it's
|
| // uninitialized, e.g. the hole. Nirk...
|
| // Passing non-strict mode because the property is writable.
|
| - RETURN_IF_EMPTY_HANDLE(SetProperty(global,
|
| + RETURN_IF_EMPTY_HANDLE(isolate,
|
| + SetProperty(global,
|
| name,
|
| value,
|
| attributes,
|
| @@ -1434,11 +1493,13 @@
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_InitializeConstContextSlot(Arguments args) {
|
| - HandleScope scope;
|
| +static MaybeObject* Runtime_InitializeConstContextSlot(
|
| + RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| + HandleScope scope(isolate);
|
| ASSERT(args.length() == 3);
|
|
|
| - Handle<Object> value(args[0]);
|
| + Handle<Object> value(args[0], isolate);
|
| ASSERT(!value->IsTheHole());
|
| CONVERT_ARG_CHECKED(Context, context, 1);
|
| Handle<String> name(String::cast(args[2]));
|
| @@ -1479,6 +1540,7 @@
|
| ASSERT((attributes & READ_ONLY) == 0);
|
| Handle<JSObject> arguments(Handle<JSObject>::cast(holder));
|
| RETURN_IF_EMPTY_HANDLE(
|
| + isolate,
|
| SetElement(arguments, index, value, kNonStrictMode));
|
| }
|
| return *value;
|
| @@ -1487,9 +1549,11 @@
|
| // The property could not be found, we introduce it in the global
|
| // context.
|
| if (attributes == ABSENT) {
|
| - Handle<JSObject> global = Handle<JSObject>(Top::context()->global());
|
| + Handle<JSObject> global = Handle<JSObject>(
|
| + isolate->context()->global());
|
| // Strict mode not needed (const disallowed in strict mode).
|
| RETURN_IF_EMPTY_HANDLE(
|
| + isolate,
|
| SetProperty(global, name, value, NONE, kNonStrictMode));
|
| return *value;
|
| }
|
| @@ -1529,6 +1593,7 @@
|
| if ((attributes & READ_ONLY) == 0) {
|
| // Strict mode not needed (const disallowed in strict mode).
|
| RETURN_IF_EMPTY_HANDLE(
|
| + isolate,
|
| SetProperty(context_ext, name, value, attributes, kNonStrictMode));
|
| }
|
| }
|
| @@ -1538,8 +1603,9 @@
|
|
|
|
|
| static MaybeObject* Runtime_OptimizeObjectForAddingMultipleProperties(
|
| - Arguments args) {
|
| - HandleScope scope;
|
| + RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| + HandleScope scope(isolate);
|
| ASSERT(args.length() == 2);
|
| CONVERT_ARG_CHECKED(JSObject, object, 0);
|
| CONVERT_SMI_CHECKED(properties, args[1]);
|
| @@ -1550,8 +1616,9 @@
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_RegExpExec(Arguments args) {
|
| - HandleScope scope;
|
| +static MaybeObject* Runtime_RegExpExec(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| + HandleScope scope(isolate);
|
| ASSERT(args.length() == 4);
|
| CONVERT_ARG_CHECKED(JSRegExp, regexp, 0);
|
| CONVERT_ARG_CHECKED(String, subject, 1);
|
| @@ -1562,7 +1629,7 @@
|
| RUNTIME_ASSERT(last_match_info->HasFastElements());
|
| RUNTIME_ASSERT(index >= 0);
|
| RUNTIME_ASSERT(index <= subject->length());
|
| - Counters::regexp_entry_runtime.Increment();
|
| + isolate->counters()->regexp_entry_runtime()->Increment();
|
| Handle<Object> result = RegExpImpl::Exec(regexp,
|
| subject,
|
| index,
|
| @@ -1572,31 +1639,31 @@
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_RegExpConstructResult(Arguments args) {
|
| +static MaybeObject* Runtime_RegExpConstructResult(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| ASSERT(args.length() == 3);
|
| CONVERT_SMI_CHECKED(elements_count, args[0]);
|
| if (elements_count > JSArray::kMaxFastElementsLength) {
|
| - return Top::ThrowIllegalOperation();
|
| + return isolate->ThrowIllegalOperation();
|
| }
|
| Object* new_object;
|
| { MaybeObject* maybe_new_object =
|
| - Heap::AllocateFixedArrayWithHoles(elements_count);
|
| + isolate->heap()->AllocateFixedArrayWithHoles(elements_count);
|
| if (!maybe_new_object->ToObject(&new_object)) return maybe_new_object;
|
| }
|
| FixedArray* elements = FixedArray::cast(new_object);
|
| - { MaybeObject* maybe_new_object = Heap::AllocateRaw(JSRegExpResult::kSize,
|
| - NEW_SPACE,
|
| - OLD_POINTER_SPACE);
|
| + { MaybeObject* maybe_new_object = isolate->heap()->AllocateRaw(
|
| + JSRegExpResult::kSize, NEW_SPACE, OLD_POINTER_SPACE);
|
| if (!maybe_new_object->ToObject(&new_object)) return maybe_new_object;
|
| }
|
| {
|
| AssertNoAllocation no_gc;
|
| - HandleScope scope;
|
| + HandleScope scope(isolate);
|
| reinterpret_cast<HeapObject*>(new_object)->
|
| - set_map(Top::global_context()->regexp_result_map());
|
| + set_map(isolate->global_context()->regexp_result_map());
|
| }
|
| JSArray* array = JSArray::cast(new_object);
|
| - array->set_properties(Heap::empty_fixed_array());
|
| + array->set_properties(isolate->heap()->empty_fixed_array());
|
| array->set_elements(elements);
|
| array->set_length(Smi::FromInt(elements_count));
|
| // Write in-object properties after the length of the array.
|
| @@ -1606,20 +1673,21 @@
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_RegExpInitializeObject(Arguments args) {
|
| +static MaybeObject* Runtime_RegExpInitializeObject(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| AssertNoAllocation no_alloc;
|
| ASSERT(args.length() == 5);
|
| CONVERT_CHECKED(JSRegExp, regexp, args[0]);
|
| CONVERT_CHECKED(String, source, args[1]);
|
|
|
| Object* global = args[2];
|
| - if (!global->IsTrue()) global = Heap::false_value();
|
| + if (!global->IsTrue()) global = isolate->heap()->false_value();
|
|
|
| Object* ignoreCase = args[3];
|
| - if (!ignoreCase->IsTrue()) ignoreCase = Heap::false_value();
|
| + if (!ignoreCase->IsTrue()) ignoreCase = isolate->heap()->false_value();
|
|
|
| Object* multiline = args[4];
|
| - if (!multiline->IsTrue()) multiline = Heap::false_value();
|
| + if (!multiline->IsTrue()) multiline = isolate->heap()->false_value();
|
|
|
| Map* map = regexp->map();
|
| Object* constructor = map->constructor();
|
| @@ -1638,33 +1706,32 @@
|
| return regexp;
|
| }
|
|
|
| - // Map has changed, so use generic, but slower, method. Since these
|
| - // properties were all added as DONT_DELETE they must be present and
|
| - // normal so no failures can be expected.
|
| + // Map has changed, so use generic, but slower, method.
|
| PropertyAttributes final =
|
| static_cast<PropertyAttributes>(READ_ONLY | DONT_ENUM | DONT_DELETE);
|
| PropertyAttributes writable =
|
| static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE);
|
| + Heap* heap = isolate->heap();
|
| MaybeObject* result;
|
| - result = regexp->SetLocalPropertyIgnoreAttributes(Heap::source_symbol(),
|
| + result = regexp->SetLocalPropertyIgnoreAttributes(heap->source_symbol(),
|
| source,
|
| final);
|
| ASSERT(!result->IsFailure());
|
| - result = regexp->SetLocalPropertyIgnoreAttributes(Heap::global_symbol(),
|
| + result = regexp->SetLocalPropertyIgnoreAttributes(heap->global_symbol(),
|
| global,
|
| final);
|
| ASSERT(!result->IsFailure());
|
| result =
|
| - regexp->SetLocalPropertyIgnoreAttributes(Heap::ignore_case_symbol(),
|
| + regexp->SetLocalPropertyIgnoreAttributes(heap->ignore_case_symbol(),
|
| ignoreCase,
|
| final);
|
| ASSERT(!result->IsFailure());
|
| - result = regexp->SetLocalPropertyIgnoreAttributes(Heap::multiline_symbol(),
|
| + result = regexp->SetLocalPropertyIgnoreAttributes(heap->multiline_symbol(),
|
| multiline,
|
| final);
|
| ASSERT(!result->IsFailure());
|
| result =
|
| - regexp->SetLocalPropertyIgnoreAttributes(Heap::last_index_symbol(),
|
| + regexp->SetLocalPropertyIgnoreAttributes(heap->last_index_symbol(),
|
| Smi::FromInt(0),
|
| writable);
|
| ASSERT(!result->IsFailure());
|
| @@ -1673,59 +1740,68 @@
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_FinishArrayPrototypeSetup(Arguments args) {
|
| - HandleScope scope;
|
| +static MaybeObject* Runtime_FinishArrayPrototypeSetup(
|
| + RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| + HandleScope scope(isolate);
|
| ASSERT(args.length() == 1);
|
| CONVERT_ARG_CHECKED(JSArray, prototype, 0);
|
| // This is necessary to enable fast checks for absence of elements
|
| // on Array.prototype and below.
|
| - prototype->set_elements(Heap::empty_fixed_array());
|
| + prototype->set_elements(isolate->heap()->empty_fixed_array());
|
| return Smi::FromInt(0);
|
| }
|
|
|
|
|
| -static Handle<JSFunction> InstallBuiltin(Handle<JSObject> holder,
|
| +static Handle<JSFunction> InstallBuiltin(Isolate* isolate,
|
| + Handle<JSObject> holder,
|
| const char* name,
|
| Builtins::Name builtin_name) {
|
| - Handle<String> key = Factory::LookupAsciiSymbol(name);
|
| - Handle<Code> code(Builtins::builtin(builtin_name));
|
| - Handle<JSFunction> optimized = Factory::NewFunction(key,
|
| - JS_OBJECT_TYPE,
|
| - JSObject::kHeaderSize,
|
| - code,
|
| - false);
|
| + Handle<String> key = isolate->factory()->LookupAsciiSymbol(name);
|
| + Handle<Code> code(isolate->builtins()->builtin(builtin_name));
|
| + Handle<JSFunction> optimized =
|
| + isolate->factory()->NewFunction(key,
|
| + JS_OBJECT_TYPE,
|
| + JSObject::kHeaderSize,
|
| + code,
|
| + false);
|
| optimized->shared()->DontAdaptArguments();
|
| SetProperty(holder, key, optimized, NONE, kStrictMode);
|
| return optimized;
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_SpecialArrayFunctions(Arguments args) {
|
| - HandleScope scope;
|
| +static MaybeObject* Runtime_SpecialArrayFunctions(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| + HandleScope scope(isolate);
|
| ASSERT(args.length() == 1);
|
| CONVERT_ARG_CHECKED(JSObject, holder, 0);
|
|
|
| - InstallBuiltin(holder, "pop", Builtins::ArrayPop);
|
| - InstallBuiltin(holder, "push", Builtins::ArrayPush);
|
| - InstallBuiltin(holder, "shift", Builtins::ArrayShift);
|
| - InstallBuiltin(holder, "unshift", Builtins::ArrayUnshift);
|
| - InstallBuiltin(holder, "slice", Builtins::ArraySlice);
|
| - InstallBuiltin(holder, "splice", Builtins::ArraySplice);
|
| - InstallBuiltin(holder, "concat", Builtins::ArrayConcat);
|
| + InstallBuiltin(isolate, holder, "pop", Builtins::ArrayPop);
|
| + InstallBuiltin(isolate, holder, "push", Builtins::ArrayPush);
|
| + InstallBuiltin(isolate, holder, "shift", Builtins::ArrayShift);
|
| + InstallBuiltin(isolate, holder, "unshift", Builtins::ArrayUnshift);
|
| + InstallBuiltin(isolate, holder, "slice", Builtins::ArraySlice);
|
| + InstallBuiltin(isolate, holder, "splice", Builtins::ArraySplice);
|
| + InstallBuiltin(isolate, holder, "concat", Builtins::ArrayConcat);
|
|
|
| return *holder;
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_GetGlobalReceiver(Arguments args) {
|
| +static MaybeObject* Runtime_GetGlobalReceiver(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| // Returns a real global receiver, not one of builtins object.
|
| - Context* global_context = Top::context()->global()->global_context();
|
| + Context* global_context =
|
| + isolate->context()->global()->global_context();
|
| return global_context->global()->global_receiver();
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_MaterializeRegExpLiteral(Arguments args) {
|
| - HandleScope scope;
|
| +static MaybeObject* Runtime_MaterializeRegExpLiteral(
|
| + RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| + HandleScope scope(isolate);
|
| ASSERT(args.length() == 4);
|
| CONVERT_ARG_CHECKED(FixedArray, literals, 0);
|
| int index = Smi::cast(args[1])->value();
|
| @@ -1746,7 +1822,7 @@
|
| RegExpImpl::CreateRegExpLiteral(constructor, pattern, flags,
|
| &has_pending_exception);
|
| if (has_pending_exception) {
|
| - ASSERT(Top::has_pending_exception());
|
| + ASSERT(isolate->has_pending_exception());
|
| return Failure::Exception();
|
| }
|
| literals->set(index, *regexp);
|
| @@ -1754,7 +1830,8 @@
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_FunctionGetName(Arguments args) {
|
| +static MaybeObject* Runtime_FunctionGetName(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 1);
|
|
|
| @@ -1763,44 +1840,47 @@
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_FunctionSetName(Arguments args) {
|
| +static MaybeObject* Runtime_FunctionSetName(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 2);
|
|
|
| CONVERT_CHECKED(JSFunction, f, args[0]);
|
| CONVERT_CHECKED(String, name, args[1]);
|
| f->shared()->set_name(name);
|
| - return Heap::undefined_value();
|
| + return isolate->heap()->undefined_value();
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_FunctionRemovePrototype(Arguments args) {
|
| +static MaybeObject* Runtime_FunctionRemovePrototype(
|
| + RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 1);
|
|
|
| CONVERT_CHECKED(JSFunction, f, args[0]);
|
| - Object* obj;
|
| - { MaybeObject* maybe_obj = f->RemovePrototype();
|
| - if (!maybe_obj->ToObject(&obj)) return maybe_obj;
|
| - }
|
| + Object* obj = f->RemovePrototype();
|
| + if (obj->IsFailure()) return obj;
|
|
|
| - return Heap::undefined_value();
|
| + return isolate->heap()->undefined_value();
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_FunctionGetScript(Arguments args) {
|
| - HandleScope scope;
|
| +static MaybeObject* Runtime_FunctionGetScript(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| + HandleScope scope(isolate);
|
| ASSERT(args.length() == 1);
|
|
|
| CONVERT_CHECKED(JSFunction, fun, args[0]);
|
| - Handle<Object> script = Handle<Object>(fun->shared()->script());
|
| - if (!script->IsScript()) return Heap::undefined_value();
|
| + Handle<Object> script = Handle<Object>(fun->shared()->script(), isolate);
|
| + if (!script->IsScript()) return isolate->heap()->undefined_value();
|
|
|
| return *GetScriptWrapper(Handle<Script>::cast(script));
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_FunctionGetSourceCode(Arguments args) {
|
| +static MaybeObject* Runtime_FunctionGetSourceCode(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 1);
|
|
|
| @@ -1809,7 +1889,9 @@
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_FunctionGetScriptSourcePosition(Arguments args) {
|
| +static MaybeObject* Runtime_FunctionGetScriptSourcePosition(
|
| + RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 1);
|
|
|
| @@ -1819,7 +1901,9 @@
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_FunctionGetPositionForOffset(Arguments args) {
|
| +static MaybeObject* Runtime_FunctionGetPositionForOffset(
|
| + RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| ASSERT(args.length() == 2);
|
|
|
| CONVERT_CHECKED(Code, code, args[0]);
|
| @@ -1832,19 +1916,21 @@
|
| }
|
|
|
|
|
| -
|
| -static MaybeObject* Runtime_FunctionSetInstanceClassName(Arguments args) {
|
| +static MaybeObject* Runtime_FunctionSetInstanceClassName(
|
| + RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 2);
|
|
|
| CONVERT_CHECKED(JSFunction, fun, args[0]);
|
| CONVERT_CHECKED(String, name, args[1]);
|
| fun->SetInstanceClassName(name);
|
| - return Heap::undefined_value();
|
| + return isolate->heap()->undefined_value();
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_FunctionSetLength(Arguments args) {
|
| +static MaybeObject* Runtime_FunctionSetLength(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 2);
|
|
|
| @@ -1855,7 +1941,8 @@
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_FunctionSetPrototype(Arguments args) {
|
| +static MaybeObject* Runtime_FunctionSetPrototype(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 2);
|
|
|
| @@ -1870,26 +1957,31 @@
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_FunctionIsAPIFunction(Arguments args) {
|
| +static MaybeObject* Runtime_FunctionIsAPIFunction(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 1);
|
|
|
| CONVERT_CHECKED(JSFunction, f, args[0]);
|
| - return f->shared()->IsApiFunction() ? Heap::true_value()
|
| - : Heap::false_value();
|
| + return f->shared()->IsApiFunction() ? isolate->heap()->true_value()
|
| + : isolate->heap()->false_value();
|
| }
|
|
|
| -static MaybeObject* Runtime_FunctionIsBuiltin(Arguments args) {
|
| +
|
| +static MaybeObject* Runtime_FunctionIsBuiltin(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 1);
|
|
|
| CONVERT_CHECKED(JSFunction, f, args[0]);
|
| - return f->IsBuiltin() ? Heap::true_value() : Heap::false_value();
|
| + return f->IsBuiltin() ? isolate->heap()->true_value() :
|
| + isolate->heap()->false_value();
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_SetCode(Arguments args) {
|
| - HandleScope scope;
|
| +static MaybeObject* Runtime_SetCode(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| + HandleScope scope(isolate);
|
| ASSERT(args.length() == 2);
|
|
|
| CONVERT_ARG_CHECKED(JSFunction, target, 0);
|
| @@ -1921,7 +2013,7 @@
|
| // SetCode is only used for built-in constructors like String,
|
| // Array, and Object, and some web code
|
| // doesn't like seeing source code for constructors.
|
| - target->shared()->set_script(Heap::undefined_value());
|
| + target->shared()->set_script(isolate->heap()->undefined_value());
|
| target->shared()->code()->set_optimizable(false);
|
| // Clear the optimization hints related to the compiled code as these are no
|
| // longer valid when the code is overwritten.
|
| @@ -1932,7 +2024,7 @@
|
| // cross context contamination.
|
| int number_of_literals = fun->NumberOfLiterals();
|
| Handle<FixedArray> literals =
|
| - Factory::NewFixedArray(number_of_literals, TENURED);
|
| + isolate->factory()->NewFixedArray(number_of_literals, TENURED);
|
| if (number_of_literals > 0) {
|
| // Insert the object, regexp and array functions in the literals
|
| // array prefix. These are the functions that will be used when
|
| @@ -1943,7 +2035,7 @@
|
| // It's okay to skip the write barrier here because the literals
|
| // are guaranteed to be in old space.
|
| target->set_literals(*literals, SKIP_WRITE_BARRIER);
|
| - target->set_next_function_link(Heap::undefined_value());
|
| + target->set_next_function_link(isolate->heap()->undefined_value());
|
| }
|
|
|
| target->set_context(*context);
|
| @@ -1951,29 +2043,33 @@
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_SetExpectedNumberOfProperties(Arguments args) {
|
| - HandleScope scope;
|
| +static MaybeObject* Runtime_SetExpectedNumberOfProperties(
|
| + RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| + HandleScope scope(isolate);
|
| ASSERT(args.length() == 2);
|
| CONVERT_ARG_CHECKED(JSFunction, function, 0);
|
| CONVERT_SMI_CHECKED(num, args[1]);
|
| RUNTIME_ASSERT(num >= 0);
|
| SetExpectedNofProperties(function, num);
|
| - return Heap::undefined_value();
|
| + return isolate->heap()->undefined_value();
|
| }
|
|
|
|
|
| -MUST_USE_RESULT static MaybeObject* CharFromCode(Object* char_code) {
|
| +MUST_USE_RESULT static MaybeObject* CharFromCode(Isolate* isolate,
|
| + Object* char_code) {
|
| uint32_t code;
|
| if (char_code->ToArrayIndex(&code)) {
|
| if (code <= 0xffff) {
|
| - return Heap::LookupSingleCharacterStringFromCode(code);
|
| + return isolate->heap()->LookupSingleCharacterStringFromCode(code);
|
| }
|
| }
|
| - return Heap::empty_string();
|
| + return isolate->heap()->empty_string();
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_StringCharCodeAt(Arguments args) {
|
| +static MaybeObject* Runtime_StringCharCodeAt(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 2);
|
|
|
| @@ -1984,7 +2080,7 @@
|
| uint32_t i = 0;
|
| if (index->IsSmi()) {
|
| int value = Smi::cast(index)->value();
|
| - if (value < 0) return Heap::nan_value();
|
| + if (value < 0) return isolate->heap()->nan_value();
|
| i = value;
|
| } else {
|
| ASSERT(index->IsHeapNumber());
|
| @@ -2002,24 +2098,25 @@
|
| subject = String::cast(flat);
|
|
|
| if (i >= static_cast<uint32_t>(subject->length())) {
|
| - return Heap::nan_value();
|
| + return isolate->heap()->nan_value();
|
| }
|
|
|
| return Smi::FromInt(subject->Get(i));
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_CharFromCode(Arguments args) {
|
| +static MaybeObject* Runtime_CharFromCode(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 1);
|
| - return CharFromCode(args[0]);
|
| + return CharFromCode(isolate, args[0]);
|
| }
|
|
|
|
|
| class FixedArrayBuilder {
|
| public:
|
| - explicit FixedArrayBuilder(int initial_capacity)
|
| - : array_(Factory::NewFixedArrayWithHoles(initial_capacity)),
|
| + explicit FixedArrayBuilder(Isolate* isolate, int initial_capacity)
|
| + : array_(isolate->factory()->NewFixedArrayWithHoles(initial_capacity)),
|
| length_(0) {
|
| // Require a non-zero initial size. Ensures that doubling the size to
|
| // extend the array will work.
|
| @@ -2049,7 +2146,7 @@
|
| new_length *= 2;
|
| } while (new_length < required_length);
|
| Handle<FixedArray> extended_array =
|
| - Factory::NewFixedArrayWithHoles(new_length);
|
| + array_->GetIsolate()->factory()->NewFixedArrayWithHoles(new_length);
|
| array_->CopyTo(0, *extended_array, 0, length_);
|
| array_ = extended_array;
|
| }
|
| @@ -2080,7 +2177,7 @@
|
| }
|
|
|
| Handle<JSArray> ToJSArray() {
|
| - Handle<JSArray> result_array = Factory::NewJSArrayWithElements(array_);
|
| + Handle<JSArray> result_array = FACTORY->NewJSArrayWithElements(array_);
|
| result_array->set_length(Smi::FromInt(length_));
|
| return result_array;
|
| }
|
| @@ -2117,8 +2214,11 @@
|
|
|
| class ReplacementStringBuilder {
|
| public:
|
| - ReplacementStringBuilder(Handle<String> subject, int estimated_part_count)
|
| - : array_builder_(estimated_part_count),
|
| + ReplacementStringBuilder(Heap* heap,
|
| + Handle<String> subject,
|
| + int estimated_part_count)
|
| + : heap_(heap),
|
| + array_builder_(heap->isolate(), estimated_part_count),
|
| subject_(subject),
|
| character_count_(0),
|
| is_ascii_(subject->IsAsciiRepresentation()) {
|
| @@ -2170,7 +2270,7 @@
|
|
|
| Handle<String> ToString() {
|
| if (array_builder_.length() == 0) {
|
| - return Factory::empty_string();
|
| + return heap_->isolate()->factory()->empty_string();
|
| }
|
|
|
| Handle<String> joined_string;
|
| @@ -2211,12 +2311,14 @@
|
|
|
| private:
|
| Handle<String> NewRawAsciiString(int size) {
|
| - CALL_HEAP_FUNCTION(Heap::AllocateRawAsciiString(size), String);
|
| + CALL_HEAP_FUNCTION(heap_->isolate(),
|
| + heap_->AllocateRawAsciiString(size), String);
|
| }
|
|
|
|
|
| Handle<String> NewRawTwoByteString(int size) {
|
| - CALL_HEAP_FUNCTION(Heap::AllocateRawTwoByteString(size), String);
|
| + CALL_HEAP_FUNCTION(heap_->isolate(),
|
| + heap_->AllocateRawTwoByteString(size), String);
|
| }
|
|
|
|
|
| @@ -2226,6 +2328,7 @@
|
| array_builder_.Add(element);
|
| }
|
|
|
| + Heap* heap_;
|
| FixedArrayBuilder array_builder_;
|
| Handle<String> subject_;
|
| int character_count_;
|
| @@ -2436,6 +2539,7 @@
|
| capture_count,
|
| subject_length);
|
| }
|
| + Isolate* isolate = replacement->GetIsolate();
|
| // Find substrings of replacement string and create them as String objects.
|
| int substring_index = 0;
|
| for (int i = 0, n = parts_.length(); i < n; i++) {
|
| @@ -2443,7 +2547,8 @@
|
| if (tag <= 0) { // A replacement string slice.
|
| int from = -tag;
|
| int to = parts_[i].data;
|
| - replacement_substrings_.Add(Factory::NewSubString(replacement, from, to));
|
| + replacement_substrings_.Add(
|
| + isolate->factory()->NewSubString(replacement, from, to));
|
| parts_[i].tag = REPLACEMENT_SUBSTRING;
|
| parts_[i].data = substring_index;
|
| substring_index++;
|
| @@ -2496,6 +2601,7 @@
|
|
|
|
|
| MUST_USE_RESULT static MaybeObject* StringReplaceRegExpWithString(
|
| + Isolate* isolate,
|
| String* subject,
|
| JSRegExp* regexp,
|
| String* replacement,
|
| @@ -2503,7 +2609,7 @@
|
| ASSERT(subject->IsFlat());
|
| ASSERT(replacement->IsFlat());
|
|
|
| - HandleScope handles;
|
| + HandleScope handles(isolate);
|
|
|
| int length = subject->length();
|
| Handle<String> subject_handle(subject);
|
| @@ -2537,7 +2643,9 @@
|
| // conservatively.
|
| int expected_parts =
|
| (compiled_replacement.parts() + 1) * (is_global ? 4 : 1) + 1;
|
| - ReplacementStringBuilder builder(subject_handle, expected_parts);
|
| + ReplacementStringBuilder builder(isolate->heap(),
|
| + subject_handle,
|
| + expected_parts);
|
|
|
| // Index of end of last match.
|
| int prev = 0;
|
| @@ -2553,7 +2661,7 @@
|
| // so its internal buffer can safely allocate a new handle if it grows.
|
| builder.EnsureCapacity(parts_added_per_loop);
|
|
|
| - HandleScope loop_scope;
|
| + HandleScope loop_scope(isolate);
|
| int start, end;
|
| {
|
| AssertNoAllocation match_info_array_is_not_in_a_handle;
|
| @@ -2605,12 +2713,13 @@
|
|
|
| template <typename ResultSeqString>
|
| MUST_USE_RESULT static MaybeObject* StringReplaceRegExpWithEmptyString(
|
| + Isolate* isolate,
|
| String* subject,
|
| JSRegExp* regexp,
|
| JSArray* last_match_info) {
|
| ASSERT(subject->IsFlat());
|
|
|
| - HandleScope handles;
|
| + HandleScope handles(isolate);
|
|
|
| Handle<String> subject_handle(subject);
|
| Handle<JSRegExp> regexp_handle(regexp);
|
| @@ -2624,7 +2733,6 @@
|
|
|
| ASSERT(last_match_info_handle->HasFastElements());
|
|
|
| - HandleScope loop_scope;
|
| int start, end;
|
| {
|
| AssertNoAllocation match_info_array_is_not_in_a_handle;
|
| @@ -2638,15 +2746,15 @@
|
| int length = subject->length();
|
| int new_length = length - (end - start);
|
| if (new_length == 0) {
|
| - return Heap::empty_string();
|
| + return isolate->heap()->empty_string();
|
| }
|
| Handle<ResultSeqString> answer;
|
| if (ResultSeqString::kHasAsciiEncoding) {
|
| - answer =
|
| - Handle<ResultSeqString>::cast(Factory::NewRawAsciiString(new_length));
|
| + answer = Handle<ResultSeqString>::cast(
|
| + isolate->factory()->NewRawAsciiString(new_length));
|
| } else {
|
| - answer =
|
| - Handle<ResultSeqString>::cast(Factory::NewRawTwoByteString(new_length));
|
| + answer = Handle<ResultSeqString>::cast(
|
| + isolate->factory()->NewRawTwoByteString(new_length));
|
| }
|
|
|
| // If the regexp isn't global, only match once.
|
| @@ -2694,7 +2802,7 @@
|
| if (match->IsNull()) break;
|
|
|
| ASSERT(last_match_info_handle->HasFastElements());
|
| - HandleScope loop_scope;
|
| + HandleScope loop_scope(isolate);
|
| {
|
| AssertNoAllocation match_info_array_is_not_in_a_handle;
|
| FixedArray* match_info_array =
|
| @@ -2714,7 +2822,7 @@
|
| }
|
|
|
| if (position == 0) {
|
| - return Heap::empty_string();
|
| + return isolate->heap()->empty_string();
|
| }
|
|
|
| // Shorten string and fill
|
| @@ -2726,13 +2834,15 @@
|
| if (delta == 0) return *answer;
|
|
|
| Address end_of_string = answer->address() + string_size;
|
| - Heap::CreateFillerObjectAt(end_of_string, delta);
|
| + isolate->heap()->CreateFillerObjectAt(end_of_string, delta);
|
|
|
| return *answer;
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_StringReplaceRegExpWithString(Arguments args) {
|
| +static MaybeObject* Runtime_StringReplaceRegExpWithString(
|
| + RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| ASSERT(args.length() == 4);
|
|
|
| CONVERT_CHECKED(String, subject, args[0]);
|
| @@ -2765,14 +2875,15 @@
|
| if (replacement->length() == 0) {
|
| if (subject->HasOnlyAsciiChars()) {
|
| return StringReplaceRegExpWithEmptyString<SeqAsciiString>(
|
| - subject, regexp, last_match_info);
|
| + isolate, subject, regexp, last_match_info);
|
| } else {
|
| return StringReplaceRegExpWithEmptyString<SeqTwoByteString>(
|
| - subject, regexp, last_match_info);
|
| + isolate, subject, regexp, last_match_info);
|
| }
|
| }
|
|
|
| - return StringReplaceRegExpWithString(subject,
|
| + return StringReplaceRegExpWithString(isolate,
|
| + subject,
|
| regexp,
|
| replacement,
|
| last_match_info);
|
| @@ -2782,7 +2893,8 @@
|
| // 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(Handle<String> sub,
|
| +int Runtime::StringMatch(Isolate* isolate,
|
| + Handle<String> sub,
|
| Handle<String> pat,
|
| int start_index) {
|
| ASSERT(0 <= start_index);
|
| @@ -2808,20 +2920,33 @@
|
| if (seq_pat->IsAsciiRepresentation()) {
|
| Vector<const char> pat_vector = seq_pat->ToAsciiVector();
|
| if (seq_sub->IsAsciiRepresentation()) {
|
| - return SearchString(seq_sub->ToAsciiVector(), pat_vector, start_index);
|
| + return SearchString(isolate,
|
| + seq_sub->ToAsciiVector(),
|
| + pat_vector,
|
| + start_index);
|
| }
|
| - return SearchString(seq_sub->ToUC16Vector(), pat_vector, start_index);
|
| + return SearchString(isolate,
|
| + seq_sub->ToUC16Vector(),
|
| + pat_vector,
|
| + start_index);
|
| }
|
| Vector<const uc16> pat_vector = seq_pat->ToUC16Vector();
|
| if (seq_sub->IsAsciiRepresentation()) {
|
| - return SearchString(seq_sub->ToAsciiVector(), pat_vector, start_index);
|
| + return SearchString(isolate,
|
| + seq_sub->ToAsciiVector(),
|
| + pat_vector,
|
| + start_index);
|
| }
|
| - return SearchString(seq_sub->ToUC16Vector(), pat_vector, start_index);
|
| + return SearchString(isolate,
|
| + seq_sub->ToUC16Vector(),
|
| + pat_vector,
|
| + start_index);
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_StringIndexOf(Arguments args) {
|
| - HandleScope scope; // create a new handle scope
|
| +static MaybeObject* Runtime_StringIndexOf(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| + HandleScope scope(isolate); // create a new handle scope
|
| ASSERT(args.length() == 3);
|
|
|
| CONVERT_ARG_CHECKED(String, sub, 0);
|
| @@ -2832,7 +2957,8 @@
|
| if (!index->ToArrayIndex(&start_index)) return Smi::FromInt(-1);
|
|
|
| RUNTIME_ASSERT(start_index <= static_cast<uint32_t>(sub->length()));
|
| - int position = Runtime::StringMatch(sub, pat, start_index);
|
| + int position =
|
| + Runtime::StringMatch(isolate, sub, pat, start_index);
|
| return Smi::FromInt(position);
|
| }
|
|
|
| @@ -2871,8 +2997,9 @@
|
| return -1;
|
| }
|
|
|
| -static MaybeObject* Runtime_StringLastIndexOf(Arguments args) {
|
| - HandleScope scope; // create a new handle scope
|
| +static MaybeObject* Runtime_StringLastIndexOf(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| + HandleScope scope(isolate); // create a new handle scope
|
| ASSERT(args.length() == 3);
|
|
|
| CONVERT_ARG_CHECKED(String, sub, 0);
|
| @@ -2928,7 +3055,8 @@
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_StringLocaleCompare(Arguments args) {
|
| +static MaybeObject* Runtime_StringLocaleCompare(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 2);
|
|
|
| @@ -2958,8 +3086,10 @@
|
| str1->TryFlatten();
|
| str2->TryFlatten();
|
|
|
| - static StringInputBuffer buf1;
|
| - static StringInputBuffer buf2;
|
| + StringInputBuffer& buf1 =
|
| + *isolate->runtime_state()->string_locale_compare_buf1();
|
| + StringInputBuffer& buf2 =
|
| + *isolate->runtime_state()->string_locale_compare_buf2();
|
|
|
| buf1.Reset(str1);
|
| buf2.Reset(str2);
|
| @@ -2974,7 +3104,8 @@
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_SubString(Arguments args) {
|
| +static MaybeObject* Runtime_SubString(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 3);
|
|
|
| @@ -2996,12 +3127,13 @@
|
| RUNTIME_ASSERT(end >= start);
|
| RUNTIME_ASSERT(start >= 0);
|
| RUNTIME_ASSERT(end <= value->length());
|
| - Counters::sub_string_runtime.Increment();
|
| + isolate->counters()->sub_string_runtime()->Increment();
|
| return value->SubString(start, end);
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_StringMatch(Arguments args) {
|
| +static MaybeObject* Runtime_StringMatch(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| ASSERT_EQ(3, args.length());
|
|
|
| CONVERT_ARG_CHECKED(String, subject, 0);
|
| @@ -3015,7 +3147,7 @@
|
| return Failure::Exception();
|
| }
|
| if (match->IsNull()) {
|
| - return Heap::null_value();
|
| + return isolate->heap()->null_value();
|
| }
|
| int length = subject->length();
|
|
|
| @@ -3040,14 +3172,14 @@
|
| }
|
| } while (!match->IsNull());
|
| int matches = offsets.length() / 2;
|
| - Handle<FixedArray> elements = Factory::NewFixedArray(matches);
|
| + Handle<FixedArray> elements = isolate->factory()->NewFixedArray(matches);
|
| for (int i = 0; i < matches ; i++) {
|
| int from = offsets.at(i * 2);
|
| int to = offsets.at(i * 2 + 1);
|
| - Handle<String> match = Factory::NewSubString(subject, from, to);
|
| + Handle<String> match = isolate->factory()->NewSubString(subject, from, to);
|
| elements->set(i, *match);
|
| }
|
| - Handle<JSArray> result = Factory::NewJSArrayWithElements(elements);
|
| + Handle<JSArray> result = isolate->factory()->NewJSArrayWithElements(elements);
|
| result->set_length(Smi::FromInt(matches));
|
| return *result;
|
| }
|
| @@ -3074,7 +3206,8 @@
|
|
|
|
|
| template <typename SubjectChar, typename PatternChar>
|
| -static bool SearchStringMultiple(Vector<const SubjectChar> subject,
|
| +static bool SearchStringMultiple(Isolate* isolate,
|
| + Vector<const SubjectChar> subject,
|
| Vector<const PatternChar> pattern,
|
| String* pattern_string,
|
| FixedArrayBuilder* builder,
|
| @@ -3083,7 +3216,7 @@
|
| int subject_length = subject.length();
|
| int pattern_length = pattern.length();
|
| int max_search_start = subject_length - pattern_length;
|
| - StringSearch<PatternChar, SubjectChar> search(pattern);
|
| + StringSearch<PatternChar, SubjectChar> search(isolate, pattern);
|
| while (pos <= max_search_start) {
|
| if (!builder->HasCapacity(kMaxBuilderEntriesPerRegExpMatch)) {
|
| *match_pos = pos;
|
| @@ -3116,7 +3249,8 @@
|
| }
|
|
|
|
|
| -static bool SearchStringMultiple(Handle<String> subject,
|
| +static bool SearchStringMultiple(Isolate* isolate,
|
| + Handle<String> subject,
|
| Handle<String> pattern,
|
| Handle<JSArray> last_match_info,
|
| FixedArrayBuilder* builder) {
|
| @@ -3132,13 +3266,15 @@
|
| if (subject->IsAsciiRepresentation()) {
|
| Vector<const char> subject_vector = subject->ToAsciiVector();
|
| if (pattern->IsAsciiRepresentation()) {
|
| - if (SearchStringMultiple(subject_vector,
|
| + if (SearchStringMultiple(isolate,
|
| + subject_vector,
|
| pattern->ToAsciiVector(),
|
| *pattern,
|
| builder,
|
| &match_pos)) break;
|
| } else {
|
| - if (SearchStringMultiple(subject_vector,
|
| + if (SearchStringMultiple(isolate,
|
| + subject_vector,
|
| pattern->ToUC16Vector(),
|
| *pattern,
|
| builder,
|
| @@ -3147,13 +3283,15 @@
|
| } else {
|
| Vector<const uc16> subject_vector = subject->ToUC16Vector();
|
| if (pattern->IsAsciiRepresentation()) {
|
| - if (SearchStringMultiple(subject_vector,
|
| + if (SearchStringMultiple(isolate,
|
| + subject_vector,
|
| pattern->ToAsciiVector(),
|
| *pattern,
|
| builder,
|
| &match_pos)) break;
|
| } else {
|
| - if (SearchStringMultiple(subject_vector,
|
| + if (SearchStringMultiple(isolate,
|
| + subject_vector,
|
| pattern->ToUC16Vector(),
|
| *pattern,
|
| builder,
|
| @@ -3174,6 +3312,7 @@
|
|
|
|
|
| static RegExpImpl::IrregexpResult SearchRegExpNoCaptureMultiple(
|
| + Isolate* isolate,
|
| Handle<String> subject,
|
| Handle<JSRegExp> regexp,
|
| Handle<JSArray> last_match_array,
|
| @@ -3204,8 +3343,10 @@
|
| match_start);
|
| }
|
| match_end = register_vector[1];
|
| - HandleScope loop_scope;
|
| - builder->Add(*Factory::NewSubString(subject, match_start, match_end));
|
| + HandleScope loop_scope(isolate);
|
| + builder->Add(*isolate->factory()->NewSubString(subject,
|
| + match_start,
|
| + match_end));
|
| if (match_start != match_end) {
|
| pos = match_end;
|
| } else {
|
| @@ -3238,6 +3379,7 @@
|
|
|
|
|
| static RegExpImpl::IrregexpResult SearchRegExpMultiple(
|
| + Isolate* isolate,
|
| Handle<String> subject,
|
| Handle<JSRegExp> regexp,
|
| Handle<JSArray> last_match_array,
|
| @@ -3281,31 +3423,32 @@
|
|
|
| {
|
| // Avoid accumulating new handles inside loop.
|
| - HandleScope temp_scope;
|
| + HandleScope temp_scope(isolate);
|
| // Arguments array to replace function is match, captures, index and
|
| // subject, i.e., 3 + capture count in total.
|
| - Handle<FixedArray> elements = Factory::NewFixedArray(3 + capture_count);
|
| - Handle<String> match = Factory::NewSubString(subject,
|
| - match_start,
|
| - match_end);
|
| + Handle<FixedArray> elements =
|
| + isolate->factory()->NewFixedArray(3 + capture_count);
|
| + Handle<String> match = isolate->factory()->NewSubString(subject,
|
| + match_start,
|
| + match_end);
|
| elements->set(0, *match);
|
| for (int i = 1; i <= capture_count; i++) {
|
| int start = register_vector[i * 2];
|
| if (start >= 0) {
|
| int end = register_vector[i * 2 + 1];
|
| ASSERT(start <= end);
|
| - Handle<String> substring = Factory::NewSubString(subject,
|
| - start,
|
| - end);
|
| + Handle<String> substring = isolate->factory()->NewSubString(subject,
|
| + start,
|
| + end);
|
| elements->set(i, *substring);
|
| } else {
|
| ASSERT(register_vector[i * 2 + 1] < 0);
|
| - elements->set(i, Heap::undefined_value());
|
| + elements->set(i, isolate->heap()->undefined_value());
|
| }
|
| }
|
| elements->set(capture_count + 1, Smi::FromInt(match_start));
|
| elements->set(capture_count + 2, *subject);
|
| - builder->Add(*Factory::NewJSArrayWithElements(elements));
|
| + builder->Add(*isolate->factory()->NewJSArrayWithElements(elements));
|
| }
|
| // Swap register vectors, so the last successful match is in
|
| // prev_register_vector.
|
| @@ -3356,9 +3499,10 @@
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_RegExpExecMultiple(Arguments args) {
|
| +static MaybeObject* Runtime_RegExpExecMultiple(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| ASSERT(args.length() == 4);
|
| - HandleScope handles;
|
| + HandleScope handles(isolate);
|
|
|
| CONVERT_ARG_CHECKED(String, subject, 1);
|
| if (!subject->IsFlat()) { FlattenString(subject); }
|
| @@ -3373,7 +3517,7 @@
|
| result_elements =
|
| Handle<FixedArray>(FixedArray::cast(result_array->elements()));
|
| } else {
|
| - result_elements = Factory::NewFixedArrayWithHoles(16);
|
| + result_elements = isolate->factory()->NewFixedArrayWithHoles(16);
|
| }
|
| FixedArrayBuilder builder(result_elements);
|
|
|
| @@ -3381,31 +3525,38 @@
|
| Handle<String> pattern(
|
| String::cast(regexp->DataAt(JSRegExp::kAtomPatternIndex)));
|
| ASSERT(pattern->IsFlat());
|
| - if (SearchStringMultiple(subject, pattern, last_match_info, &builder)) {
|
| + if (SearchStringMultiple(isolate, subject, pattern,
|
| + last_match_info, &builder)) {
|
| return *builder.ToJSArray(result_array);
|
| }
|
| - return Heap::null_value();
|
| + return isolate->heap()->null_value();
|
| }
|
|
|
| ASSERT_EQ(regexp->TypeTag(), JSRegExp::IRREGEXP);
|
|
|
| RegExpImpl::IrregexpResult result;
|
| if (regexp->CaptureCount() == 0) {
|
| - result = SearchRegExpNoCaptureMultiple(subject,
|
| + result = SearchRegExpNoCaptureMultiple(isolate,
|
| + subject,
|
| regexp,
|
| last_match_info,
|
| &builder);
|
| } else {
|
| - result = SearchRegExpMultiple(subject, regexp, last_match_info, &builder);
|
| + result = SearchRegExpMultiple(isolate,
|
| + subject,
|
| + regexp,
|
| + last_match_info,
|
| + &builder);
|
| }
|
| if (result == RegExpImpl::RE_SUCCESS) return *builder.ToJSArray(result_array);
|
| - if (result == RegExpImpl::RE_FAILURE) return Heap::null_value();
|
| + if (result == RegExpImpl::RE_FAILURE) return isolate->heap()->null_value();
|
| ASSERT_EQ(result, RegExpImpl::RE_EXCEPTION);
|
| return Failure::Exception();
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_NumberToRadixString(Arguments args) {
|
| +static MaybeObject* Runtime_NumberToRadixString(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 2);
|
|
|
| @@ -3417,100 +3568,108 @@
|
| RUNTIME_ASSERT(radix <= 36);
|
| // Character array used for conversion.
|
| static const char kCharTable[] = "0123456789abcdefghijklmnopqrstuvwxyz";
|
| - return Heap::LookupSingleCharacterStringFromCode(kCharTable[value]);
|
| + return isolate->heap()->
|
| + LookupSingleCharacterStringFromCode(kCharTable[value]);
|
| }
|
| }
|
|
|
| // Slow case.
|
| CONVERT_DOUBLE_CHECKED(value, args[0]);
|
| if (isnan(value)) {
|
| - return Heap::AllocateStringFromAscii(CStrVector("NaN"));
|
| + return isolate->heap()->AllocateStringFromAscii(CStrVector("NaN"));
|
| }
|
| if (isinf(value)) {
|
| if (value < 0) {
|
| - return Heap::AllocateStringFromAscii(CStrVector("-Infinity"));
|
| + return isolate->heap()->AllocateStringFromAscii(CStrVector("-Infinity"));
|
| }
|
| - return Heap::AllocateStringFromAscii(CStrVector("Infinity"));
|
| + return isolate->heap()->AllocateStringFromAscii(CStrVector("Infinity"));
|
| }
|
| CONVERT_DOUBLE_CHECKED(radix_number, args[1]);
|
| int radix = FastD2I(radix_number);
|
| RUNTIME_ASSERT(2 <= radix && radix <= 36);
|
| char* str = DoubleToRadixCString(value, radix);
|
| - MaybeObject* result = Heap::AllocateStringFromAscii(CStrVector(str));
|
| + MaybeObject* result =
|
| + isolate->heap()->AllocateStringFromAscii(CStrVector(str));
|
| DeleteArray(str);
|
| return result;
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_NumberToFixed(Arguments args) {
|
| +static MaybeObject* Runtime_NumberToFixed(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 2);
|
|
|
| CONVERT_DOUBLE_CHECKED(value, args[0]);
|
| if (isnan(value)) {
|
| - return Heap::AllocateStringFromAscii(CStrVector("NaN"));
|
| + return isolate->heap()->AllocateStringFromAscii(CStrVector("NaN"));
|
| }
|
| if (isinf(value)) {
|
| if (value < 0) {
|
| - return Heap::AllocateStringFromAscii(CStrVector("-Infinity"));
|
| + return isolate->heap()->AllocateStringFromAscii(CStrVector("-Infinity"));
|
| }
|
| - return Heap::AllocateStringFromAscii(CStrVector("Infinity"));
|
| + return isolate->heap()->AllocateStringFromAscii(CStrVector("Infinity"));
|
| }
|
| CONVERT_DOUBLE_CHECKED(f_number, args[1]);
|
| int f = FastD2I(f_number);
|
| RUNTIME_ASSERT(f >= 0);
|
| char* str = DoubleToFixedCString(value, f);
|
| - MaybeObject* result = Heap::AllocateStringFromAscii(CStrVector(str));
|
| + MaybeObject* res =
|
| + isolate->heap()->AllocateStringFromAscii(CStrVector(str));
|
| DeleteArray(str);
|
| - return result;
|
| + return res;
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_NumberToExponential(Arguments args) {
|
| +static MaybeObject* Runtime_NumberToExponential(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 2);
|
|
|
| CONVERT_DOUBLE_CHECKED(value, args[0]);
|
| if (isnan(value)) {
|
| - return Heap::AllocateStringFromAscii(CStrVector("NaN"));
|
| + return isolate->heap()->AllocateStringFromAscii(CStrVector("NaN"));
|
| }
|
| if (isinf(value)) {
|
| if (value < 0) {
|
| - return Heap::AllocateStringFromAscii(CStrVector("-Infinity"));
|
| + return isolate->heap()->AllocateStringFromAscii(CStrVector("-Infinity"));
|
| }
|
| - return Heap::AllocateStringFromAscii(CStrVector("Infinity"));
|
| + return isolate->heap()->AllocateStringFromAscii(CStrVector("Infinity"));
|
| }
|
| CONVERT_DOUBLE_CHECKED(f_number, args[1]);
|
| int f = FastD2I(f_number);
|
| RUNTIME_ASSERT(f >= -1 && f <= 20);
|
| char* str = DoubleToExponentialCString(value, f);
|
| - MaybeObject* result = Heap::AllocateStringFromAscii(CStrVector(str));
|
| + MaybeObject* res =
|
| + isolate->heap()->AllocateStringFromAscii(CStrVector(str));
|
| DeleteArray(str);
|
| - return result;
|
| + return res;
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_NumberToPrecision(Arguments args) {
|
| +static MaybeObject* Runtime_NumberToPrecision(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 2);
|
|
|
| CONVERT_DOUBLE_CHECKED(value, args[0]);
|
| if (isnan(value)) {
|
| - return Heap::AllocateStringFromAscii(CStrVector("NaN"));
|
| + return isolate->heap()->AllocateStringFromAscii(CStrVector("NaN"));
|
| }
|
| if (isinf(value)) {
|
| if (value < 0) {
|
| - return Heap::AllocateStringFromAscii(CStrVector("-Infinity"));
|
| + return isolate->heap()->AllocateStringFromAscii(CStrVector("-Infinity"));
|
| }
|
| - return Heap::AllocateStringFromAscii(CStrVector("Infinity"));
|
| + return isolate->heap()->AllocateStringFromAscii(CStrVector("Infinity"));
|
| }
|
| CONVERT_DOUBLE_CHECKED(f_number, args[1]);
|
| int f = FastD2I(f_number);
|
| RUNTIME_ASSERT(f >= 1 && f <= 21);
|
| char* str = DoubleToPrecisionCString(value, f);
|
| - MaybeObject* result = Heap::AllocateStringFromAscii(CStrVector(str));
|
| + MaybeObject* res =
|
| + isolate->heap()->AllocateStringFromAscii(CStrVector(str));
|
| DeleteArray(str);
|
| - return result;
|
| + return res;
|
| }
|
|
|
|
|
| @@ -3526,7 +3685,8 @@
|
| }
|
|
|
|
|
| -MaybeObject* Runtime::GetElementOrCharAt(Handle<Object> object,
|
| +MaybeObject* Runtime::GetElementOrCharAt(Isolate* isolate,
|
| + Handle<Object> object,
|
| uint32_t index) {
|
| // Handle [] indexing on Strings
|
| if (object->IsString()) {
|
| @@ -3556,22 +3716,23 @@
|
| }
|
|
|
|
|
| -MaybeObject* Runtime::GetObjectProperty(Handle<Object> object,
|
| +MaybeObject* Runtime::GetObjectProperty(Isolate* isolate,
|
| + Handle<Object> object,
|
| Handle<Object> key) {
|
| - HandleScope scope;
|
| + HandleScope scope(isolate);
|
|
|
| if (object->IsUndefined() || object->IsNull()) {
|
| Handle<Object> args[2] = { key, object };
|
| Handle<Object> error =
|
| - Factory::NewTypeError("non_object_property_load",
|
| - HandleVector(args, 2));
|
| - return Top::Throw(*error);
|
| + isolate->factory()->NewTypeError("non_object_property_load",
|
| + HandleVector(args, 2));
|
| + return isolate->Throw(*error);
|
| }
|
|
|
| // Check if the given key is an array index.
|
| uint32_t index;
|
| if (key->ToArrayIndex(&index)) {
|
| - return GetElementOrCharAt(object, index);
|
| + return GetElementOrCharAt(isolate, object, index);
|
| }
|
|
|
| // Convert the key to a string - possibly by calling back into JavaScript.
|
| @@ -3589,7 +3750,7 @@
|
| // Check if the name is trivially convertible to an index and get
|
| // the element if so.
|
| if (name->AsArrayIndex(&index)) {
|
| - return GetElementOrCharAt(object, index);
|
| + return GetElementOrCharAt(isolate, object, index);
|
| } else {
|
| PropertyAttributes attr;
|
| return object->GetProperty(*name, &attr);
|
| @@ -3597,19 +3758,21 @@
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_GetProperty(Arguments args) {
|
| +static MaybeObject* Runtime_GetProperty(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 2);
|
|
|
| Handle<Object> object = args.at<Object>(0);
|
| Handle<Object> key = args.at<Object>(1);
|
|
|
| - return Runtime::GetObjectProperty(object, key);
|
| + return Runtime::GetObjectProperty(isolate, object, key);
|
| }
|
|
|
|
|
| // KeyedStringGetProperty is called from KeyedLoadIC::GenerateGeneric.
|
| -static MaybeObject* Runtime_KeyedGetProperty(Arguments args) {
|
| +static MaybeObject* Runtime_KeyedGetProperty(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 2);
|
|
|
| @@ -3633,17 +3796,18 @@
|
| if (receiver->HasFastProperties()) {
|
| // Attempt to use lookup cache.
|
| Map* receiver_map = receiver->map();
|
| - int offset = KeyedLookupCache::Lookup(receiver_map, key);
|
| + KeyedLookupCache* keyed_lookup_cache = isolate->keyed_lookup_cache();
|
| + int offset = keyed_lookup_cache->Lookup(receiver_map, key);
|
| if (offset != -1) {
|
| Object* value = receiver->FastPropertyAt(offset);
|
| - return value->IsTheHole() ? Heap::undefined_value() : value;
|
| + return value->IsTheHole() ? isolate->heap()->undefined_value() : value;
|
| }
|
| // Lookup cache miss. Perform lookup and update the cache if appropriate.
|
| LookupResult result;
|
| receiver->LocalLookup(key, &result);
|
| if (result.IsProperty() && result.type() == FIELD) {
|
| int offset = result.GetFieldIndex();
|
| - KeyedLookupCache::Update(receiver_map, key, offset);
|
| + keyed_lookup_cache->Update(receiver_map, key, offset);
|
| return receiver->FastPropertyAt(offset);
|
| }
|
| } else {
|
| @@ -3661,7 +3825,7 @@
|
| }
|
| } else if (args[0]->IsString() && args[1]->IsSmi()) {
|
| // Fast case for string indexing using [] with a smi index.
|
| - HandleScope scope;
|
| + HandleScope scope(isolate);
|
| Handle<String> str = args.at<String>(0);
|
| int index = Smi::cast(args[1])->value();
|
| if (index >= 0 && index < str->length()) {
|
| @@ -3671,7 +3835,8 @@
|
| }
|
|
|
| // Fall back to GetObjectProperty.
|
| - return Runtime::GetObjectProperty(args.at<Object>(0),
|
| + return Runtime::GetObjectProperty(isolate,
|
| + args.at<Object>(0),
|
| args.at<Object>(1));
|
| }
|
|
|
| @@ -3681,9 +3846,11 @@
|
| // Steps 9c & 12 - replace an existing data property with an accessor property.
|
| // Step 12 - update an existing accessor property with an accessor or generic
|
| // descriptor.
|
| -static MaybeObject* Runtime_DefineOrRedefineAccessorProperty(Arguments args) {
|
| +static MaybeObject* Runtime_DefineOrRedefineAccessorProperty(
|
| + RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| ASSERT(args.length() == 5);
|
| - HandleScope scope;
|
| + HandleScope scope(isolate);
|
| CONVERT_ARG_CHECKED(JSObject, obj, 0);
|
| CONVERT_CHECKED(String, name, args[1]);
|
| CONVERT_CHECKED(Smi, flag_setter, args[2]);
|
| @@ -3718,9 +3885,11 @@
|
| // Steps 9b & 12 - replace an existing accessor property with a data property.
|
| // Step 12 - update an existing data property with a data or generic
|
| // descriptor.
|
| -static MaybeObject* Runtime_DefineOrRedefineDataProperty(Arguments args) {
|
| +static MaybeObject* Runtime_DefineOrRedefineDataProperty(
|
| + RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| ASSERT(args.length() == 4);
|
| - HandleScope scope;
|
| + HandleScope scope(isolate);
|
| CONVERT_ARG_CHECKED(JSObject, js_object, 0);
|
| CONVERT_ARG_CHECKED(String, name, 1);
|
| Handle<Object> obj_value = args.at<Object>(2);
|
| @@ -3767,7 +3936,7 @@
|
| if (result.IsProperty() &&
|
| (result.type() == CALLBACKS) &&
|
| result.GetCallbackObject()->IsAccessorInfo()) {
|
| - return Heap::undefined_value();
|
| + return isolate->heap()->undefined_value();
|
| }
|
|
|
| // Take special care when attributes are different and there is already
|
| @@ -3792,23 +3961,28 @@
|
| attr);
|
| }
|
|
|
| - return Runtime::ForceSetObjectProperty(js_object, name, obj_value, attr);
|
| + return Runtime::ForceSetObjectProperty(isolate,
|
| + js_object,
|
| + name,
|
| + obj_value,
|
| + attr);
|
| }
|
|
|
|
|
| -MaybeObject* Runtime::SetObjectProperty(Handle<Object> object,
|
| +MaybeObject* Runtime::SetObjectProperty(Isolate* isolate,
|
| + Handle<Object> object,
|
| Handle<Object> key,
|
| Handle<Object> value,
|
| PropertyAttributes attr,
|
| StrictModeFlag strict_mode) {
|
| - HandleScope scope;
|
| + HandleScope scope(isolate);
|
|
|
| if (object->IsUndefined() || object->IsNull()) {
|
| Handle<Object> args[2] = { key, object };
|
| Handle<Object> error =
|
| - Factory::NewTypeError("non_object_property_store",
|
| - HandleVector(args, 2));
|
| - return Top::Throw(*error);
|
| + isolate->factory()->NewTypeError("non_object_property_store",
|
| + HandleVector(args, 2));
|
| + return isolate->Throw(*error);
|
| }
|
|
|
| // If the object isn't a JavaScript object, we ignore the store.
|
| @@ -3862,11 +4036,12 @@
|
| }
|
|
|
|
|
| -MaybeObject* Runtime::ForceSetObjectProperty(Handle<JSObject> js_object,
|
| +MaybeObject* Runtime::ForceSetObjectProperty(Isolate* isolate,
|
| + Handle<JSObject> js_object,
|
| Handle<Object> key,
|
| Handle<Object> value,
|
| PropertyAttributes attr) {
|
| - HandleScope scope;
|
| + HandleScope scope(isolate);
|
|
|
| // Check if the given key is an array index.
|
| uint32_t index;
|
| @@ -3911,9 +4086,10 @@
|
| }
|
|
|
|
|
| -MaybeObject* Runtime::ForceDeleteObjectProperty(Handle<JSObject> js_object,
|
| +MaybeObject* Runtime::ForceDeleteObjectProperty(Isolate* isolate,
|
| + Handle<JSObject> js_object,
|
| Handle<Object> key) {
|
| - HandleScope scope;
|
| + HandleScope scope(isolate);
|
|
|
| // Check if the given key is an array index.
|
| uint32_t index;
|
| @@ -3925,7 +4101,7 @@
|
| // underlying string does nothing with the deletion, we can ignore
|
| // such deletions.
|
| if (js_object->IsStringObjectWithCharacterAt(index)) {
|
| - return Heap::true_value();
|
| + return isolate->heap()->true_value();
|
| }
|
|
|
| return js_object->DeleteElement(index, JSObject::FORCE_DELETION);
|
| @@ -3947,7 +4123,8 @@
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_SetProperty(Arguments args) {
|
| +static MaybeObject* Runtime_SetProperty(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| RUNTIME_ASSERT(args.length() == 4 || args.length() == 5);
|
|
|
| @@ -3969,7 +4146,8 @@
|
| strict_mode = static_cast<StrictModeFlag>(strict_unchecked);
|
| }
|
|
|
| - return Runtime::SetObjectProperty(object,
|
| + return Runtime::SetObjectProperty(isolate,
|
| + object,
|
| key,
|
| value,
|
| attributes,
|
| @@ -3979,7 +4157,9 @@
|
|
|
| // Set a local property, even if it is READ_ONLY. If the property does not
|
| // exist, it will be added with attributes NONE.
|
| -static MaybeObject* Runtime_IgnoreAttributesAndSetProperty(Arguments args) {
|
| +static MaybeObject* Runtime_IgnoreAttributesAndSetProperty(
|
| + RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| RUNTIME_ASSERT(args.length() == 3 || args.length() == 4);
|
| CONVERT_CHECKED(JSObject, object, args[0]);
|
| @@ -4000,7 +4180,8 @@
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_DeleteProperty(Arguments args) {
|
| +static MaybeObject* Runtime_DeleteProperty(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 3);
|
|
|
| @@ -4013,22 +4194,26 @@
|
| }
|
|
|
|
|
| -static Object* HasLocalPropertyImplementation(Handle<JSObject> object,
|
| +static Object* HasLocalPropertyImplementation(Isolate* isolate,
|
| + Handle<JSObject> object,
|
| Handle<String> key) {
|
| - if (object->HasLocalProperty(*key)) return Heap::true_value();
|
| + if (object->HasLocalProperty(*key)) return isolate->heap()->true_value();
|
| // Handle hidden prototypes. If there's a hidden prototype above this thing
|
| // then we have to check it for properties, because they are supposed to
|
| // look like they are on this object.
|
| Handle<Object> proto(object->GetPrototype());
|
| if (proto->IsJSObject() &&
|
| Handle<JSObject>::cast(proto)->map()->is_hidden_prototype()) {
|
| - return HasLocalPropertyImplementation(Handle<JSObject>::cast(proto), key);
|
| + return HasLocalPropertyImplementation(isolate,
|
| + Handle<JSObject>::cast(proto),
|
| + key);
|
| }
|
| - return Heap::false_value();
|
| + return isolate->heap()->false_value();
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_HasLocalProperty(Arguments args) {
|
| +static MaybeObject* Runtime_HasLocalProperty(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 2);
|
| CONVERT_CHECKED(String, key, args[1]);
|
| @@ -4038,11 +4223,12 @@
|
| if (obj->IsJSObject()) {
|
| JSObject* object = JSObject::cast(obj);
|
| // Fast case - no interceptors.
|
| - if (object->HasRealNamedProperty(key)) return Heap::true_value();
|
| + if (object->HasRealNamedProperty(key)) return isolate->heap()->true_value();
|
| // Slow case. Either it's not there or we have an interceptor. We should
|
| // have handles for this kind of deal.
|
| - HandleScope scope;
|
| - return HasLocalPropertyImplementation(Handle<JSObject>(object),
|
| + HandleScope scope(isolate);
|
| + return HasLocalPropertyImplementation(isolate,
|
| + Handle<JSObject>(object),
|
| Handle<String>(key));
|
| } else if (obj->IsString()) {
|
| // Well, there is one exception: Handle [] on strings.
|
| @@ -4050,14 +4236,15 @@
|
| if (key->AsArrayIndex(&index)) {
|
| String* string = String::cast(obj);
|
| if (index < static_cast<uint32_t>(string->length()))
|
| - return Heap::true_value();
|
| + return isolate->heap()->true_value();
|
| }
|
| }
|
| - return Heap::false_value();
|
| + return isolate->heap()->false_value();
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_HasProperty(Arguments args) {
|
| +static MaybeObject* Runtime_HasProperty(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation na;
|
| ASSERT(args.length() == 2);
|
|
|
| @@ -4065,13 +4252,14 @@
|
| if (args[0]->IsJSObject()) {
|
| JSObject* object = JSObject::cast(args[0]);
|
| CONVERT_CHECKED(String, key, args[1]);
|
| - if (object->HasProperty(key)) return Heap::true_value();
|
| + if (object->HasProperty(key)) return isolate->heap()->true_value();
|
| }
|
| - return Heap::false_value();
|
| + return isolate->heap()->false_value();
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_HasElement(Arguments args) {
|
| +static MaybeObject* Runtime_HasElement(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation na;
|
| ASSERT(args.length() == 2);
|
|
|
| @@ -4080,13 +4268,14 @@
|
| JSObject* object = JSObject::cast(args[0]);
|
| CONVERT_CHECKED(Smi, index_obj, args[1]);
|
| uint32_t index = index_obj->value();
|
| - if (object->HasElement(index)) return Heap::true_value();
|
| + if (object->HasElement(index)) return isolate->heap()->true_value();
|
| }
|
| - return Heap::false_value();
|
| + return isolate->heap()->false_value();
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_IsPropertyEnumerable(Arguments args) {
|
| +static MaybeObject* Runtime_IsPropertyEnumerable(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 2);
|
|
|
| @@ -4095,16 +4284,17 @@
|
|
|
| uint32_t index;
|
| if (key->AsArrayIndex(&index)) {
|
| - return Heap::ToBoolean(object->HasElement(index));
|
| + return isolate->heap()->ToBoolean(object->HasElement(index));
|
| }
|
|
|
| PropertyAttributes att = object->GetLocalPropertyAttribute(key);
|
| - return Heap::ToBoolean(att != ABSENT && (att & DONT_ENUM) == 0);
|
| + return isolate->heap()->ToBoolean(att != ABSENT && (att & DONT_ENUM) == 0);
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_GetPropertyNames(Arguments args) {
|
| - HandleScope scope;
|
| +static MaybeObject* Runtime_GetPropertyNames(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| + HandleScope scope(isolate);
|
| ASSERT(args.length() == 1);
|
| CONVERT_ARG_CHECKED(JSObject, object, 0);
|
| return *GetKeysFor(object);
|
| @@ -4116,14 +4306,15 @@
|
| // all enumerable properties of the object and its prototypes
|
| // have none, the map of the object. This is used to speed up
|
| // the check for deletions during a for-in.
|
| -static MaybeObject* Runtime_GetPropertyNamesFast(Arguments args) {
|
| +static MaybeObject* Runtime_GetPropertyNamesFast(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| ASSERT(args.length() == 1);
|
|
|
| CONVERT_CHECKED(JSObject, raw_object, args[0]);
|
|
|
| if (raw_object->IsSimpleEnum()) return raw_object->map();
|
|
|
| - HandleScope scope;
|
| + HandleScope scope(isolate);
|
| Handle<JSObject> object(raw_object);
|
| Handle<FixedArray> content = GetKeysInFixedArrayFor(object,
|
| INCLUDE_PROTOS);
|
| @@ -4152,11 +4343,12 @@
|
|
|
| // Return the names of the local named properties.
|
| // args[0]: object
|
| -static MaybeObject* Runtime_GetLocalPropertyNames(Arguments args) {
|
| - HandleScope scope;
|
| +static MaybeObject* Runtime_GetLocalPropertyNames(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| + HandleScope scope(isolate);
|
| ASSERT(args.length() == 1);
|
| if (!args[0]->IsJSObject()) {
|
| - return Heap::undefined_value();
|
| + return isolate->heap()->undefined_value();
|
| }
|
| CONVERT_ARG_CHECKED(JSObject, obj, 0);
|
|
|
| @@ -4165,9 +4357,11 @@
|
| if (obj->IsJSGlobalProxy()) {
|
| // Only collect names if access is permitted.
|
| if (obj->IsAccessCheckNeeded() &&
|
| - !Top::MayNamedAccess(*obj, Heap::undefined_value(), v8::ACCESS_KEYS)) {
|
| - Top::ReportFailedAccessCheck(*obj, v8::ACCESS_KEYS);
|
| - return *Factory::NewJSArray(0);
|
| + !isolate->MayNamedAccess(*obj,
|
| + isolate->heap()->undefined_value(),
|
| + v8::ACCESS_KEYS)) {
|
| + isolate->ReportFailedAccessCheck(*obj, v8::ACCESS_KEYS);
|
| + return *isolate->factory()->NewJSArray(0);
|
| }
|
| obj = Handle<JSObject>(JSObject::cast(obj->GetPrototype()));
|
| }
|
| @@ -4182,11 +4376,11 @@
|
| for (int i = 0; i < length; i++) {
|
| // Only collect names if access is permitted.
|
| if (jsproto->IsAccessCheckNeeded() &&
|
| - !Top::MayNamedAccess(*jsproto,
|
| - Heap::undefined_value(),
|
| - v8::ACCESS_KEYS)) {
|
| - Top::ReportFailedAccessCheck(*jsproto, v8::ACCESS_KEYS);
|
| - return *Factory::NewJSArray(0);
|
| + !isolate->MayNamedAccess(*jsproto,
|
| + isolate->heap()->undefined_value(),
|
| + v8::ACCESS_KEYS)) {
|
| + isolate->ReportFailedAccessCheck(*jsproto, v8::ACCESS_KEYS);
|
| + return *isolate->factory()->NewJSArray(0);
|
| }
|
| int n;
|
| n = jsproto->NumberOfLocalProperties(static_cast<PropertyAttributes>(NONE));
|
| @@ -4198,7 +4392,8 @@
|
| }
|
|
|
| // Allocate an array with storage for all the property names.
|
| - Handle<FixedArray> names = Factory::NewFixedArray(total_property_count);
|
| + Handle<FixedArray> names =
|
| + isolate->factory()->NewFixedArray(total_property_count);
|
|
|
| // Get the property names.
|
| jsproto = obj;
|
| @@ -4217,43 +4412,45 @@
|
| // Filter out name of hidden propeties object.
|
| if (proto_with_hidden_properties > 0) {
|
| Handle<FixedArray> old_names = names;
|
| - names = Factory::NewFixedArray(
|
| + names = isolate->factory()->NewFixedArray(
|
| names->length() - proto_with_hidden_properties);
|
| int dest_pos = 0;
|
| for (int i = 0; i < total_property_count; i++) {
|
| Object* name = old_names->get(i);
|
| - if (name == Heap::hidden_symbol()) {
|
| + if (name == isolate->heap()->hidden_symbol()) {
|
| continue;
|
| }
|
| names->set(dest_pos++, name);
|
| }
|
| }
|
|
|
| - return *Factory::NewJSArrayWithElements(names);
|
| + return *isolate->factory()->NewJSArrayWithElements(names);
|
| }
|
|
|
|
|
| // Return the names of the local indexed properties.
|
| // args[0]: object
|
| -static MaybeObject* Runtime_GetLocalElementNames(Arguments args) {
|
| - HandleScope scope;
|
| +static MaybeObject* Runtime_GetLocalElementNames(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| + HandleScope scope(isolate);
|
| ASSERT(args.length() == 1);
|
| if (!args[0]->IsJSObject()) {
|
| - return Heap::undefined_value();
|
| + return isolate->heap()->undefined_value();
|
| }
|
| CONVERT_ARG_CHECKED(JSObject, obj, 0);
|
|
|
| int n = obj->NumberOfLocalElements(static_cast<PropertyAttributes>(NONE));
|
| - Handle<FixedArray> names = Factory::NewFixedArray(n);
|
| + Handle<FixedArray> names = isolate->factory()->NewFixedArray(n);
|
| obj->GetLocalElementKeys(*names, static_cast<PropertyAttributes>(NONE));
|
| - return *Factory::NewJSArrayWithElements(names);
|
| + return *isolate->factory()->NewJSArrayWithElements(names);
|
| }
|
|
|
|
|
| // Return information on whether an object has a named or indexed interceptor.
|
| // args[0]: object
|
| -static MaybeObject* Runtime_GetInterceptorInfo(Arguments args) {
|
| - HandleScope scope;
|
| +static MaybeObject* Runtime_GetInterceptorInfo(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| + HandleScope scope(isolate);
|
| ASSERT(args.length() == 1);
|
| if (!args[0]->IsJSObject()) {
|
| return Smi::FromInt(0);
|
| @@ -4270,8 +4467,10 @@
|
|
|
| // Return property names from named interceptor.
|
| // args[0]: object
|
| -static MaybeObject* Runtime_GetNamedInterceptorPropertyNames(Arguments args) {
|
| - HandleScope scope;
|
| +static MaybeObject* Runtime_GetNamedInterceptorPropertyNames(
|
| + RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| + HandleScope scope(isolate);
|
| ASSERT(args.length() == 1);
|
| CONVERT_ARG_CHECKED(JSObject, obj, 0);
|
|
|
| @@ -4279,14 +4478,16 @@
|
| v8::Handle<v8::Array> result = GetKeysForNamedInterceptor(obj, obj);
|
| if (!result.IsEmpty()) return *v8::Utils::OpenHandle(*result);
|
| }
|
| - return Heap::undefined_value();
|
| + return isolate->heap()->undefined_value();
|
| }
|
|
|
|
|
| // Return element names from indexed interceptor.
|
| // args[0]: object
|
| -static MaybeObject* Runtime_GetIndexedInterceptorElementNames(Arguments args) {
|
| - HandleScope scope;
|
| +static MaybeObject* Runtime_GetIndexedInterceptorElementNames(
|
| + RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| + HandleScope scope(isolate);
|
| ASSERT(args.length() == 1);
|
| CONVERT_ARG_CHECKED(JSObject, obj, 0);
|
|
|
| @@ -4294,28 +4495,29 @@
|
| v8::Handle<v8::Array> result = GetKeysForIndexedInterceptor(obj, obj);
|
| if (!result.IsEmpty()) return *v8::Utils::OpenHandle(*result);
|
| }
|
| - return Heap::undefined_value();
|
| + return isolate->heap()->undefined_value();
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_LocalKeys(Arguments args) {
|
| +static MaybeObject* Runtime_LocalKeys(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| ASSERT_EQ(args.length(), 1);
|
| CONVERT_CHECKED(JSObject, raw_object, args[0]);
|
| - HandleScope scope;
|
| + HandleScope scope(isolate);
|
| Handle<JSObject> object(raw_object);
|
|
|
| if (object->IsJSGlobalProxy()) {
|
| // Do access checks before going to the global object.
|
| if (object->IsAccessCheckNeeded() &&
|
| - !Top::MayNamedAccess(*object, Heap::undefined_value(),
|
| + !isolate->MayNamedAccess(*object, isolate->heap()->undefined_value(),
|
| v8::ACCESS_KEYS)) {
|
| - Top::ReportFailedAccessCheck(*object, v8::ACCESS_KEYS);
|
| - return *Factory::NewJSArray(0);
|
| + isolate->ReportFailedAccessCheck(*object, v8::ACCESS_KEYS);
|
| + return *isolate->factory()->NewJSArray(0);
|
| }
|
|
|
| Handle<Object> proto(object->GetPrototype());
|
| // If proxy is detached we simply return an empty array.
|
| - if (proto->IsNull()) return *Factory::NewJSArray(0);
|
| + if (proto->IsNull()) return *isolate->factory()->NewJSArray(0);
|
| object = Handle<JSObject>::cast(proto);
|
| }
|
|
|
| @@ -4325,24 +4527,26 @@
|
| // property array and since the result is mutable we have to create
|
| // a fresh clone on each invocation.
|
| int length = contents->length();
|
| - Handle<FixedArray> copy = Factory::NewFixedArray(length);
|
| + Handle<FixedArray> copy = isolate->factory()->NewFixedArray(length);
|
| for (int i = 0; i < length; i++) {
|
| Object* entry = contents->get(i);
|
| if (entry->IsString()) {
|
| copy->set(i, entry);
|
| } else {
|
| ASSERT(entry->IsNumber());
|
| - HandleScope scope;
|
| - Handle<Object> entry_handle(entry);
|
| - Handle<Object> entry_str = Factory::NumberToString(entry_handle);
|
| + HandleScope scope(isolate);
|
| + Handle<Object> entry_handle(entry, isolate);
|
| + Handle<Object> entry_str =
|
| + isolate->factory()->NumberToString(entry_handle);
|
| copy->set(i, *entry_str);
|
| }
|
| }
|
| - return *Factory::NewJSArrayWithElements(copy);
|
| + return *isolate->factory()->NewJSArrayWithElements(copy);
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_GetArgumentsProperty(Arguments args) {
|
| +static MaybeObject* Runtime_GetArgumentsProperty(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 1);
|
|
|
| @@ -4362,7 +4566,7 @@
|
| }
|
|
|
| // Convert the key to a string.
|
| - HandleScope scope;
|
| + HandleScope scope(isolate);
|
| bool exception = false;
|
| Handle<Object> converted =
|
| Execution::ToString(args.at<Object>(0), &exception);
|
| @@ -4374,29 +4578,30 @@
|
| if (index < n) {
|
| return frame->GetParameter(index);
|
| } else {
|
| - return Top::initial_object_prototype()->GetElement(index);
|
| + return isolate->initial_object_prototype()->GetElement(index);
|
| }
|
| }
|
|
|
| // Handle special arguments properties.
|
| - if (key->Equals(Heap::length_symbol())) return Smi::FromInt(n);
|
| - if (key->Equals(Heap::callee_symbol())) {
|
| + if (key->Equals(isolate->heap()->length_symbol())) return Smi::FromInt(n);
|
| + if (key->Equals(isolate->heap()->callee_symbol())) {
|
| Object* function = frame->function();
|
| if (function->IsJSFunction() &&
|
| JSFunction::cast(function)->shared()->strict_mode()) {
|
| - return Top::Throw(*Factory::NewTypeError("strict_arguments_callee",
|
| - HandleVector<Object>(NULL, 0)));
|
| + return isolate->Throw(*isolate->factory()->NewTypeError(
|
| + "strict_arguments_callee", HandleVector<Object>(NULL, 0)));
|
| }
|
| return function;
|
| }
|
|
|
| // Lookup in the initial Object.prototype object.
|
| - return Top::initial_object_prototype()->GetProperty(*key);
|
| + return isolate->initial_object_prototype()->GetProperty(*key);
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_ToFastProperties(Arguments args) {
|
| - HandleScope scope;
|
| +static MaybeObject* Runtime_ToFastProperties(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| + HandleScope scope(isolate);
|
|
|
| ASSERT(args.length() == 1);
|
| Handle<Object> object = args.at<Object>(0);
|
| @@ -4411,8 +4616,9 @@
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_ToSlowProperties(Arguments args) {
|
| - HandleScope scope;
|
| +static MaybeObject* Runtime_ToSlowProperties(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| + HandleScope scope(isolate);
|
|
|
| ASSERT(args.length() == 1);
|
| Handle<Object> object = args.at<Object>(0);
|
| @@ -4424,7 +4630,8 @@
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_ToBool(Arguments args) {
|
| +static MaybeObject* Runtime_ToBool(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 1);
|
|
|
| @@ -4434,37 +4641,40 @@
|
|
|
| // Returns the type string of a value; see ECMA-262, 11.4.3 (p 47).
|
| // Possible optimizations: put the type string into the oddballs.
|
| -static MaybeObject* Runtime_Typeof(Arguments args) {
|
| +static MaybeObject* Runtime_Typeof(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
|
|
| Object* obj = args[0];
|
| - if (obj->IsNumber()) return Heap::number_symbol();
|
| + if (obj->IsNumber()) return isolate->heap()->number_symbol();
|
| HeapObject* heap_obj = HeapObject::cast(obj);
|
|
|
| // typeof an undetectable object is 'undefined'
|
| - if (heap_obj->map()->is_undetectable()) return Heap::undefined_symbol();
|
| + if (heap_obj->map()->is_undetectable()) {
|
| + return isolate->heap()->undefined_symbol();
|
| + }
|
|
|
| InstanceType instance_type = heap_obj->map()->instance_type();
|
| if (instance_type < FIRST_NONSTRING_TYPE) {
|
| - return Heap::string_symbol();
|
| + return isolate->heap()->string_symbol();
|
| }
|
|
|
| switch (instance_type) {
|
| case ODDBALL_TYPE:
|
| if (heap_obj->IsTrue() || heap_obj->IsFalse()) {
|
| - return Heap::boolean_symbol();
|
| + return isolate->heap()->boolean_symbol();
|
| }
|
| if (heap_obj->IsNull()) {
|
| - return Heap::object_symbol();
|
| + return isolate->heap()->object_symbol();
|
| }
|
| ASSERT(heap_obj->IsUndefined());
|
| - return Heap::undefined_symbol();
|
| + return isolate->heap()->undefined_symbol();
|
| case JS_FUNCTION_TYPE: case JS_REGEXP_TYPE:
|
| - return Heap::function_symbol();
|
| + return isolate->heap()->function_symbol();
|
| default:
|
| // For any kind of object not handled above, the spec rule for
|
| // host objects gives that it is okay to return "object"
|
| - return Heap::object_symbol();
|
| + return isolate->heap()->object_symbol();
|
| }
|
| }
|
|
|
| @@ -4491,7 +4701,8 @@
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_StringToNumber(Arguments args) {
|
| +static MaybeObject* Runtime_StringToNumber(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 1);
|
| CONVERT_CHECKED(String, subject, args[0]);
|
| @@ -4507,21 +4718,21 @@
|
| int start_pos = (minus ? 1 : 0);
|
|
|
| if (start_pos == len) {
|
| - return Heap::nan_value();
|
| + return isolate->heap()->nan_value();
|
| } else if (data[start_pos] > '9') {
|
| // Fast check for a junk value. A valid string may start from a
|
| // whitespace, a sign ('+' or '-'), the decimal point, a decimal digit or
|
| // the 'I' character ('Infinity'). All of that have codes not greater than
|
| // '9' except 'I'.
|
| if (data[start_pos] != 'I') {
|
| - return Heap::nan_value();
|
| + return isolate->heap()->nan_value();
|
| }
|
| } else if (len - start_pos < 10 && AreDigits(data, start_pos, len)) {
|
| // The maximal/minimal smi has 10 digits. If the string has less digits we
|
| // know it will fit into the smi-data type.
|
| int d = ParseDecimalInteger(data, start_pos, len);
|
| if (minus) {
|
| - if (d == 0) return Heap::minus_zero_value();
|
| + if (d == 0) return isolate->heap()->minus_zero_value();
|
| d = -d;
|
| } else if (!subject->HasHashCode() &&
|
| len <= String::kMaxArrayIndexSize &&
|
| @@ -4541,11 +4752,13 @@
|
| }
|
|
|
| // Slower case.
|
| - return Heap::NumberFromDouble(StringToDouble(subject, ALLOW_HEX));
|
| + return isolate->heap()->NumberFromDouble(StringToDouble(subject, ALLOW_HEX));
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_StringFromCharCodeArray(Arguments args) {
|
| +static MaybeObject* Runtime_StringFromCharCodeArray(
|
| + RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 1);
|
|
|
| @@ -4568,9 +4781,9 @@
|
|
|
| MaybeObject* maybe_object = NULL;
|
| if (i == length) { // The string is ASCII.
|
| - maybe_object = Heap::AllocateRawAsciiString(length);
|
| + maybe_object = isolate->heap()->AllocateRawAsciiString(length);
|
| } else { // The string is not ASCII.
|
| - maybe_object = Heap::AllocateRawTwoByteString(length);
|
| + maybe_object = isolate->heap()->AllocateRawTwoByteString(length);
|
| }
|
|
|
| Object* object = NULL;
|
| @@ -4625,7 +4838,8 @@
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_URIEscape(Arguments args) {
|
| +static MaybeObject* Runtime_URIEscape(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| const char hex_chars[] = "0123456789ABCDEF";
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 1);
|
| @@ -4636,7 +4850,8 @@
|
| int escaped_length = 0;
|
| int length = source->length();
|
| {
|
| - Access<StringInputBuffer> buffer(&runtime_string_input_buffer);
|
| + Access<StringInputBuffer> buffer(
|
| + isolate->runtime_state()->string_input_buffer());
|
| buffer->Reset(source);
|
| while (buffer->has_more()) {
|
| uint16_t character = buffer->GetNext();
|
| @@ -4650,7 +4865,7 @@
|
| // We don't allow strings that are longer than a maximal length.
|
| ASSERT(String::kMaxLength < 0x7fffffff - 6); // Cannot overflow.
|
| if (escaped_length > String::kMaxLength) {
|
| - Top::context()->mark_out_of_memory();
|
| + isolate->context()->mark_out_of_memory();
|
| return Failure::OutOfMemoryException();
|
| }
|
| }
|
| @@ -4660,13 +4875,15 @@
|
| return source;
|
| }
|
| Object* o;
|
| - { MaybeObject* maybe_o = Heap::AllocateRawAsciiString(escaped_length);
|
| + { MaybeObject* maybe_o =
|
| + isolate->heap()->AllocateRawAsciiString(escaped_length);
|
| if (!maybe_o->ToObject(&o)) return maybe_o;
|
| }
|
| String* destination = String::cast(o);
|
| int dest_position = 0;
|
|
|
| - Access<StringInputBuffer> buffer(&runtime_string_input_buffer);
|
| + Access<StringInputBuffer> buffer(
|
| + isolate->runtime_state()->string_input_buffer());
|
| buffer->Rewind();
|
| while (buffer->has_more()) {
|
| uint16_t chr = buffer->GetNext();
|
| @@ -4741,7 +4958,8 @@
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_URIUnescape(Arguments args) {
|
| +static MaybeObject* Runtime_URIUnescape(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 1);
|
| CONVERT_CHECKED(String, source, args[0]);
|
| @@ -4765,9 +4983,10 @@
|
| return source;
|
|
|
| Object* o;
|
| - { MaybeObject* maybe_o = ascii ?
|
| - Heap::AllocateRawAsciiString(unescaped_length) :
|
| - Heap::AllocateRawTwoByteString(unescaped_length);
|
| + { MaybeObject* maybe_o =
|
| + ascii ?
|
| + isolate->heap()->AllocateRawAsciiString(unescaped_length) :
|
| + isolate->heap()->AllocateRawTwoByteString(unescaped_length);
|
| if (!maybe_o->ToObject(&o)) return maybe_o;
|
| }
|
| String* destination = String::cast(o);
|
| @@ -4857,13 +5076,13 @@
|
|
|
| template <>
|
| MaybeObject* AllocateRawString<SeqTwoByteString>(int length) {
|
| - return Heap::AllocateRawTwoByteString(length);
|
| + return HEAP->AllocateRawTwoByteString(length);
|
| }
|
|
|
|
|
| template <>
|
| MaybeObject* AllocateRawString<SeqAsciiString>(int length) {
|
| - return Heap::AllocateRawAsciiString(length);
|
| + return HEAP->AllocateRawAsciiString(length);
|
| }
|
|
|
|
|
| @@ -4916,7 +5135,7 @@
|
| template <typename Char, typename StringType, bool comma>
|
| static MaybeObject* QuoteJsonString(Vector<const Char> characters) {
|
| int length = characters.length();
|
| - Counters::quote_json_char_count.Increment(length);
|
| + COUNTERS->quote_json_char_count()->Increment(length);
|
| const int kSpaceForQuotes = 2 + (comma ? 1 :0);
|
| int worst_case_length = length * kJsonQuoteWorstCaseBlowup + kSpaceForQuotes;
|
| if (worst_case_length > kMaxGuaranteedNewSpaceString) {
|
| @@ -4928,7 +5147,7 @@
|
| if (!new_alloc->ToObject(&new_object)) {
|
| return new_alloc;
|
| }
|
| - if (!Heap::new_space()->Contains(new_object)) {
|
| + if (!HEAP->new_space()->Contains(new_object)) {
|
| // Even if our string is small enough to fit in new space we still have to
|
| // handle it being allocated in old space as may happen in the third
|
| // attempt. See CALL_AND_RETRY in heap-inl.h and similar code in
|
| @@ -4936,7 +5155,7 @@
|
| return SlowQuoteJsonString<Char, StringType, comma>(characters);
|
| }
|
| StringType* new_string = StringType::cast(new_object);
|
| - ASSERT(Heap::new_space()->Contains(new_string));
|
| + ASSERT(HEAP->new_space()->Contains(new_string));
|
|
|
| STATIC_ASSERT(SeqTwoByteString::kHeaderSize == SeqAsciiString::kHeaderSize);
|
| Char* write_cursor = reinterpret_cast<Char*>(
|
| @@ -4973,13 +5192,14 @@
|
| int final_length = static_cast<int>(
|
| write_cursor - reinterpret_cast<Char*>(
|
| new_string->address() + SeqAsciiString::kHeaderSize));
|
| - Heap::new_space()->ShrinkStringAtAllocationBoundary<StringType>(new_string,
|
| + HEAP->new_space()->ShrinkStringAtAllocationBoundary<StringType>(new_string,
|
| final_length);
|
| return new_string;
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_QuoteJSONString(Arguments args) {
|
| +static MaybeObject* Runtime_QuoteJSONString(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| CONVERT_CHECKED(String, str, args[0]);
|
| if (!str->IsFlat()) {
|
| @@ -4999,7 +5219,8 @@
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_QuoteJSONStringComma(Arguments args) {
|
| +static MaybeObject* Runtime_QuoteJSONStringComma(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| CONVERT_CHECKED(String, str, args[0]);
|
| if (!str->IsFlat()) {
|
| @@ -5018,8 +5239,8 @@
|
| }
|
| }
|
|
|
| -
|
| -static MaybeObject* Runtime_StringParseInt(Arguments args) {
|
| +static MaybeObject* Runtime_StringParseInt(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
|
|
| CONVERT_CHECKED(String, s, args[0]);
|
| @@ -5029,11 +5250,12 @@
|
|
|
| RUNTIME_ASSERT(radix == 0 || (2 <= radix && radix <= 36));
|
| double value = StringToInt(s, radix);
|
| - return Heap::NumberFromDouble(value);
|
| + return isolate->heap()->NumberFromDouble(value);
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_StringParseFloat(Arguments args) {
|
| +static MaybeObject* Runtime_StringParseFloat(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| CONVERT_CHECKED(String, str, args[0]);
|
|
|
| @@ -5041,16 +5263,13 @@
|
| double value = StringToDouble(str, ALLOW_TRAILING_JUNK, OS::nan_value());
|
|
|
| // Create a number object from the value.
|
| - return Heap::NumberFromDouble(value);
|
| + return isolate->heap()->NumberFromDouble(value);
|
| }
|
|
|
|
|
| -static unibrow::Mapping<unibrow::ToUppercase, 128> to_upper_mapping;
|
| -static unibrow::Mapping<unibrow::ToLowercase, 128> to_lower_mapping;
|
| -
|
| -
|
| template <class Converter>
|
| MUST_USE_RESULT static MaybeObject* ConvertCaseHelper(
|
| + Isolate* isolate,
|
| String* s,
|
| int length,
|
| int input_string_length,
|
| @@ -5068,8 +5287,8 @@
|
| // dependent upper/lower conversions.
|
| Object* o;
|
| { MaybeObject* maybe_o = s->IsAsciiRepresentation()
|
| - ? Heap::AllocateRawAsciiString(length)
|
| - : Heap::AllocateRawTwoByteString(length);
|
| + ? isolate->heap()->AllocateRawAsciiString(length)
|
| + : isolate->heap()->AllocateRawTwoByteString(length);
|
| if (!maybe_o->ToObject(&o)) return maybe_o;
|
| }
|
| String* result = String::cast(o);
|
| @@ -5077,7 +5296,8 @@
|
|
|
| // Convert all characters to upper case, assuming that they will fit
|
| // in the buffer
|
| - Access<StringInputBuffer> buffer(&runtime_string_input_buffer);
|
| + Access<StringInputBuffer> buffer(
|
| + isolate->runtime_state()->string_input_buffer());
|
| buffer->Reset(s);
|
| unibrow::uchar chars[Converter::kMaxWidth];
|
| // We can assume that the string is not empty
|
| @@ -5124,7 +5344,7 @@
|
| if (char_length == 0) char_length = 1;
|
| current_length += char_length;
|
| if (current_length > Smi::kMaxValue) {
|
| - Top::context()->mark_out_of_memory();
|
| + isolate->context()->mark_out_of_memory();
|
| return Failure::OutOfMemoryException();
|
| }
|
| }
|
| @@ -5282,6 +5502,7 @@
|
| template <typename ConvertTraits>
|
| MUST_USE_RESULT static MaybeObject* ConvertCase(
|
| Arguments args,
|
| + Isolate* isolate,
|
| unibrow::Mapping<typename ConvertTraits::UnibrowConverter, 128>* mapping) {
|
| NoHandleAllocation ha;
|
| CONVERT_CHECKED(String, s, args[0]);
|
| @@ -5299,7 +5520,7 @@
|
| // dependent upper/lower conversions.
|
| if (s->IsSeqAsciiString()) {
|
| Object* o;
|
| - { MaybeObject* maybe_o = Heap::AllocateRawAsciiString(length);
|
| + { MaybeObject* maybe_o = isolate->heap()->AllocateRawAsciiString(length);
|
| if (!maybe_o->ToObject(&o)) return maybe_o;
|
| }
|
| SeqAsciiString* result = SeqAsciiString::cast(o);
|
| @@ -5309,13 +5530,15 @@
|
| }
|
|
|
| Object* answer;
|
| - { MaybeObject* maybe_answer = ConvertCaseHelper(s, length, length, mapping);
|
| + { MaybeObject* maybe_answer =
|
| + ConvertCaseHelper(isolate, s, length, length, mapping);
|
| if (!maybe_answer->ToObject(&answer)) return maybe_answer;
|
| }
|
| if (answer->IsSmi()) {
|
| // Retry with correct length.
|
| { MaybeObject* maybe_answer =
|
| - ConvertCaseHelper(s, Smi::cast(answer)->value(), length, mapping);
|
| + ConvertCaseHelper(isolate,
|
| + s, Smi::cast(answer)->value(), length, mapping);
|
| if (!maybe_answer->ToObject(&answer)) return maybe_answer;
|
| }
|
| }
|
| @@ -5323,13 +5546,17 @@
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_StringToLowerCase(Arguments args) {
|
| - return ConvertCase<ToLowerTraits>(args, &to_lower_mapping);
|
| +static MaybeObject* Runtime_StringToLowerCase(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| + return ConvertCase<ToLowerTraits>(
|
| + args, isolate, isolate->runtime_state()->to_lower_mapping());
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_StringToUpperCase(Arguments args) {
|
| - return ConvertCase<ToUpperTraits>(args, &to_upper_mapping);
|
| +static MaybeObject* Runtime_StringToUpperCase(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| + return ConvertCase<ToUpperTraits>(
|
| + args, isolate, isolate->runtime_state()->to_upper_mapping());
|
| }
|
|
|
|
|
| @@ -5338,7 +5565,8 @@
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_StringTrim(Arguments args) {
|
| +static MaybeObject* Runtime_StringTrim(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 3);
|
|
|
| @@ -5367,14 +5595,15 @@
|
|
|
|
|
| template <typename SubjectChar, typename PatternChar>
|
| -void FindStringIndices(Vector<const SubjectChar> subject,
|
| +void FindStringIndices(Isolate* isolate,
|
| + Vector<const SubjectChar> subject,
|
| Vector<const PatternChar> pattern,
|
| ZoneList<int>* indices,
|
| unsigned int limit) {
|
| ASSERT(limit > 0);
|
| // Collect indices of pattern in subject, and the end-of-string index.
|
| // Stop after finding at most limit values.
|
| - StringSearch<PatternChar, SubjectChar> search(pattern);
|
| + StringSearch<PatternChar, SubjectChar> search(isolate, pattern);
|
| int pattern_length = pattern.length();
|
| int index = 0;
|
| while (limit > 0) {
|
| @@ -5387,9 +5616,10 @@
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_StringSplit(Arguments args) {
|
| +static MaybeObject* Runtime_StringSplit(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| ASSERT(args.length() == 3);
|
| - HandleScope handle_scope;
|
| + HandleScope handle_scope(isolate);
|
| CONVERT_ARG_CHECKED(String, subject, 0);
|
| CONVERT_ARG_CHECKED(String, pattern, 1);
|
| CONVERT_NUMBER_CHECKED(uint32_t, limit, Uint32, args[2]);
|
| @@ -5419,12 +5649,14 @@
|
| if (subject->IsAsciiRepresentation()) {
|
| Vector<const char> subject_vector = subject->ToAsciiVector();
|
| if (pattern->IsAsciiRepresentation()) {
|
| - FindStringIndices(subject_vector,
|
| + FindStringIndices(isolate,
|
| + subject_vector,
|
| pattern->ToAsciiVector(),
|
| &indices,
|
| limit);
|
| } else {
|
| - FindStringIndices(subject_vector,
|
| + FindStringIndices(isolate,
|
| + subject_vector,
|
| pattern->ToUC16Vector(),
|
| &indices,
|
| limit);
|
| @@ -5432,12 +5664,14 @@
|
| } else {
|
| Vector<const uc16> subject_vector = subject->ToUC16Vector();
|
| if (pattern->IsAsciiRepresentation()) {
|
| - FindStringIndices(subject_vector,
|
| + FindStringIndices(isolate,
|
| + subject_vector,
|
| pattern->ToAsciiVector(),
|
| &indices,
|
| limit);
|
| } else {
|
| - FindStringIndices(subject_vector,
|
| + FindStringIndices(isolate,
|
| + subject_vector,
|
| pattern->ToUC16Vector(),
|
| &indices,
|
| limit);
|
| @@ -5454,7 +5688,7 @@
|
| // Create JSArray of substrings separated by separator.
|
| int part_count = indices.length();
|
|
|
| - Handle<JSArray> result = Factory::NewJSArray(part_count);
|
| + Handle<JSArray> result = isolate->factory()->NewJSArray(part_count);
|
| result->set_length(Smi::FromInt(part_count));
|
|
|
| ASSERT(result->HasFastElements());
|
| @@ -5470,7 +5704,7 @@
|
| HandleScope local_loop_handle;
|
| int part_end = indices.at(i);
|
| Handle<String> substring =
|
| - Factory::NewSubString(subject, part_start, part_end);
|
| + isolate->factory()->NewSubString(subject, part_start, part_end);
|
| elements->set(i, *substring);
|
| part_start = part_end + pattern_length;
|
| }
|
| @@ -5483,17 +5717,18 @@
|
| // one-char strings in the cache. Gives up on the first char that is
|
| // not in the cache and fills the remainder with smi zeros. Returns
|
| // the length of the successfully copied prefix.
|
| -static int CopyCachedAsciiCharsToArray(const char* chars,
|
| +static int CopyCachedAsciiCharsToArray(Heap* heap,
|
| + const char* chars,
|
| FixedArray* elements,
|
| int length) {
|
| AssertNoAllocation nogc;
|
| - FixedArray* ascii_cache = Heap::single_character_string_cache();
|
| - Object* undefined = Heap::undefined_value();
|
| + FixedArray* ascii_cache = heap->single_character_string_cache();
|
| + Object* undefined = heap->undefined_value();
|
| int i;
|
| for (i = 0; i < length; ++i) {
|
| Object* value = ascii_cache->get(chars[i]);
|
| if (value == undefined) break;
|
| - ASSERT(!Heap::InNewSpace(value));
|
| + ASSERT(!heap->InNewSpace(value));
|
| elements->set(i, value, SKIP_WRITE_BARRIER);
|
| }
|
| if (i < length) {
|
| @@ -5513,8 +5748,9 @@
|
|
|
| // Converts a String to JSArray.
|
| // For example, "foo" => ["f", "o", "o"].
|
| -static MaybeObject* Runtime_StringToArray(Arguments args) {
|
| - HandleScope scope;
|
| +static MaybeObject* Runtime_StringToArray(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| + HandleScope scope(isolate);
|
| ASSERT(args.length() == 2);
|
| CONVERT_ARG_CHECKED(String, s, 0);
|
| CONVERT_NUMBER_CHECKED(uint32_t, limit, Uint32, args[1]);
|
| @@ -5525,15 +5761,17 @@
|
| Handle<FixedArray> elements;
|
| if (s->IsFlat() && s->IsAsciiRepresentation()) {
|
| Object* obj;
|
| - { MaybeObject* maybe_obj = Heap::AllocateUninitializedFixedArray(length);
|
| + { MaybeObject* maybe_obj =
|
| + isolate->heap()->AllocateUninitializedFixedArray(length);
|
| if (!maybe_obj->ToObject(&obj)) return maybe_obj;
|
| }
|
| - elements = Handle<FixedArray>(FixedArray::cast(obj));
|
| + elements = Handle<FixedArray>(FixedArray::cast(obj), isolate);
|
|
|
| Vector<const char> chars = s->ToAsciiVector();
|
| // Note, this will initialize all elements (not only the prefix)
|
| // to prevent GC from seeing partially initialized array.
|
| - int num_copied_from_cache = CopyCachedAsciiCharsToArray(chars.start(),
|
| + int num_copied_from_cache = CopyCachedAsciiCharsToArray(isolate->heap(),
|
| + chars.start(),
|
| *elements,
|
| length);
|
|
|
| @@ -5542,7 +5780,7 @@
|
| elements->set(i, *str);
|
| }
|
| } else {
|
| - elements = Factory::NewFixedArray(length);
|
| + elements = isolate->factory()->NewFixedArray(length);
|
| for (int i = 0; i < length; ++i) {
|
| Handle<Object> str = LookupSingleCharacterStringFromCode(s->Get(i));
|
| elements->set(i, *str);
|
| @@ -5555,11 +5793,12 @@
|
| }
|
| #endif
|
|
|
| - return *Factory::NewJSArrayWithElements(elements);
|
| + return *isolate->factory()->NewJSArrayWithElements(elements);
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_NewStringWrapper(Arguments args) {
|
| +static MaybeObject* Runtime_NewStringWrapper(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 1);
|
| CONVERT_CHECKED(String, value, args[0]);
|
| @@ -5567,36 +5806,40 @@
|
| }
|
|
|
|
|
| -bool Runtime::IsUpperCaseChar(uint16_t ch) {
|
| +bool Runtime::IsUpperCaseChar(RuntimeState* runtime_state, uint16_t ch) {
|
| unibrow::uchar chars[unibrow::ToUppercase::kMaxWidth];
|
| - int char_length = to_upper_mapping.get(ch, 0, chars);
|
| + int char_length = runtime_state->to_upper_mapping()->get(ch, 0, chars);
|
| return char_length == 0;
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_NumberToString(Arguments args) {
|
| +static MaybeObject* Runtime_NumberToString(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 1);
|
|
|
| Object* number = args[0];
|
| RUNTIME_ASSERT(number->IsNumber());
|
|
|
| - return Heap::NumberToString(number);
|
| + return isolate->heap()->NumberToString(number);
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_NumberToStringSkipCache(Arguments args) {
|
| +static MaybeObject* Runtime_NumberToStringSkipCache(
|
| + RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 1);
|
|
|
| Object* number = args[0];
|
| RUNTIME_ASSERT(number->IsNumber());
|
|
|
| - return Heap::NumberToString(number, false);
|
| + return isolate->heap()->NumberToString(number, false);
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_NumberToInteger(Arguments args) {
|
| +static MaybeObject* Runtime_NumberToInteger(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 1);
|
|
|
| @@ -5606,11 +5849,13 @@
|
| if (number > 0 && number <= Smi::kMaxValue) {
|
| return Smi::FromInt(static_cast<int>(number));
|
| }
|
| - return Heap::NumberFromDouble(DoubleToInteger(number));
|
| + return isolate->heap()->NumberFromDouble(DoubleToInteger(number));
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_NumberToIntegerMapMinusZero(Arguments args) {
|
| +static MaybeObject* Runtime_NumberToIntegerMapMinusZero(
|
| + RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 1);
|
|
|
| @@ -5625,20 +5870,22 @@
|
| // Map both -0 and +0 to +0.
|
| if (double_value == 0) double_value = 0;
|
|
|
| - return Heap::NumberFromDouble(double_value);
|
| + return isolate->heap()->NumberFromDouble(double_value);
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_NumberToJSUint32(Arguments args) {
|
| +static MaybeObject* Runtime_NumberToJSUint32(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 1);
|
|
|
| CONVERT_NUMBER_CHECKED(int32_t, number, Uint32, args[0]);
|
| - return Heap::NumberFromUint32(number);
|
| + return isolate->heap()->NumberFromUint32(number);
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_NumberToJSInt32(Arguments args) {
|
| +static MaybeObject* Runtime_NumberToJSInt32(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 1);
|
|
|
| @@ -5648,13 +5895,14 @@
|
| if (number > 0 && number <= Smi::kMaxValue) {
|
| return Smi::FromInt(static_cast<int>(number));
|
| }
|
| - return Heap::NumberFromInt32(DoubleToInt32(number));
|
| + return isolate->heap()->NumberFromInt32(DoubleToInt32(number));
|
| }
|
|
|
|
|
| // Converts a Number to a Smi, if possible. Returns NaN if the number is not
|
| // a small integer.
|
| -static MaybeObject* Runtime_NumberToSmi(Arguments args) {
|
| +static MaybeObject* Runtime_NumberToSmi(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 1);
|
|
|
| @@ -5669,75 +5917,83 @@
|
| return Smi::FromInt(int_value);
|
| }
|
| }
|
| - return Heap::nan_value();
|
| + return isolate->heap()->nan_value();
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_AllocateHeapNumber(Arguments args) {
|
| +static MaybeObject* Runtime_AllocateHeapNumber(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 0);
|
| - return Heap::AllocateHeapNumber(0);
|
| + return isolate->heap()->AllocateHeapNumber(0);
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_NumberAdd(Arguments args) {
|
| +static MaybeObject* Runtime_NumberAdd(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 2);
|
|
|
| CONVERT_DOUBLE_CHECKED(x, args[0]);
|
| CONVERT_DOUBLE_CHECKED(y, args[1]);
|
| - return Heap::NumberFromDouble(x + y);
|
| + return isolate->heap()->NumberFromDouble(x + y);
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_NumberSub(Arguments args) {
|
| +static MaybeObject* Runtime_NumberSub(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 2);
|
|
|
| CONVERT_DOUBLE_CHECKED(x, args[0]);
|
| CONVERT_DOUBLE_CHECKED(y, args[1]);
|
| - return Heap::NumberFromDouble(x - y);
|
| + return isolate->heap()->NumberFromDouble(x - y);
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_NumberMul(Arguments args) {
|
| +static MaybeObject* Runtime_NumberMul(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 2);
|
|
|
| CONVERT_DOUBLE_CHECKED(x, args[0]);
|
| CONVERT_DOUBLE_CHECKED(y, args[1]);
|
| - return Heap::NumberFromDouble(x * y);
|
| + return isolate->heap()->NumberFromDouble(x * y);
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_NumberUnaryMinus(Arguments args) {
|
| +static MaybeObject* Runtime_NumberUnaryMinus(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 1);
|
|
|
| CONVERT_DOUBLE_CHECKED(x, args[0]);
|
| - return Heap::NumberFromDouble(-x);
|
| + return isolate->heap()->NumberFromDouble(-x);
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_NumberAlloc(Arguments args) {
|
| +static MaybeObject* Runtime_NumberAlloc(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 0);
|
|
|
| - return Heap::NumberFromDouble(9876543210.0);
|
| + return isolate->heap()->NumberFromDouble(9876543210.0);
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_NumberDiv(Arguments args) {
|
| +static MaybeObject* Runtime_NumberDiv(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 2);
|
|
|
| CONVERT_DOUBLE_CHECKED(x, args[0]);
|
| CONVERT_DOUBLE_CHECKED(y, args[1]);
|
| - return Heap::NumberFromDouble(x / y);
|
| + return isolate->heap()->NumberFromDouble(x / y);
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_NumberMod(Arguments args) {
|
| +static MaybeObject* Runtime_NumberMod(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 2);
|
|
|
| @@ -5746,17 +6002,18 @@
|
|
|
| x = modulo(x, y);
|
| // NumberFromDouble may return a Smi instead of a Number object
|
| - return Heap::NumberFromDouble(x);
|
| + return isolate->heap()->NumberFromDouble(x);
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_StringAdd(Arguments args) {
|
| +static MaybeObject* Runtime_StringAdd(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 2);
|
| CONVERT_CHECKED(String, str1, args[0]);
|
| CONVERT_CHECKED(String, str2, args[1]);
|
| - Counters::string_add_runtime.Increment();
|
| - return Heap::AllocateConsString(str1, str2);
|
| + isolate->counters()->string_add_runtime()->Increment();
|
| + return isolate->heap()->AllocateConsString(str1, str2);
|
| }
|
|
|
|
|
| @@ -5799,12 +6056,13 @@
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_StringBuilderConcat(Arguments args) {
|
| +static MaybeObject* Runtime_StringBuilderConcat(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 3);
|
| CONVERT_CHECKED(JSArray, array, args[0]);
|
| if (!args[1]->IsSmi()) {
|
| - Top::context()->mark_out_of_memory();
|
| + isolate->context()->mark_out_of_memory();
|
| return Failure::OutOfMemoryException();
|
| }
|
| int array_length = Smi::cast(args[1])->value();
|
| @@ -5815,7 +6073,7 @@
|
|
|
| int special_length = special->length();
|
| if (!array->HasFastElements()) {
|
| - return Top::Throw(Heap::illegal_argument_symbol());
|
| + return isolate->Throw(isolate->heap()->illegal_argument_symbol());
|
| }
|
| FixedArray* fixed_array = FixedArray::cast(array->elements());
|
| if (fixed_array->length() < array_length) {
|
| @@ -5823,7 +6081,7 @@
|
| }
|
|
|
| if (array_length == 0) {
|
| - return Heap::empty_string();
|
| + return isolate->heap()->empty_string();
|
| } else if (array_length == 1) {
|
| Object* first = fixed_array->get(0);
|
| if (first->IsString()) return first;
|
| @@ -5849,21 +6107,21 @@
|
| // Get the position and check that it is a positive smi.
|
| i++;
|
| if (i >= array_length) {
|
| - return Top::Throw(Heap::illegal_argument_symbol());
|
| + return isolate->Throw(isolate->heap()->illegal_argument_symbol());
|
| }
|
| Object* next_smi = fixed_array->get(i);
|
| if (!next_smi->IsSmi()) {
|
| - return Top::Throw(Heap::illegal_argument_symbol());
|
| + return isolate->Throw(isolate->heap()->illegal_argument_symbol());
|
| }
|
| pos = Smi::cast(next_smi)->value();
|
| if (pos < 0) {
|
| - return Top::Throw(Heap::illegal_argument_symbol());
|
| + return isolate->Throw(isolate->heap()->illegal_argument_symbol());
|
| }
|
| }
|
| ASSERT(pos >= 0);
|
| ASSERT(len >= 0);
|
| if (pos > special_length || len > special_length - pos) {
|
| - return Top::Throw(Heap::illegal_argument_symbol());
|
| + return isolate->Throw(isolate->heap()->illegal_argument_symbol());
|
| }
|
| increment = len;
|
| } else if (elt->IsString()) {
|
| @@ -5874,10 +6132,10 @@
|
| ascii = false;
|
| }
|
| } else {
|
| - return Top::Throw(Heap::illegal_argument_symbol());
|
| + return isolate->Throw(isolate->heap()->illegal_argument_symbol());
|
| }
|
| if (increment > String::kMaxLength - position) {
|
| - Top::context()->mark_out_of_memory();
|
| + isolate->context()->mark_out_of_memory();
|
| return Failure::OutOfMemoryException();
|
| }
|
| position += increment;
|
| @@ -5887,7 +6145,8 @@
|
| Object* object;
|
|
|
| if (ascii) {
|
| - { MaybeObject* maybe_object = Heap::AllocateRawAsciiString(length);
|
| + { MaybeObject* maybe_object =
|
| + isolate->heap()->AllocateRawAsciiString(length);
|
| if (!maybe_object->ToObject(&object)) return maybe_object;
|
| }
|
| SeqAsciiString* answer = SeqAsciiString::cast(object);
|
| @@ -5897,7 +6156,8 @@
|
| array_length);
|
| return answer;
|
| } else {
|
| - { MaybeObject* maybe_object = Heap::AllocateRawTwoByteString(length);
|
| + { MaybeObject* maybe_object =
|
| + isolate->heap()->AllocateRawTwoByteString(length);
|
| if (!maybe_object->ToObject(&object)) return maybe_object;
|
| }
|
| SeqTwoByteString* answer = SeqTwoByteString::cast(object);
|
| @@ -5910,19 +6170,20 @@
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_StringBuilderJoin(Arguments args) {
|
| +static MaybeObject* Runtime_StringBuilderJoin(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 3);
|
| CONVERT_CHECKED(JSArray, array, args[0]);
|
| if (!args[1]->IsSmi()) {
|
| - Top::context()->mark_out_of_memory();
|
| + isolate->context()->mark_out_of_memory();
|
| return Failure::OutOfMemoryException();
|
| }
|
| int array_length = Smi::cast(args[1])->value();
|
| CONVERT_CHECKED(String, separator, args[2]);
|
|
|
| if (!array->HasFastElements()) {
|
| - return Top::Throw(Heap::illegal_argument_symbol());
|
| + return isolate->Throw(isolate->heap()->illegal_argument_symbol());
|
| }
|
| FixedArray* fixed_array = FixedArray::cast(array->elements());
|
| if (fixed_array->length() < array_length) {
|
| @@ -5930,7 +6191,7 @@
|
| }
|
|
|
| if (array_length == 0) {
|
| - return Heap::empty_string();
|
| + return isolate->heap()->empty_string();
|
| } else if (array_length == 1) {
|
| Object* first = fixed_array->get(0);
|
| if (first->IsString()) return first;
|
| @@ -5940,7 +6201,7 @@
|
| int max_nof_separators =
|
| (String::kMaxLength + separator_length - 1) / separator_length;
|
| if (max_nof_separators < (array_length - 1)) {
|
| - Top::context()->mark_out_of_memory();
|
| + isolate->context()->mark_out_of_memory();
|
| return Failure::OutOfMemoryException();
|
| }
|
| int length = (array_length - 1) * separator_length;
|
| @@ -5948,19 +6209,20 @@
|
| Object* element_obj = fixed_array->get(i);
|
| if (!element_obj->IsString()) {
|
| // TODO(1161): handle this case.
|
| - return Top::Throw(Heap::illegal_argument_symbol());
|
| + return isolate->Throw(isolate->heap()->illegal_argument_symbol());
|
| }
|
| String* element = String::cast(element_obj);
|
| int increment = element->length();
|
| if (increment > String::kMaxLength - length) {
|
| - Top::context()->mark_out_of_memory();
|
| + isolate->context()->mark_out_of_memory();
|
| return Failure::OutOfMemoryException();
|
| }
|
| length += increment;
|
| }
|
|
|
| Object* object;
|
| - { MaybeObject* maybe_object = Heap::AllocateRawTwoByteString(length);
|
| + { MaybeObject* maybe_object =
|
| + isolate->heap()->AllocateRawTwoByteString(length);
|
| if (!maybe_object->ToObject(&object)) return maybe_object;
|
| }
|
| SeqTwoByteString* answer = SeqTwoByteString::cast(object);
|
| @@ -5993,76 +6255,84 @@
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_NumberOr(Arguments args) {
|
| +static MaybeObject* Runtime_NumberOr(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 2);
|
|
|
| CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]);
|
| CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]);
|
| - return Heap::NumberFromInt32(x | y);
|
| + return isolate->heap()->NumberFromInt32(x | y);
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_NumberAnd(Arguments args) {
|
| +static MaybeObject* Runtime_NumberAnd(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 2);
|
|
|
| CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]);
|
| CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]);
|
| - return Heap::NumberFromInt32(x & y);
|
| + return isolate->heap()->NumberFromInt32(x & y);
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_NumberXor(Arguments args) {
|
| +static MaybeObject* Runtime_NumberXor(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 2);
|
|
|
| CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]);
|
| CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]);
|
| - return Heap::NumberFromInt32(x ^ y);
|
| + return isolate->heap()->NumberFromInt32(x ^ y);
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_NumberNot(Arguments args) {
|
| +static MaybeObject* Runtime_NumberNot(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 1);
|
|
|
| CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]);
|
| - return Heap::NumberFromInt32(~x);
|
| + return isolate->heap()->NumberFromInt32(~x);
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_NumberShl(Arguments args) {
|
| +static MaybeObject* Runtime_NumberShl(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 2);
|
|
|
| CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]);
|
| CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]);
|
| - return Heap::NumberFromInt32(x << (y & 0x1f));
|
| + return isolate->heap()->NumberFromInt32(x << (y & 0x1f));
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_NumberShr(Arguments args) {
|
| +static MaybeObject* Runtime_NumberShr(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 2);
|
|
|
| CONVERT_NUMBER_CHECKED(uint32_t, x, Uint32, args[0]);
|
| CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]);
|
| - return Heap::NumberFromUint32(x >> (y & 0x1f));
|
| + return isolate->heap()->NumberFromUint32(x >> (y & 0x1f));
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_NumberSar(Arguments args) {
|
| +static MaybeObject* Runtime_NumberSar(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 2);
|
|
|
| CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]);
|
| CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]);
|
| - return Heap::NumberFromInt32(ArithmeticShiftRight(x, y & 0x1f));
|
| + return isolate->heap()->NumberFromInt32(ArithmeticShiftRight(x, y & 0x1f));
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_NumberEquals(Arguments args) {
|
| +static MaybeObject* Runtime_NumberEquals(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 2);
|
|
|
| @@ -6081,7 +6351,8 @@
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_StringEquals(Arguments args) {
|
| +static MaybeObject* Runtime_StringEquals(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 2);
|
|
|
| @@ -6099,7 +6370,8 @@
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_NumberCompare(Arguments args) {
|
| +static MaybeObject* Runtime_NumberCompare(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 3);
|
|
|
| @@ -6114,15 +6386,12 @@
|
|
|
| // Compare two Smis as if they were converted to strings and then
|
| // compared lexicographically.
|
| -static MaybeObject* Runtime_SmiLexicographicCompare(Arguments args) {
|
| +static MaybeObject* Runtime_SmiLexicographicCompare(
|
| + RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 2);
|
|
|
| - // Arrays for the individual characters of the two Smis. Smis are
|
| - // 31 bit integers and 10 decimal digits are therefore enough.
|
| - static int x_elms[10];
|
| - static int y_elms[10];
|
| -
|
| // Extract the integer values from the Smis.
|
| CONVERT_CHECKED(Smi, x, args[0]);
|
| CONVERT_CHECKED(Smi, y, args[1]);
|
| @@ -6146,6 +6415,13 @@
|
| y_value = -y_value;
|
| }
|
|
|
| + // Arrays for the individual characters of the two Smis. Smis are
|
| + // 31 bit integers and 10 decimal digits are therefore enough.
|
| + // TODO(isolates): maybe we should simply allocate 20 bytes on the stack.
|
| + int* x_elms = isolate->runtime_state()->smi_lexicographic_compare_x_elms();
|
| + int* y_elms = isolate->runtime_state()->smi_lexicographic_compare_y_elms();
|
| +
|
| +
|
| // Convert the integers to arrays of their decimal digits.
|
| int x_index = 0;
|
| int y_index = 0;
|
| @@ -6172,9 +6448,11 @@
|
| }
|
|
|
|
|
| -static Object* StringInputBufferCompare(String* x, String* y) {
|
| - static StringInputBuffer bufx;
|
| - static StringInputBuffer bufy;
|
| +static Object* StringInputBufferCompare(RuntimeState* state,
|
| + String* x,
|
| + String* y) {
|
| + StringInputBuffer& bufx = *state->string_input_buffer_compare_bufx();
|
| + StringInputBuffer& bufy = *state->string_input_buffer_compare_bufy();
|
| bufx.Reset(x);
|
| bufy.Reset(y);
|
| while (bufx.has_more() && bufy.has_more()) {
|
| @@ -6227,19 +6505,21 @@
|
| } else {
|
| result = (r < 0) ? Smi::FromInt(LESS) : Smi::FromInt(GREATER);
|
| }
|
| - ASSERT(result == StringInputBufferCompare(x, y));
|
| + ASSERT(result ==
|
| + StringInputBufferCompare(Isolate::Current()->runtime_state(), x, y));
|
| return result;
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_StringCompare(Arguments args) {
|
| +static MaybeObject* Runtime_StringCompare(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 2);
|
|
|
| CONVERT_CHECKED(String, x, args[0]);
|
| CONVERT_CHECKED(String, y, args[1]);
|
|
|
| - Counters::string_compare_runtime.Increment();
|
| + isolate->counters()->string_compare_runtime()->Increment();
|
|
|
| // A few fast case tests before we flatten.
|
| if (x == y) return Smi::FromInt(EQUAL);
|
| @@ -6255,52 +6535,59 @@
|
| else if (d > 0) return Smi::FromInt(GREATER);
|
|
|
| Object* obj;
|
| - { MaybeObject* maybe_obj = Heap::PrepareForCompare(x);
|
| + { MaybeObject* maybe_obj = isolate->heap()->PrepareForCompare(x);
|
| if (!maybe_obj->ToObject(&obj)) return maybe_obj;
|
| }
|
| - { MaybeObject* maybe_obj = Heap::PrepareForCompare(y);
|
| + { MaybeObject* maybe_obj = isolate->heap()->PrepareForCompare(y);
|
| if (!maybe_obj->ToObject(&obj)) return maybe_obj;
|
| }
|
|
|
| return (x->IsFlat() && y->IsFlat()) ? FlatStringCompare(x, y)
|
| - : StringInputBufferCompare(x, y);
|
| + : StringInputBufferCompare(isolate->runtime_state(), x, y);
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_Math_acos(Arguments args) {
|
| +static MaybeObject* Runtime_Math_acos(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 1);
|
| - Counters::math_acos.Increment();
|
| + isolate->counters()->math_acos()->Increment();
|
|
|
| CONVERT_DOUBLE_CHECKED(x, args[0]);
|
| - return TranscendentalCache::Get(TranscendentalCache::ACOS, x);
|
| + return isolate->transcendental_cache()->Get(TranscendentalCache::ACOS, x);
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_Math_asin(Arguments args) {
|
| +static MaybeObject* Runtime_Math_asin(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 1);
|
| - Counters::math_asin.Increment();
|
| + isolate->counters()->math_asin()->Increment();
|
|
|
| CONVERT_DOUBLE_CHECKED(x, args[0]);
|
| - return TranscendentalCache::Get(TranscendentalCache::ASIN, x);
|
| + return isolate->transcendental_cache()->Get(TranscendentalCache::ASIN, x);
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_Math_atan(Arguments args) {
|
| +static MaybeObject* Runtime_Math_atan(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 1);
|
| - Counters::math_atan.Increment();
|
| + isolate->counters()->math_atan()->Increment();
|
|
|
| CONVERT_DOUBLE_CHECKED(x, args[0]);
|
| - return TranscendentalCache::Get(TranscendentalCache::ATAN, x);
|
| + return isolate->transcendental_cache()->Get(TranscendentalCache::ATAN, x);
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_Math_atan2(Arguments args) {
|
| +static const double kPiDividedBy4 = 0.78539816339744830962;
|
| +
|
| +
|
| +static MaybeObject* Runtime_Math_atan2(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 2);
|
| - Counters::math_atan2.Increment();
|
| + isolate->counters()->math_atan2()->Increment();
|
|
|
| CONVERT_DOUBLE_CHECKED(x, args[0]);
|
| CONVERT_DOUBLE_CHECKED(y, args[1]);
|
| @@ -6310,71 +6597,76 @@
|
| // is a multiple of Pi / 4. The sign of the result is determined
|
| // by the first argument (x) and the sign of the second argument
|
| // determines the multiplier: one or three.
|
| - static double kPiDividedBy4 = 0.78539816339744830962;
|
| int multiplier = (x < 0) ? -1 : 1;
|
| if (y < 0) multiplier *= 3;
|
| result = multiplier * kPiDividedBy4;
|
| } else {
|
| result = atan2(x, y);
|
| }
|
| - return Heap::AllocateHeapNumber(result);
|
| + return isolate->heap()->AllocateHeapNumber(result);
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_Math_ceil(Arguments args) {
|
| +static MaybeObject* Runtime_Math_ceil(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 1);
|
| - Counters::math_ceil.Increment();
|
| + isolate->counters()->math_ceil()->Increment();
|
|
|
| CONVERT_DOUBLE_CHECKED(x, args[0]);
|
| - return Heap::NumberFromDouble(ceiling(x));
|
| + return isolate->heap()->NumberFromDouble(ceiling(x));
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_Math_cos(Arguments args) {
|
| +static MaybeObject* Runtime_Math_cos(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 1);
|
| - Counters::math_cos.Increment();
|
| + isolate->counters()->math_cos()->Increment();
|
|
|
| CONVERT_DOUBLE_CHECKED(x, args[0]);
|
| - return TranscendentalCache::Get(TranscendentalCache::COS, x);
|
| + return isolate->transcendental_cache()->Get(TranscendentalCache::COS, x);
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_Math_exp(Arguments args) {
|
| +static MaybeObject* Runtime_Math_exp(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 1);
|
| - Counters::math_exp.Increment();
|
| + isolate->counters()->math_exp()->Increment();
|
|
|
| CONVERT_DOUBLE_CHECKED(x, args[0]);
|
| - return TranscendentalCache::Get(TranscendentalCache::EXP, x);
|
| + return isolate->transcendental_cache()->Get(TranscendentalCache::EXP, x);
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_Math_floor(Arguments args) {
|
| +static MaybeObject* Runtime_Math_floor(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 1);
|
| - Counters::math_floor.Increment();
|
| + isolate->counters()->math_floor()->Increment();
|
|
|
| CONVERT_DOUBLE_CHECKED(x, args[0]);
|
| - return Heap::NumberFromDouble(floor(x));
|
| + return isolate->heap()->NumberFromDouble(floor(x));
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_Math_log(Arguments args) {
|
| +static MaybeObject* Runtime_Math_log(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 1);
|
| - Counters::math_log.Increment();
|
| + isolate->counters()->math_log()->Increment();
|
|
|
| CONVERT_DOUBLE_CHECKED(x, args[0]);
|
| - return TranscendentalCache::Get(TranscendentalCache::LOG, x);
|
| + return isolate->transcendental_cache()->Get(TranscendentalCache::LOG, x);
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_Math_pow(Arguments args) {
|
| +static MaybeObject* Runtime_Math_pow(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 2);
|
| - Counters::math_pow.Increment();
|
| + isolate->counters()->math_pow()->Increment();
|
|
|
| CONVERT_DOUBLE_CHECKED(x, args[0]);
|
|
|
| @@ -6382,16 +6674,17 @@
|
| // custom powi() function than the generic pow().
|
| if (args[1]->IsSmi()) {
|
| int y = Smi::cast(args[1])->value();
|
| - return Heap::NumberFromDouble(power_double_int(x, y));
|
| + return isolate->heap()->NumberFromDouble(power_double_int(x, y));
|
| }
|
|
|
| CONVERT_DOUBLE_CHECKED(y, args[1]);
|
| - return Heap::AllocateHeapNumber(power_double_double(x, y));
|
| + return isolate->heap()->AllocateHeapNumber(power_double_double(x, y));
|
| }
|
|
|
| // Fast version of Math.pow if we know that y is not an integer and
|
| // y is not -0.5 or 0.5. Used as slowcase from codegen.
|
| -static MaybeObject* Runtime_Math_pow_cfunction(Arguments args) {
|
| +static MaybeObject* Runtime_Math_pow_cfunction(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 2);
|
| CONVERT_DOUBLE_CHECKED(x, args[0]);
|
| @@ -6399,17 +6692,18 @@
|
| if (y == 0) {
|
| return Smi::FromInt(1);
|
| } else if (isnan(y) || ((x == 1 || x == -1) && isinf(y))) {
|
| - return Heap::nan_value();
|
| + return isolate->heap()->nan_value();
|
| } else {
|
| - return Heap::AllocateHeapNumber(pow(x, y));
|
| + return isolate->heap()->AllocateHeapNumber(pow(x, y));
|
| }
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_RoundNumber(Arguments args) {
|
| +static MaybeObject* Runtime_RoundNumber(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 1);
|
| - Counters::math_round.Increment();
|
| + isolate->counters()->math_round()->Increment();
|
|
|
| if (!args[0]->IsHeapNumber()) {
|
| // Must be smi. Return the argument unchanged for all the other types
|
| @@ -6435,40 +6729,43 @@
|
| return number;
|
| }
|
|
|
| - if (sign && value >= -0.5) return Heap::minus_zero_value();
|
| + if (sign && value >= -0.5) return isolate->heap()->minus_zero_value();
|
|
|
| // Do not call NumberFromDouble() to avoid extra checks.
|
| - return Heap::AllocateHeapNumber(floor(value + 0.5));
|
| + return isolate->heap()->AllocateHeapNumber(floor(value + 0.5));
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_Math_sin(Arguments args) {
|
| +static MaybeObject* Runtime_Math_sin(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 1);
|
| - Counters::math_sin.Increment();
|
| + isolate->counters()->math_sin()->Increment();
|
|
|
| CONVERT_DOUBLE_CHECKED(x, args[0]);
|
| - return TranscendentalCache::Get(TranscendentalCache::SIN, x);
|
| + return isolate->transcendental_cache()->Get(TranscendentalCache::SIN, x);
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_Math_sqrt(Arguments args) {
|
| +static MaybeObject* Runtime_Math_sqrt(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 1);
|
| - Counters::math_sqrt.Increment();
|
| + isolate->counters()->math_sqrt()->Increment();
|
|
|
| CONVERT_DOUBLE_CHECKED(x, args[0]);
|
| - return Heap::AllocateHeapNumber(sqrt(x));
|
| + return isolate->heap()->AllocateHeapNumber(sqrt(x));
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_Math_tan(Arguments args) {
|
| +static MaybeObject* Runtime_Math_tan(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 1);
|
| - Counters::math_tan.Increment();
|
| + isolate->counters()->math_tan()->Increment();
|
|
|
| CONVERT_DOUBLE_CHECKED(x, args[0]);
|
| - return TranscendentalCache::Get(TranscendentalCache::TAN, x);
|
| + return isolate->transcendental_cache()->Get(TranscendentalCache::TAN, x);
|
| }
|
|
|
|
|
| @@ -6517,7 +6814,8 @@
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_DateMakeDay(Arguments args) {
|
| +static MaybeObject* Runtime_DateMakeDay(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 3);
|
|
|
| @@ -6816,7 +7114,8 @@
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_DateYMDFromTime(Arguments args) {
|
| +static MaybeObject* Runtime_DateYMDFromTime(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 2);
|
|
|
| @@ -6826,7 +7125,8 @@
|
| int year, month, day;
|
| DateYMDFromTime(static_cast<int>(floor(t / 86400000)), year, month, day);
|
|
|
| - RUNTIME_ASSERT(res_array->elements()->map() == Heap::fixed_array_map());
|
| + RUNTIME_ASSERT(res_array->elements()->map() ==
|
| + isolate->heap()->fixed_array_map());
|
| FixedArray* elms = FixedArray::cast(res_array->elements());
|
| RUNTIME_ASSERT(elms->length() == 3);
|
|
|
| @@ -6834,11 +7134,12 @@
|
| elms->set(1, Smi::FromInt(month));
|
| elms->set(2, Smi::FromInt(day));
|
|
|
| - return Heap::undefined_value();
|
| + return isolate->heap()->undefined_value();
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_NewArgumentsFast(Arguments args) {
|
| +static MaybeObject* Runtime_NewArgumentsFast(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 3);
|
|
|
| @@ -6847,20 +7148,21 @@
|
| const int length = Smi::cast(args[2])->value();
|
|
|
| Object* result;
|
| - { MaybeObject* maybe_result = Heap::AllocateArgumentsObject(callee, length);
|
| + { MaybeObject* maybe_result =
|
| + isolate->heap()->AllocateArgumentsObject(callee, length);
|
| if (!maybe_result->ToObject(&result)) return maybe_result;
|
| }
|
| // Allocate the elements if needed.
|
| if (length > 0) {
|
| // Allocate the fixed array.
|
| Object* obj;
|
| - { MaybeObject* maybe_obj = Heap::AllocateRawFixedArray(length);
|
| + { MaybeObject* maybe_obj = isolate->heap()->AllocateRawFixedArray(length);
|
| if (!maybe_obj->ToObject(&obj)) return maybe_obj;
|
| }
|
|
|
| AssertNoAllocation no_gc;
|
| FixedArray* array = reinterpret_cast<FixedArray*>(obj);
|
| - array->set_map(Heap::fixed_array_map());
|
| + array->set_map(isolate->heap()->fixed_array_map());
|
| array->set_length(length);
|
|
|
| WriteBarrierMode mode = array->GetWriteBarrierMode(no_gc);
|
| @@ -6873,8 +7175,9 @@
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_NewClosure(Arguments args) {
|
| - HandleScope scope;
|
| +static MaybeObject* Runtime_NewClosure(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| + HandleScope scope(isolate);
|
| ASSERT(args.length() == 3);
|
| CONVERT_ARG_CHECKED(Context, context, 0);
|
| CONVERT_ARG_CHECKED(SharedFunctionInfo, shared, 1);
|
| @@ -6886,15 +7189,15 @@
|
| pretenure = pretenure || (context->global_context() == *context);
|
| PretenureFlag pretenure_flag = pretenure ? TENURED : NOT_TENURED;
|
| Handle<JSFunction> result =
|
| - Factory::NewFunctionFromSharedFunctionInfo(shared,
|
| - context,
|
| - pretenure_flag);
|
| + isolate->factory()->NewFunctionFromSharedFunctionInfo(shared,
|
| + context,
|
| + pretenure_flag);
|
| return *result;
|
| }
|
|
|
| -
|
| -static MaybeObject* Runtime_NewObjectFromBound(Arguments args) {
|
| - HandleScope scope;
|
| +static MaybeObject* Runtime_NewObjectFromBound(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| + HandleScope scope(isolate);
|
| ASSERT(args.length() == 2);
|
| // First argument is a function to use as a constructor.
|
| CONVERT_ARG_CHECKED(JSFunction, function, 0);
|
| @@ -6941,10 +7244,11 @@
|
| }
|
|
|
|
|
| -static void TrySettingInlineConstructStub(Handle<JSFunction> function) {
|
| - Handle<Object> prototype = Factory::null_value();
|
| +static void TrySettingInlineConstructStub(Isolate* isolate,
|
| + Handle<JSFunction> function) {
|
| + Handle<Object> prototype = isolate->factory()->null_value();
|
| if (function->has_instance_prototype()) {
|
| - prototype = Handle<Object>(function->instance_prototype());
|
| + prototype = Handle<Object>(function->instance_prototype(), isolate);
|
| }
|
| if (function->shared()->CanGenerateInlineConstructor(*prototype)) {
|
| ConstructStubCompiler compiler;
|
| @@ -6957,8 +7261,9 @@
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_NewObject(Arguments args) {
|
| - HandleScope scope;
|
| +static MaybeObject* Runtime_NewObject(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| + HandleScope scope(isolate);
|
| ASSERT(args.length() == 1);
|
|
|
| Handle<Object> constructor = args.at<Object>(0);
|
| @@ -6967,8 +7272,8 @@
|
| if (!constructor->IsJSFunction()) {
|
| Vector< Handle<Object> > arguments = HandleVector(&constructor, 1);
|
| Handle<Object> type_error =
|
| - Factory::NewTypeError("not_constructor", arguments);
|
| - return Top::Throw(*type_error);
|
| + isolate->factory()->NewTypeError("not_constructor", arguments);
|
| + return isolate->Throw(*type_error);
|
| }
|
|
|
| Handle<JSFunction> function = Handle<JSFunction>::cast(constructor);
|
| @@ -6978,14 +7283,15 @@
|
| if (!function->should_have_prototype()) {
|
| Vector< Handle<Object> > arguments = HandleVector(&constructor, 1);
|
| Handle<Object> type_error =
|
| - Factory::NewTypeError("not_constructor", arguments);
|
| - return Top::Throw(*type_error);
|
| + isolate->factory()->NewTypeError("not_constructor", arguments);
|
| + return isolate->Throw(*type_error);
|
| }
|
|
|
| #ifdef ENABLE_DEBUGGER_SUPPORT
|
| + Debug* debug = isolate->debug();
|
| // Handle stepping into constructors if step into is active.
|
| - if (Debug::StepInActive()) {
|
| - Debug::HandleStepIn(function, Handle<Object>::null(), 0, true);
|
| + if (debug->StepInActive()) {
|
| + debug->HandleStepIn(function, Handle<Object>::null(), 0, true);
|
| }
|
| #endif
|
|
|
| @@ -6995,14 +7301,14 @@
|
| // called using 'new' and creates a new JSFunction object that
|
| // is returned. The receiver object is only used for error
|
| // reporting if an error occurs when constructing the new
|
| - // JSFunction. Factory::NewJSObject() should not be used to
|
| + // JSFunction. FACTORY->NewJSObject() should not be used to
|
| // allocate JSFunctions since it does not properly initialize
|
| // the shared part of the function. Since the receiver is
|
| // ignored anyway, we use the global object as the receiver
|
| // instead of a new JSFunction object. This way, errors are
|
| // reported the same way whether or not 'Function' is called
|
| // using 'new'.
|
| - return Top::context()->global();
|
| + return isolate->context()->global();
|
| }
|
| }
|
|
|
| @@ -7010,7 +7316,7 @@
|
| // available. We cannot use EnsureCompiled because that forces a
|
| // compilation through the shared function info which makes it
|
| // impossible for us to optimize.
|
| - Handle<SharedFunctionInfo> shared(function->shared());
|
| + Handle<SharedFunctionInfo> shared(function->shared(), isolate);
|
| if (!function->is_compiled()) CompileLazy(function, CLEAR_EXCEPTION);
|
|
|
| if (!function->has_initial_map() &&
|
| @@ -7022,34 +7328,36 @@
|
| }
|
|
|
| bool first_allocation = !shared->live_objects_may_exist();
|
| - Handle<JSObject> result = Factory::NewJSObject(function);
|
| - RETURN_IF_EMPTY_HANDLE(result);
|
| + Handle<JSObject> result = isolate->factory()->NewJSObject(function);
|
| + RETURN_IF_EMPTY_HANDLE(isolate, result);
|
| // Delay setting the stub if inobject slack tracking is in progress.
|
| if (first_allocation && !shared->IsInobjectSlackTrackingInProgress()) {
|
| - TrySettingInlineConstructStub(function);
|
| + TrySettingInlineConstructStub(isolate, function);
|
| }
|
|
|
| - Counters::constructed_objects.Increment();
|
| - Counters::constructed_objects_runtime.Increment();
|
| + isolate->counters()->constructed_objects()->Increment();
|
| + isolate->counters()->constructed_objects_runtime()->Increment();
|
|
|
| return *result;
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_FinalizeInstanceSize(Arguments args) {
|
| - HandleScope scope;
|
| +static MaybeObject* Runtime_FinalizeInstanceSize(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| + HandleScope scope(isolate);
|
| ASSERT(args.length() == 1);
|
|
|
| CONVERT_ARG_CHECKED(JSFunction, function, 0);
|
| function->shared()->CompleteInobjectSlackTracking();
|
| - TrySettingInlineConstructStub(function);
|
| + TrySettingInlineConstructStub(isolate, function);
|
|
|
| - return Heap::undefined_value();
|
| + return isolate->heap()->undefined_value();
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_LazyCompile(Arguments args) {
|
| - HandleScope scope;
|
| +static MaybeObject* Runtime_LazyCompile(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| + HandleScope scope(isolate);
|
| ASSERT(args.length() == 1);
|
|
|
| Handle<JSFunction> function = args.at<JSFunction>(0);
|
| @@ -7079,20 +7387,21 @@
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_LazyRecompile(Arguments args) {
|
| - HandleScope scope;
|
| +static MaybeObject* Runtime_LazyRecompile(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| + HandleScope scope(isolate);
|
| ASSERT(args.length() == 1);
|
| Handle<JSFunction> function = args.at<JSFunction>(0);
|
| // If the function is not optimizable or debugger is active continue using the
|
| // code from the full compiler.
|
| if (!function->shared()->code()->optimizable() ||
|
| - Debug::has_break_points()) {
|
| + isolate->debug()->has_break_points()) {
|
| if (FLAG_trace_opt) {
|
| PrintF("[failed to optimize ");
|
| function->PrintName();
|
| PrintF(": is code optimizable: %s, is debugger enabled: %s]\n",
|
| function->shared()->code()->optimizable() ? "T" : "F",
|
| - Debug::has_break_points() ? "T" : "F");
|
| + isolate->debug()->has_break_points() ? "T" : "F");
|
| }
|
| function->ReplaceCode(function->shared()->code());
|
| return function->code();
|
| @@ -7110,14 +7419,15 @@
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_NotifyDeoptimized(Arguments args) {
|
| - HandleScope scope;
|
| +static MaybeObject* Runtime_NotifyDeoptimized(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| + HandleScope scope(isolate);
|
| ASSERT(args.length() == 1);
|
| RUNTIME_ASSERT(args[0]->IsSmi());
|
| Deoptimizer::BailoutType type =
|
| static_cast<Deoptimizer::BailoutType>(Smi::cast(args[0])->value());
|
| - Deoptimizer* deoptimizer = Deoptimizer::Grab();
|
| - ASSERT(Heap::IsAllocationAllowed());
|
| + Deoptimizer* deoptimizer = Deoptimizer::Grab(isolate);
|
| + ASSERT(isolate->heap()->IsAllocationAllowed());
|
| int frames = deoptimizer->output_count();
|
|
|
| JavaScriptFrameIterator it;
|
| @@ -7130,24 +7440,24 @@
|
| delete deoptimizer;
|
|
|
| RUNTIME_ASSERT(frame->function()->IsJSFunction());
|
| - Handle<JSFunction> function(JSFunction::cast(frame->function()));
|
| + Handle<JSFunction> function(JSFunction::cast(frame->function()), isolate);
|
| Handle<Object> arguments;
|
| for (int i = frame->ComputeExpressionsCount() - 1; i >= 0; --i) {
|
| - if (frame->GetExpression(i) == Heap::arguments_marker()) {
|
| + if (frame->GetExpression(i) == isolate->heap()->arguments_marker()) {
|
| if (arguments.is_null()) {
|
| // FunctionGetArguments can't throw an exception, so cast away the
|
| // doubt with an assert.
|
| arguments = Handle<Object>(
|
| Accessors::FunctionGetArguments(*function,
|
| NULL)->ToObjectUnchecked());
|
| - ASSERT(*arguments != Heap::null_value());
|
| - ASSERT(*arguments != Heap::undefined_value());
|
| + ASSERT(*arguments != isolate->heap()->null_value());
|
| + ASSERT(*arguments != isolate->heap()->undefined_value());
|
| }
|
| frame->SetExpression(i, *arguments);
|
| }
|
| }
|
|
|
| - CompilationCache::MarkForLazyOptimizing(function);
|
| + isolate->compilation_cache()->MarkForLazyOptimizing(function);
|
| if (type == Deoptimizer::EAGER) {
|
| RUNTIME_ASSERT(function->IsOptimized());
|
| } else {
|
| @@ -7157,7 +7467,7 @@
|
| // Avoid doing too much work when running with --always-opt and keep
|
| // the optimized code around.
|
| if (FLAG_always_opt || type == Deoptimizer::LAZY) {
|
| - return Heap::undefined_value();
|
| + return isolate->heap()->undefined_value();
|
| }
|
|
|
| // Count the number of optimized activations of the function.
|
| @@ -7180,31 +7490,35 @@
|
| }
|
| function->ReplaceCode(function->shared()->code());
|
| }
|
| - return Heap::undefined_value();
|
| + return isolate->heap()->undefined_value();
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_NotifyOSR(Arguments args) {
|
| - Deoptimizer* deoptimizer = Deoptimizer::Grab();
|
| +static MaybeObject* Runtime_NotifyOSR(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| + Deoptimizer* deoptimizer = Deoptimizer::Grab(isolate);
|
| delete deoptimizer;
|
| - return Heap::undefined_value();
|
| + return isolate->heap()->undefined_value();
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_DeoptimizeFunction(Arguments args) {
|
| - HandleScope scope;
|
| +static MaybeObject* Runtime_DeoptimizeFunction(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| + HandleScope scope(isolate);
|
| ASSERT(args.length() == 1);
|
| CONVERT_ARG_CHECKED(JSFunction, function, 0);
|
| - if (!function->IsOptimized()) return Heap::undefined_value();
|
| + if (!function->IsOptimized()) return isolate->heap()->undefined_value();
|
|
|
| Deoptimizer::DeoptimizeFunction(*function);
|
|
|
| - return Heap::undefined_value();
|
| + return isolate->heap()->undefined_value();
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_CompileForOnStackReplacement(Arguments args) {
|
| - HandleScope scope;
|
| +static MaybeObject* Runtime_CompileForOnStackReplacement(
|
| + RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| + HandleScope scope(isolate);
|
| ASSERT(args.length() == 1);
|
| CONVERT_ARG_CHECKED(JSFunction, function, 0);
|
|
|
| @@ -7213,7 +7527,7 @@
|
|
|
| // We have hit a back edge in an unoptimized frame for a function that was
|
| // selected for on-stack replacement. Find the unoptimized code object.
|
| - Handle<Code> unoptimized(function->shared()->code());
|
| + Handle<Code> unoptimized(function->shared()->code(), isolate);
|
| // Keep track of whether we've succeeded in optimizing.
|
| bool succeeded = unoptimized->optimizable();
|
| if (succeeded) {
|
| @@ -7237,7 +7551,7 @@
|
| JavaScriptFrameIterator it;
|
| JavaScriptFrame* frame = it.frame();
|
| ASSERT(frame->function() == *function);
|
| - ASSERT(frame->code() == *unoptimized);
|
| + ASSERT(frame->LookupCode(isolate) == *unoptimized);
|
| ASSERT(unoptimized->contains(frame->pc()));
|
|
|
| // Use linear search of the unoptimized code's stack check table to find
|
| @@ -7295,7 +7609,7 @@
|
| StackCheckStub check_stub;
|
| Handle<Code> check_code = check_stub.GetCode();
|
| Handle<Code> replacement_code(
|
| - Builtins::builtin(Builtins::OnStackReplacement));
|
| + isolate->builtins()->builtin(Builtins::OnStackReplacement));
|
| Deoptimizer::RevertStackCheckCode(*unoptimized,
|
| *check_code,
|
| *replacement_code);
|
| @@ -7318,40 +7632,45 @@
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_GetFunctionDelegate(Arguments args) {
|
| - HandleScope scope;
|
| +static MaybeObject* Runtime_GetFunctionDelegate(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| + HandleScope scope(isolate);
|
| ASSERT(args.length() == 1);
|
| RUNTIME_ASSERT(!args[0]->IsJSFunction());
|
| return *Execution::GetFunctionDelegate(args.at<Object>(0));
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_GetConstructorDelegate(Arguments args) {
|
| - HandleScope scope;
|
| +static MaybeObject* Runtime_GetConstructorDelegate(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| + HandleScope scope(isolate);
|
| ASSERT(args.length() == 1);
|
| RUNTIME_ASSERT(!args[0]->IsJSFunction());
|
| return *Execution::GetConstructorDelegate(args.at<Object>(0));
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_NewContext(Arguments args) {
|
| +static MaybeObject* Runtime_NewContext(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 1);
|
|
|
| CONVERT_CHECKED(JSFunction, function, args[0]);
|
| int length = function->shared()->scope_info()->NumberOfContextSlots();
|
| Object* result;
|
| - { MaybeObject* maybe_result = Heap::AllocateFunctionContext(length, function);
|
| + { MaybeObject* maybe_result =
|
| + isolate->heap()->AllocateFunctionContext(length, function);
|
| if (!maybe_result->ToObject(&result)) return maybe_result;
|
| }
|
|
|
| - Top::set_context(Context::cast(result));
|
| + isolate->set_context(Context::cast(result));
|
|
|
| return result; // non-failure
|
| }
|
|
|
|
|
| -MUST_USE_RESULT static MaybeObject* PushContextHelper(Object* object,
|
| +MUST_USE_RESULT static MaybeObject* PushContextHelper(Isolate* isolate,
|
| + Object* object,
|
| bool is_catch_context) {
|
| // Convert the object to a proper JavaScript object.
|
| Object* js_object = object;
|
| @@ -7361,45 +7680,47 @@
|
| if (!Failure::cast(maybe_js_object)->IsInternalError()) {
|
| return maybe_js_object;
|
| }
|
| - HandleScope scope;
|
| - Handle<Object> handle(object);
|
| + HandleScope scope(isolate);
|
| + Handle<Object> handle(object, isolate);
|
| Handle<Object> result =
|
| - Factory::NewTypeError("with_expression", HandleVector(&handle, 1));
|
| - return Top::Throw(*result);
|
| + isolate->factory()->NewTypeError("with_expression",
|
| + HandleVector(&handle, 1));
|
| + return isolate->Throw(*result);
|
| }
|
| }
|
|
|
| Object* result;
|
| - { MaybeObject* maybe_result =
|
| - Heap::AllocateWithContext(Top::context(),
|
| - JSObject::cast(js_object),
|
| - is_catch_context);
|
| + { MaybeObject* maybe_result = isolate->heap()->AllocateWithContext(
|
| + isolate->context(), JSObject::cast(js_object), is_catch_context);
|
| if (!maybe_result->ToObject(&result)) return maybe_result;
|
| }
|
|
|
| Context* context = Context::cast(result);
|
| - Top::set_context(context);
|
| + isolate->set_context(context);
|
|
|
| return result;
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_PushContext(Arguments args) {
|
| +static MaybeObject* Runtime_PushContext(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 1);
|
| - return PushContextHelper(args[0], false);
|
| + return PushContextHelper(isolate, args[0], false);
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_PushCatchContext(Arguments args) {
|
| +static MaybeObject* Runtime_PushCatchContext(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 1);
|
| - return PushContextHelper(args[0], true);
|
| + return PushContextHelper(isolate, args[0], true);
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_DeleteContextSlot(Arguments args) {
|
| - HandleScope scope;
|
| +static MaybeObject* Runtime_DeleteContextSlot(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| + HandleScope scope(isolate);
|
| ASSERT(args.length() == 2);
|
|
|
| CONVERT_ARG_CHECKED(Context, context, 0);
|
| @@ -7412,12 +7733,12 @@
|
|
|
| // If the slot was not found the result is true.
|
| if (holder.is_null()) {
|
| - return Heap::true_value();
|
| + return isolate->heap()->true_value();
|
| }
|
|
|
| // If the slot was found in a context, it should be DONT_DELETE.
|
| if (holder->IsContext()) {
|
| - return Heap::false_value();
|
| + return isolate->heap()->false_value();
|
| }
|
|
|
| // The slot was found in a JSObject, either a context extension object,
|
| @@ -7465,17 +7786,19 @@
|
| #endif
|
|
|
|
|
| -static inline MaybeObject* Unhole(MaybeObject* x,
|
| +static inline MaybeObject* Unhole(Heap* heap,
|
| + MaybeObject* x,
|
| PropertyAttributes attributes) {
|
| ASSERT(!x->IsTheHole() || (attributes & READ_ONLY) != 0);
|
| USE(attributes);
|
| - return x->IsTheHole() ? Heap::undefined_value() : x;
|
| + return x->IsTheHole() ? heap->undefined_value() : x;
|
| }
|
|
|
|
|
| -static JSObject* ComputeReceiverForNonGlobal(JSObject* holder) {
|
| +static JSObject* ComputeReceiverForNonGlobal(Isolate* isolate,
|
| + JSObject* holder) {
|
| ASSERT(!holder->IsGlobalObject());
|
| - Context* top = Top::context();
|
| + Context* top = isolate->context();
|
| // Get the context extension function.
|
| JSFunction* context_extension_function =
|
| top->global_context()->context_extension_function();
|
| @@ -7492,12 +7815,14 @@
|
| }
|
|
|
|
|
| -static ObjectPair LoadContextSlotHelper(Arguments args, bool throw_error) {
|
| - HandleScope scope;
|
| +static ObjectPair LoadContextSlotHelper(Arguments args,
|
| + Isolate* isolate,
|
| + bool throw_error) {
|
| + HandleScope scope(isolate);
|
| ASSERT_EQ(2, args.length());
|
|
|
| if (!args[0]->IsContext() || !args[1]->IsString()) {
|
| - return MakePair(Top::ThrowIllegalOperation(), NULL);
|
| + return MakePair(isolate->ThrowIllegalOperation(), NULL);
|
| }
|
| Handle<Context> context = args.at<Context>(0);
|
| Handle<String> name = args.at<String>(1);
|
| @@ -7514,11 +7839,12 @@
|
| // If the "property" we were looking for is a local variable or an
|
| // argument in a context, the receiver is the global object; see
|
| // ECMA-262, 3rd., 10.1.6 and 10.2.3.
|
| - JSObject* receiver = Top::context()->global()->global_receiver();
|
| + JSObject* receiver =
|
| + isolate->context()->global()->global_receiver();
|
| MaybeObject* value = (holder->IsContext())
|
| ? Context::cast(*holder)->get(index)
|
| : JSObject::cast(*holder)->GetElement(index);
|
| - return MakePair(Unhole(value, attributes), receiver);
|
| + return MakePair(Unhole(isolate->heap(), value, attributes), receiver);
|
| }
|
|
|
| // If the holder is found, we read the property from it.
|
| @@ -7529,9 +7855,9 @@
|
| if (object->IsGlobalObject()) {
|
| receiver = GlobalObject::cast(object)->global_receiver();
|
| } else if (context->is_exception_holder(*holder)) {
|
| - receiver = Top::context()->global()->global_receiver();
|
| + receiver = isolate->context()->global()->global_receiver();
|
| } else {
|
| - receiver = ComputeReceiverForNonGlobal(object);
|
| + receiver = ComputeReceiverForNonGlobal(isolate, object);
|
| }
|
| // No need to unhole the value here. This is taken care of by the
|
| // GetProperty function.
|
| @@ -7542,30 +7868,36 @@
|
| if (throw_error) {
|
| // The property doesn't exist - throw exception.
|
| Handle<Object> reference_error =
|
| - Factory::NewReferenceError("not_defined", HandleVector(&name, 1));
|
| - return MakePair(Top::Throw(*reference_error), NULL);
|
| + isolate->factory()->NewReferenceError("not_defined",
|
| + HandleVector(&name, 1));
|
| + return MakePair(isolate->Throw(*reference_error), NULL);
|
| } else {
|
| // The property doesn't exist - return undefined
|
| - return MakePair(Heap::undefined_value(), Heap::undefined_value());
|
| + return MakePair(isolate->heap()->undefined_value(),
|
| + isolate->heap()->undefined_value());
|
| }
|
| }
|
|
|
|
|
| -static ObjectPair Runtime_LoadContextSlot(Arguments args) {
|
| - return LoadContextSlotHelper(args, true);
|
| +static ObjectPair Runtime_LoadContextSlot(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| + return LoadContextSlotHelper(args, isolate, true);
|
| }
|
|
|
|
|
| -static ObjectPair Runtime_LoadContextSlotNoReferenceError(Arguments args) {
|
| - return LoadContextSlotHelper(args, false);
|
| +static ObjectPair Runtime_LoadContextSlotNoReferenceError(
|
| + RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| + return LoadContextSlotHelper(args, isolate, false);
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_StoreContextSlot(Arguments args) {
|
| - HandleScope scope;
|
| +static MaybeObject* Runtime_StoreContextSlot(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| + HandleScope scope(isolate);
|
| ASSERT(args.length() == 4);
|
|
|
| - Handle<Object> value(args[0]);
|
| + Handle<Object> value(args[0], isolate);
|
| CONVERT_ARG_CHECKED(Context, context, 1);
|
| CONVERT_ARG_CHECKED(String, name, 2);
|
| CONVERT_SMI_CHECKED(strict_unchecked, args[3]);
|
| @@ -7587,16 +7919,16 @@
|
| } else if (strict_mode == kStrictMode) {
|
| // Setting read only property in strict mode.
|
| Handle<Object> error =
|
| - Factory::NewTypeError("strict_cannot_assign",
|
| - HandleVector(&name, 1));
|
| - return Top::Throw(*error);
|
| + isolate->factory()->NewTypeError("strict_cannot_assign",
|
| + HandleVector(&name, 1));
|
| + return isolate->Throw(*error);
|
| }
|
| } else {
|
| ASSERT((attributes & READ_ONLY) == 0);
|
| Handle<Object> result =
|
| SetElement(Handle<JSObject>::cast(holder), index, value, strict_mode);
|
| if (result.is_null()) {
|
| - ASSERT(Top::has_pending_exception());
|
| + ASSERT(isolate->has_pending_exception());
|
| return Failure::Exception();
|
| }
|
| }
|
| @@ -7614,7 +7946,7 @@
|
| // The property was not found. It needs to be stored in the global context.
|
| ASSERT(attributes == ABSENT);
|
| attributes = NONE;
|
| - context_ext = Handle<JSObject>(Top::context()->global());
|
| + context_ext = Handle<JSObject>(isolate->context()->global());
|
| }
|
|
|
| // Set the property, but ignore if read_only variable on the context
|
| @@ -7622,62 +7954,66 @@
|
| if ((attributes & READ_ONLY) == 0 ||
|
| (context_ext->GetLocalPropertyAttribute(*name) == ABSENT)) {
|
| RETURN_IF_EMPTY_HANDLE(
|
| + isolate,
|
| SetProperty(context_ext, name, value, NONE, strict_mode));
|
| } else if (strict_mode == kStrictMode && (attributes & READ_ONLY) != 0) {
|
| // Setting read only property in strict mode.
|
| Handle<Object> error =
|
| - Factory::NewTypeError("strict_cannot_assign", HandleVector(&name, 1));
|
| - return Top::Throw(*error);
|
| + isolate->factory()->NewTypeError(
|
| + "strict_cannot_assign", HandleVector(&name, 1));
|
| + return isolate->Throw(*error);
|
| }
|
| return *value;
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_Throw(Arguments args) {
|
| - HandleScope scope;
|
| +static MaybeObject* Runtime_Throw(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| + HandleScope scope(isolate);
|
| ASSERT(args.length() == 1);
|
|
|
| - return Top::Throw(args[0]);
|
| + return isolate->Throw(args[0]);
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_ReThrow(Arguments args) {
|
| - HandleScope scope;
|
| +static MaybeObject* Runtime_ReThrow(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| + HandleScope scope(isolate);
|
| ASSERT(args.length() == 1);
|
|
|
| - return Top::ReThrow(args[0]);
|
| + return isolate->ReThrow(args[0]);
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_PromoteScheduledException(Arguments args) {
|
| +static MaybeObject* Runtime_PromoteScheduledException(
|
| + RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| ASSERT_EQ(0, args.length());
|
| - return Top::PromoteScheduledException();
|
| + return isolate->PromoteScheduledException();
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_ThrowReferenceError(Arguments args) {
|
| - HandleScope scope;
|
| +static MaybeObject* Runtime_ThrowReferenceError(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| + HandleScope scope(isolate);
|
| ASSERT(args.length() == 1);
|
|
|
| - Handle<Object> name(args[0]);
|
| + Handle<Object> name(args[0], isolate);
|
| Handle<Object> reference_error =
|
| - Factory::NewReferenceError("not_defined", HandleVector(&name, 1));
|
| - return Top::Throw(*reference_error);
|
| + isolate->factory()->NewReferenceError("not_defined",
|
| + HandleVector(&name, 1));
|
| + return isolate->Throw(*reference_error);
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_StackOverflow(Arguments args) {
|
| - NoHandleAllocation na;
|
| - return Top::StackOverflow();
|
| -}
|
| -
|
| -
|
| -static MaybeObject* Runtime_StackGuard(Arguments args) {
|
| +static MaybeObject* Runtime_StackGuard(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| ASSERT(args.length() == 0);
|
|
|
| // First check if this is a real stack overflow.
|
| - if (StackGuard::IsStackOverflow()) {
|
| - return Runtime_StackOverflow(args);
|
| + if (isolate->stack_guard()->IsStackOverflow()) {
|
| + NoHandleAllocation na;
|
| + return isolate->StackOverflow();
|
| }
|
|
|
| return Execution::HandleStackGuardInterrupt();
|
| @@ -7770,22 +8106,25 @@
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_TraceEnter(Arguments args) {
|
| +static MaybeObject* Runtime_TraceEnter(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| ASSERT(args.length() == 0);
|
| NoHandleAllocation ha;
|
| PrintTransition(NULL);
|
| - return Heap::undefined_value();
|
| + return isolate->heap()->undefined_value();
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_TraceExit(Arguments args) {
|
| +static MaybeObject* Runtime_TraceExit(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| PrintTransition(args[0]);
|
| return args[0]; // return TOS
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_DebugPrint(Arguments args) {
|
| +static MaybeObject* Runtime_DebugPrint(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 1);
|
|
|
| @@ -7816,15 +8155,17 @@
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_DebugTrace(Arguments args) {
|
| +static MaybeObject* Runtime_DebugTrace(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| ASSERT(args.length() == 0);
|
| NoHandleAllocation ha;
|
| - Top::PrintStack();
|
| - return Heap::undefined_value();
|
| + isolate->PrintStack();
|
| + return isolate->heap()->undefined_value();
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_DateCurrentTime(Arguments args) {
|
| +static MaybeObject* Runtime_DateCurrentTime(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 0);
|
|
|
| @@ -7833,12 +8174,13 @@
|
| // time is milliseconds. Therefore, we floor the result of getting
|
| // the OS time.
|
| double millis = floor(OS::TimeCurrentMillis());
|
| - return Heap::NumberFromDouble(millis);
|
| + return isolate->heap()->NumberFromDouble(millis);
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_DateParseString(Arguments args) {
|
| - HandleScope scope;
|
| +static MaybeObject* Runtime_DateParseString(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| + HandleScope scope(isolate);
|
| ASSERT(args.length() == 2);
|
|
|
| CONVERT_ARG_CHECKED(String, str, 0);
|
| @@ -7862,109 +8204,119 @@
|
| if (result) {
|
| return *output;
|
| } else {
|
| - return Heap::null_value();
|
| + return isolate->heap()->null_value();
|
| }
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_DateLocalTimezone(Arguments args) {
|
| +static MaybeObject* Runtime_DateLocalTimezone(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 1);
|
|
|
| CONVERT_DOUBLE_CHECKED(x, args[0]);
|
| const char* zone = OS::LocalTimezone(x);
|
| - return Heap::AllocateStringFromUtf8(CStrVector(zone));
|
| + return isolate->heap()->AllocateStringFromUtf8(CStrVector(zone));
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_DateLocalTimeOffset(Arguments args) {
|
| +static MaybeObject* Runtime_DateLocalTimeOffset(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 0);
|
|
|
| - return Heap::NumberFromDouble(OS::LocalTimeOffset());
|
| + return isolate->heap()->NumberFromDouble(OS::LocalTimeOffset());
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_DateDaylightSavingsOffset(Arguments args) {
|
| +static MaybeObject* Runtime_DateDaylightSavingsOffset(
|
| + RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 1);
|
|
|
| CONVERT_DOUBLE_CHECKED(x, args[0]);
|
| - return Heap::NumberFromDouble(OS::DaylightSavingsOffset(x));
|
| + return isolate->heap()->NumberFromDouble(OS::DaylightSavingsOffset(x));
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_GlobalReceiver(Arguments args) {
|
| +static MaybeObject* Runtime_GlobalReceiver(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| ASSERT(args.length() == 1);
|
| Object* global = args[0];
|
| - if (!global->IsJSGlobalObject()) return Heap::null_value();
|
| + if (!global->IsJSGlobalObject()) return isolate->heap()->null_value();
|
| return JSGlobalObject::cast(global)->global_receiver();
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_ParseJson(Arguments args) {
|
| - HandleScope scope;
|
| +static MaybeObject* Runtime_ParseJson(RUNTIME_CALLING_CONVENTION) {
|
| + HandleScope scope(isolate);
|
| ASSERT_EQ(1, args.length());
|
| CONVERT_ARG_CHECKED(String, source, 0);
|
|
|
| Handle<Object> result = JsonParser::Parse(source);
|
| if (result.is_null()) {
|
| // Syntax error or stack overflow in scanner.
|
| - ASSERT(Top::has_pending_exception());
|
| + ASSERT(isolate->has_pending_exception());
|
| return Failure::Exception();
|
| }
|
| return *result;
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_CompileString(Arguments args) {
|
| - HandleScope scope;
|
| +static MaybeObject* Runtime_CompileString(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| + HandleScope scope(isolate);
|
| ASSERT_EQ(1, args.length());
|
| CONVERT_ARG_CHECKED(String, source, 0);
|
|
|
| // Compile source string in the global context.
|
| - Handle<Context> context(Top::context()->global_context());
|
| + Handle<Context> context(isolate->context()->global_context());
|
| Handle<SharedFunctionInfo> shared = Compiler::CompileEval(source,
|
| context,
|
| true,
|
| kNonStrictMode);
|
| if (shared.is_null()) return Failure::Exception();
|
| Handle<JSFunction> fun =
|
| - Factory::NewFunctionFromSharedFunctionInfo(shared, context, NOT_TENURED);
|
| + isolate->factory()->NewFunctionFromSharedFunctionInfo(shared,
|
| + context,
|
| + NOT_TENURED);
|
| return *fun;
|
| }
|
|
|
|
|
| -static ObjectPair CompileGlobalEval(Handle<String> source,
|
| +static ObjectPair CompileGlobalEval(Isolate* isolate,
|
| + Handle<String> source,
|
| Handle<Object> receiver,
|
| StrictModeFlag strict_mode) {
|
| // Deal with a normal eval call with a string argument. Compile it
|
| // and return the compiled function bound in the local context.
|
| Handle<SharedFunctionInfo> shared = Compiler::CompileEval(
|
| source,
|
| - Handle<Context>(Top::context()),
|
| - Top::context()->IsGlobalContext(),
|
| + Handle<Context>(isolate->context()),
|
| + isolate->context()->IsGlobalContext(),
|
| strict_mode);
|
| if (shared.is_null()) return MakePair(Failure::Exception(), NULL);
|
| - Handle<JSFunction> compiled = Factory::NewFunctionFromSharedFunctionInfo(
|
| - shared,
|
| - Handle<Context>(Top::context()),
|
| - NOT_TENURED);
|
| + Handle<JSFunction> compiled =
|
| + isolate->factory()->NewFunctionFromSharedFunctionInfo(
|
| + shared, Handle<Context>(isolate->context()), NOT_TENURED);
|
| return MakePair(*compiled, *receiver);
|
| }
|
|
|
|
|
| -static ObjectPair Runtime_ResolvePossiblyDirectEval(Arguments args) {
|
| +static ObjectPair Runtime_ResolvePossiblyDirectEval(
|
| + RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| ASSERT(args.length() == 4);
|
|
|
| - HandleScope scope;
|
| + HandleScope scope(isolate);
|
| Handle<Object> callee = args.at<Object>(0);
|
| Handle<Object> receiver; // Will be overwritten.
|
|
|
| // Compute the calling context.
|
| - Handle<Context> context = Handle<Context>(Top::context());
|
| + Handle<Context> context = Handle<Context>(isolate->context(), isolate);
|
| #ifdef DEBUG
|
| - // Make sure Top::context() agrees with the old code that traversed
|
| + // Make sure Isolate::context() agrees with the old code that traversed
|
| // the stack frames to compute the context.
|
| StackFrameLocator locator;
|
| JavaScriptFrame* frame = locator.FindJavaScriptFrame(0);
|
| @@ -7976,25 +8328,28 @@
|
| int index = -1;
|
| PropertyAttributes attributes = ABSENT;
|
| while (true) {
|
| - receiver = context->Lookup(Factory::eval_symbol(), FOLLOW_PROTOTYPE_CHAIN,
|
| + receiver = context->Lookup(isolate->factory()->eval_symbol(),
|
| + FOLLOW_PROTOTYPE_CHAIN,
|
| &index, &attributes);
|
| // Stop search when eval is found or when the global context is
|
| // reached.
|
| if (attributes != ABSENT || context->IsGlobalContext()) break;
|
| if (context->is_function_context()) {
|
| - context = Handle<Context>(Context::cast(context->closure()->context()));
|
| + context = Handle<Context>(Context::cast(context->closure()->context()),
|
| + isolate);
|
| } else {
|
| - context = Handle<Context>(context->previous());
|
| + context = Handle<Context>(context->previous(), isolate);
|
| }
|
| }
|
|
|
| // If eval could not be resolved, it has been deleted and we need to
|
| // throw a reference error.
|
| if (attributes == ABSENT) {
|
| - Handle<Object> name = Factory::eval_symbol();
|
| + Handle<Object> name = isolate->factory()->eval_symbol();
|
| Handle<Object> reference_error =
|
| - Factory::NewReferenceError("not_defined", HandleVector(&name, 1));
|
| - return MakePair(Top::Throw(*reference_error), NULL);
|
| + isolate->factory()->NewReferenceError("not_defined",
|
| + HandleVector(&name, 1));
|
| + return MakePair(isolate->Throw(*reference_error), NULL);
|
| }
|
|
|
| if (!context->IsGlobalContext()) {
|
| @@ -8002,61 +8357,70 @@
|
| // with the given arguments. This is not necessarily the global eval.
|
| if (receiver->IsContext()) {
|
| context = Handle<Context>::cast(receiver);
|
| - receiver = Handle<Object>(context->get(index));
|
| + receiver = Handle<Object>(context->get(index), isolate);
|
| } else if (receiver->IsJSContextExtensionObject()) {
|
| - receiver = Handle<JSObject>(Top::context()->global()->global_receiver());
|
| + receiver = Handle<JSObject>(
|
| + isolate->context()->global()->global_receiver(), isolate);
|
| }
|
| return MakePair(*callee, *receiver);
|
| }
|
|
|
| // 'eval' is bound in the global context, but it may have been overwritten.
|
| // Compare it to the builtin 'GlobalEval' function to make sure.
|
| - if (*callee != Top::global_context()->global_eval_fun() ||
|
| + if (*callee != isolate->global_context()->global_eval_fun() ||
|
| !args[1]->IsString()) {
|
| - return MakePair(*callee, Top::context()->global()->global_receiver());
|
| + return MakePair(*callee,
|
| + isolate->context()->global()->global_receiver());
|
| }
|
|
|
| ASSERT(args[3]->IsSmi());
|
| - return CompileGlobalEval(args.at<String>(1),
|
| + return CompileGlobalEval(isolate,
|
| + args.at<String>(1),
|
| args.at<Object>(2),
|
| static_cast<StrictModeFlag>(
|
| Smi::cast(args[3])->value()));
|
| }
|
|
|
|
|
| -static ObjectPair Runtime_ResolvePossiblyDirectEvalNoLookup(Arguments args) {
|
| +static ObjectPair Runtime_ResolvePossiblyDirectEvalNoLookup(
|
| + RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| ASSERT(args.length() == 4);
|
|
|
| - HandleScope scope;
|
| + HandleScope scope(isolate);
|
| Handle<Object> callee = args.at<Object>(0);
|
|
|
| // 'eval' is bound in the global context, but it may have been overwritten.
|
| // Compare it to the builtin 'GlobalEval' function to make sure.
|
| - if (*callee != Top::global_context()->global_eval_fun() ||
|
| + if (*callee != isolate->global_context()->global_eval_fun() ||
|
| !args[1]->IsString()) {
|
| - return MakePair(*callee, Top::context()->global()->global_receiver());
|
| + return MakePair(*callee,
|
| + isolate->context()->global()->global_receiver());
|
| }
|
|
|
| ASSERT(args[3]->IsSmi());
|
| - return CompileGlobalEval(args.at<String>(1),
|
| + return CompileGlobalEval(isolate,
|
| + args.at<String>(1),
|
| args.at<Object>(2),
|
| static_cast<StrictModeFlag>(
|
| Smi::cast(args[3])->value()));
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_SetNewFunctionAttributes(Arguments args) {
|
| +static MaybeObject* Runtime_SetNewFunctionAttributes(
|
| + RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| // This utility adjusts the property attributes for newly created Function
|
| // object ("new Function(...)") by changing the map.
|
| // All it does is changing the prototype property to enumerable
|
| // as specified in ECMA262, 15.3.5.2.
|
| - HandleScope scope;
|
| + HandleScope scope(isolate);
|
| ASSERT(args.length() == 1);
|
| CONVERT_ARG_CHECKED(JSFunction, func, 0);
|
|
|
| Handle<Map> map = func->shared()->strict_mode()
|
| - ? Top::strict_mode_function_instance_map()
|
| - : Top::function_instance_map();
|
| + ? isolate->strict_mode_function_instance_map()
|
| + : isolate->function_instance_map();
|
|
|
| ASSERT(func->map()->instance_type() == map->instance_type());
|
| ASSERT(func->map()->instance_size() == map->instance_size());
|
| @@ -8065,7 +8429,8 @@
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_AllocateInNewSpace(Arguments args) {
|
| +static MaybeObject* Runtime_AllocateInNewSpace(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| // Allocate a block of memory in NewSpace (filled with a filler).
|
| // Use as fallback for allocation in generated code when NewSpace
|
| // is full.
|
| @@ -8074,13 +8439,13 @@
|
| int size = size_smi->value();
|
| RUNTIME_ASSERT(IsAligned(size, kPointerSize));
|
| RUNTIME_ASSERT(size > 0);
|
| - static const int kMinFreeNewSpaceAfterGC =
|
| - Heap::InitialSemiSpaceSize() * 3/4;
|
| + Heap* heap = isolate->heap();
|
| + const int kMinFreeNewSpaceAfterGC = heap->InitialSemiSpaceSize() * 3/4;
|
| RUNTIME_ASSERT(size <= kMinFreeNewSpaceAfterGC);
|
| Object* allocation;
|
| - { MaybeObject* maybe_allocation = Heap::new_space()->AllocateRaw(size);
|
| + { MaybeObject* maybe_allocation = heap->new_space()->AllocateRaw(size);
|
| if (maybe_allocation->ToObject(&allocation)) {
|
| - Heap::CreateFillerObjectAt(HeapObject::cast(allocation)->address(), size);
|
| + heap->CreateFillerObjectAt(HeapObject::cast(allocation)->address(), size);
|
| }
|
| return maybe_allocation;
|
| }
|
| @@ -8090,7 +8455,8 @@
|
| // Push an object unto an array of objects if it is not already in the
|
| // array. Returns true if the element was pushed on the stack and
|
| // false otherwise.
|
| -static MaybeObject* Runtime_PushIfAbsent(Arguments args) {
|
| +static MaybeObject* Runtime_PushIfAbsent(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| ASSERT(args.length() == 2);
|
| CONVERT_CHECKED(JSArray, array, args[0]);
|
| CONVERT_CHECKED(JSObject, element, args[1]);
|
| @@ -8098,7 +8464,7 @@
|
| int length = Smi::cast(array->length())->value();
|
| FixedArray* elements = FixedArray::cast(array->elements());
|
| for (int i = 0; i < length; i++) {
|
| - if (elements->get(i) == element) return Heap::false_value();
|
| + if (elements->get(i) == element) return isolate->heap()->false_value();
|
| }
|
| Object* obj;
|
| // Strict not needed. Used for cycle detection in Array join implementation.
|
| @@ -8106,7 +8472,7 @@
|
| kNonStrictMode);
|
| if (!maybe_obj->ToObject(&obj)) return maybe_obj;
|
| }
|
| - return Heap::true_value();
|
| + return isolate->heap()->true_value();
|
| }
|
|
|
|
|
| @@ -8123,9 +8489,12 @@
|
| */
|
| class ArrayConcatVisitor {
|
| public:
|
| - ArrayConcatVisitor(Handle<FixedArray> storage,
|
| + ArrayConcatVisitor(Isolate* isolate,
|
| + Handle<FixedArray> storage,
|
| bool fast_elements) :
|
| - storage_(Handle<FixedArray>::cast(GlobalHandles::Create(*storage))),
|
| + isolate_(isolate),
|
| + storage_(Handle<FixedArray>::cast(
|
| + isolate->global_handles()->Create(*storage))),
|
| index_offset_(0u),
|
| fast_elements_(fast_elements) { }
|
|
|
| @@ -8152,7 +8521,7 @@
|
| ASSERT(!fast_elements_);
|
| Handle<NumberDictionary> dict(NumberDictionary::cast(*storage_));
|
| Handle<NumberDictionary> result =
|
| - Factory::DictionaryAtNumberPut(dict, index, elm);
|
| + isolate_->factory()->DictionaryAtNumberPut(dict, index, elm);
|
| if (!result.is_identical_to(dict)) {
|
| // Dictionary needed to grow.
|
| clear_storage();
|
| @@ -8169,14 +8538,14 @@
|
| }
|
|
|
| Handle<JSArray> ToArray() {
|
| - Handle<JSArray> array = Factory::NewJSArray(0);
|
| + Handle<JSArray> array = isolate_->factory()->NewJSArray(0);
|
| Handle<Object> length =
|
| - Factory::NewNumber(static_cast<double>(index_offset_));
|
| + isolate_->factory()->NewNumber(static_cast<double>(index_offset_));
|
| Handle<Map> map;
|
| if (fast_elements_) {
|
| - map = Factory::GetFastElementsMap(Handle<Map>(array->map()));
|
| + map = isolate_->factory()->GetFastElementsMap(Handle<Map>(array->map()));
|
| } else {
|
| - map = Factory::GetSlowElementsMap(Handle<Map>(array->map()));
|
| + map = isolate_->factory()->GetSlowElementsMap(Handle<Map>(array->map()));
|
| }
|
| array->set_map(*map);
|
| array->set_length(*length);
|
| @@ -8190,14 +8559,14 @@
|
| ASSERT(fast_elements_);
|
| Handle<FixedArray> current_storage(*storage_);
|
| Handle<NumberDictionary> slow_storage(
|
| - Factory::NewNumberDictionary(current_storage->length()));
|
| + isolate_->factory()->NewNumberDictionary(current_storage->length()));
|
| uint32_t current_length = static_cast<uint32_t>(current_storage->length());
|
| for (uint32_t i = 0; i < current_length; i++) {
|
| HandleScope loop_scope;
|
| Handle<Object> element(current_storage->get(i));
|
| if (!element->IsTheHole()) {
|
| Handle<NumberDictionary> new_storage =
|
| - Factory::DictionaryAtNumberPut(slow_storage, i, element);
|
| + isolate_->factory()->DictionaryAtNumberPut(slow_storage, i, element);
|
| if (!new_storage.is_identical_to(slow_storage)) {
|
| slow_storage = loop_scope.CloseAndEscape(new_storage);
|
| }
|
| @@ -8209,13 +8578,16 @@
|
| }
|
|
|
| inline void clear_storage() {
|
| - GlobalHandles::Destroy(Handle<Object>::cast(storage_).location());
|
| + isolate_->global_handles()->Destroy(
|
| + Handle<Object>::cast(storage_).location());
|
| }
|
|
|
| inline void set_storage(FixedArray* storage) {
|
| - storage_ = Handle<FixedArray>::cast(GlobalHandles::Create(storage));
|
| + storage_ = Handle<FixedArray>::cast(
|
| + isolate_->global_handles()->Create(storage));
|
| }
|
|
|
| + Isolate* isolate_;
|
| Handle<FixedArray> storage_; // Always a global handle.
|
| // Index after last seen index. Always less than or equal to
|
| // JSObject::kMaxElementCount.
|
| @@ -8263,7 +8635,8 @@
|
|
|
|
|
| template<class ExternalArrayClass, class ElementType>
|
| -static void IterateExternalArrayElements(Handle<JSObject> receiver,
|
| +static void IterateExternalArrayElements(Isolate* isolate,
|
| + Handle<JSObject> receiver,
|
| bool elements_are_ints,
|
| bool elements_are_guaranteed_smis,
|
| ArrayConcatVisitor* visitor) {
|
| @@ -8288,15 +8661,15 @@
|
| visitor->visit(j, e);
|
| } else {
|
| Handle<Object> e =
|
| - Factory::NewNumber(static_cast<ElementType>(val));
|
| + isolate->factory()->NewNumber(static_cast<ElementType>(val));
|
| visitor->visit(j, e);
|
| }
|
| }
|
| }
|
| } else {
|
| for (uint32_t j = 0; j < len; j++) {
|
| - HandleScope loop_scope;
|
| - Handle<Object> e = Factory::NewNumber(array->get(j));
|
| + HandleScope loop_scope(isolate);
|
| + Handle<Object> e = isolate->factory()->NewNumber(array->get(j));
|
| visitor->visit(j, e);
|
| }
|
| }
|
| @@ -8425,7 +8798,8 @@
|
| * length.
|
| * Returns false if any access threw an exception, otherwise true.
|
| */
|
| -static bool IterateElements(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()) {
|
| @@ -8436,8 +8810,8 @@
|
| int fast_length = static_cast<int>(length);
|
| ASSERT(fast_length <= elements->length());
|
| for (int j = 0; j < fast_length; j++) {
|
| - HandleScope loop_scope;
|
| - Handle<Object> element_value(elements->get(j));
|
| + HandleScope loop_scope(isolate);
|
| + Handle<Object> element_value(elements->get(j), isolate);
|
| if (!element_value->IsTheHole()) {
|
| visitor->visit(j, element_value);
|
| } else if (receiver->HasElement(j)) {
|
| @@ -8483,37 +8857,37 @@
|
| }
|
| case JSObject::EXTERNAL_BYTE_ELEMENTS: {
|
| IterateExternalArrayElements<ExternalByteArray, int8_t>(
|
| - receiver, true, true, visitor);
|
| + isolate, receiver, true, true, visitor);
|
| break;
|
| }
|
| case JSObject::EXTERNAL_UNSIGNED_BYTE_ELEMENTS: {
|
| IterateExternalArrayElements<ExternalUnsignedByteArray, uint8_t>(
|
| - receiver, true, true, visitor);
|
| + isolate, receiver, true, true, visitor);
|
| break;
|
| }
|
| case JSObject::EXTERNAL_SHORT_ELEMENTS: {
|
| IterateExternalArrayElements<ExternalShortArray, int16_t>(
|
| - receiver, true, true, visitor);
|
| + isolate, receiver, true, true, visitor);
|
| break;
|
| }
|
| case JSObject::EXTERNAL_UNSIGNED_SHORT_ELEMENTS: {
|
| IterateExternalArrayElements<ExternalUnsignedShortArray, uint16_t>(
|
| - receiver, true, true, visitor);
|
| + isolate, receiver, true, true, visitor);
|
| break;
|
| }
|
| case JSObject::EXTERNAL_INT_ELEMENTS: {
|
| IterateExternalArrayElements<ExternalIntArray, int32_t>(
|
| - receiver, true, false, visitor);
|
| + isolate, receiver, true, false, visitor);
|
| break;
|
| }
|
| case JSObject::EXTERNAL_UNSIGNED_INT_ELEMENTS: {
|
| IterateExternalArrayElements<ExternalUnsignedIntArray, uint32_t>(
|
| - receiver, true, false, visitor);
|
| + isolate, receiver, true, false, visitor);
|
| break;
|
| }
|
| case JSObject::EXTERNAL_FLOAT_ELEMENTS: {
|
| IterateExternalArrayElements<ExternalFloatArray, float>(
|
| - receiver, false, false, visitor);
|
| + isolate, receiver, false, false, visitor);
|
| break;
|
| }
|
| default:
|
| @@ -8531,9 +8905,10 @@
|
| * TODO(581): Fix non-compliance for very large concatenations and update to
|
| * following the ECMAScript 5 specification.
|
| */
|
| -static MaybeObject* Runtime_ArrayConcat(Arguments args) {
|
| +static MaybeObject* Runtime_ArrayConcat(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| ASSERT(args.length() == 1);
|
| - HandleScope handle_scope;
|
| + HandleScope handle_scope(isolate);
|
|
|
| CONVERT_ARG_CHECKED(JSArray, arguments, 0);
|
| int argument_count = static_cast<int>(arguments->length()->Number());
|
| @@ -8588,22 +8963,23 @@
|
| if (fast_case) {
|
| // The backing storage array must have non-existing elements to
|
| // preserve holes across concat operations.
|
| - storage = 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);
|
| storage = Handle<FixedArray>::cast(
|
| - Factory::NewNumberDictionary(at_least_space_for));
|
| + isolate->factory()->NewNumberDictionary(at_least_space_for));
|
| }
|
|
|
| - ArrayConcatVisitor visitor(storage, fast_case);
|
| + ArrayConcatVisitor visitor(isolate, storage, fast_case);
|
|
|
| for (int i = 0; i < argument_count; i++) {
|
| Handle<Object> obj(elements->get(i));
|
| if (obj->IsJSArray()) {
|
| Handle<JSArray> array = Handle<JSArray>::cast(obj);
|
| - if (!IterateElements(array, &visitor)) {
|
| + if (!IterateElements(isolate, array, &visitor)) {
|
| return Failure::Exception();
|
| }
|
| } else {
|
| @@ -8618,7 +8994,8 @@
|
|
|
| // This will not allocate (flatten the string), but it may run
|
| // very slowly for very deeply nested ConsStrings. For debugging use only.
|
| -static MaybeObject* Runtime_GlobalPrint(Arguments args) {
|
| +static MaybeObject* Runtime_GlobalPrint(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 1);
|
|
|
| @@ -8636,7 +9013,8 @@
|
| // and are followed by non-existing element. Does not change the length
|
| // property.
|
| // Returns the number of non-undefined elements collected.
|
| -static MaybeObject* Runtime_RemoveArrayHoles(Arguments args) {
|
| +static MaybeObject* Runtime_RemoveArrayHoles(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| ASSERT(args.length() == 2);
|
| CONVERT_CHECKED(JSObject, object, args[0]);
|
| CONVERT_NUMBER_CHECKED(uint32_t, limit, Uint32, args[1]);
|
| @@ -8645,14 +9023,15 @@
|
|
|
|
|
| // Move contents of argument 0 (an array) to argument 1 (an array)
|
| -static MaybeObject* Runtime_MoveArrayContents(Arguments args) {
|
| +static MaybeObject* Runtime_MoveArrayContents(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| ASSERT(args.length() == 2);
|
| CONVERT_CHECKED(JSArray, from, args[0]);
|
| CONVERT_CHECKED(JSArray, to, args[1]);
|
| HeapObject* new_elements = from->elements();
|
| MaybeObject* maybe_new_map;
|
| - if (new_elements->map() == Heap::fixed_array_map() ||
|
| - new_elements->map() == Heap::fixed_cow_array_map()) {
|
| + if (new_elements->map() == isolate->heap()->fixed_array_map() ||
|
| + new_elements->map() == isolate->heap()->fixed_cow_array_map()) {
|
| maybe_new_map = to->map()->GetFastElementsMap();
|
| } else {
|
| maybe_new_map = to->map()->GetSlowElementsMap();
|
| @@ -8672,7 +9051,9 @@
|
|
|
|
|
| // How many elements does this object/array have?
|
| -static MaybeObject* Runtime_EstimateNumberOfElements(Arguments args) {
|
| +static MaybeObject* Runtime_EstimateNumberOfElements(
|
| + RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| ASSERT(args.length() == 1);
|
| CONVERT_CHECKED(JSObject, object, args[0]);
|
| HeapObject* elements = object->elements();
|
| @@ -8686,8 +9067,9 @@
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_SwapElements(Arguments args) {
|
| - HandleScope handle_scope;
|
| +static MaybeObject* Runtime_SwapElements(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| + HandleScope handle_scope(isolate);
|
|
|
| ASSERT_EQ(3, args.length());
|
|
|
| @@ -8698,19 +9080,21 @@
|
| uint32_t index1, index2;
|
| if (!key1->ToArrayIndex(&index1)
|
| || !key2->ToArrayIndex(&index2)) {
|
| - return Top::ThrowIllegalOperation();
|
| + return isolate->ThrowIllegalOperation();
|
| }
|
|
|
| Handle<JSObject> jsobject = Handle<JSObject>::cast(object);
|
| Handle<Object> tmp1 = GetElement(jsobject, index1);
|
| - RETURN_IF_EMPTY_HANDLE(tmp1);
|
| + RETURN_IF_EMPTY_HANDLE(isolate, tmp1);
|
| Handle<Object> tmp2 = GetElement(jsobject, index2);
|
| - RETURN_IF_EMPTY_HANDLE(tmp2);
|
| + RETURN_IF_EMPTY_HANDLE(isolate, tmp2);
|
|
|
| - RETURN_IF_EMPTY_HANDLE(SetElement(jsobject, index1, tmp2, kStrictMode));
|
| - RETURN_IF_EMPTY_HANDLE(SetElement(jsobject, index2, tmp1, kStrictMode));
|
| + RETURN_IF_EMPTY_HANDLE(isolate,
|
| + SetElement(jsobject, index1, tmp2, kStrictMode));
|
| + RETURN_IF_EMPTY_HANDLE(isolate,
|
| + SetElement(jsobject, index2, tmp1, kStrictMode));
|
|
|
| - return Heap::undefined_value();
|
| + return isolate->heap()->undefined_value();
|
| }
|
|
|
|
|
| @@ -8719,9 +9103,10 @@
|
| // intervals (pair of a negative integer (-start-1) followed by a
|
| // positive (length)) or undefined values.
|
| // Intervals can span over some keys that are not in the object.
|
| -static MaybeObject* Runtime_GetArrayKeys(Arguments args) {
|
| +static MaybeObject* Runtime_GetArrayKeys(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| ASSERT(args.length() == 2);
|
| - HandleScope scope;
|
| + HandleScope scope(isolate);
|
| CONVERT_ARG_CHECKED(JSObject, array, 0);
|
| CONVERT_NUMBER_CHECKED(uint32_t, length, Uint32, args[1]);
|
| if (array->elements()->IsDictionary()) {
|
| @@ -8737,19 +9122,19 @@
|
| keys->set_undefined(i);
|
| }
|
| }
|
| - return *Factory::NewJSArrayWithElements(keys);
|
| + return *isolate->factory()->NewJSArrayWithElements(keys);
|
| } else {
|
| ASSERT(array->HasFastElements());
|
| - Handle<FixedArray> single_interval = Factory::NewFixedArray(2);
|
| + Handle<FixedArray> single_interval = isolate->factory()->NewFixedArray(2);
|
| // -1 means start of array.
|
| single_interval->set(0, Smi::FromInt(-1));
|
| uint32_t actual_length =
|
| static_cast<uint32_t>(FixedArray::cast(array->elements())->length());
|
| uint32_t min_length = actual_length < length ? actual_length : length;
|
| Handle<Object> length_object =
|
| - Factory::NewNumber(static_cast<double>(min_length));
|
| + isolate->factory()->NewNumber(static_cast<double>(min_length));
|
| single_interval->set(1, *length_object);
|
| - return *Factory::NewJSArrayWithElements(single_interval);
|
| + return *isolate->factory()->NewJSArrayWithElements(single_interval);
|
| }
|
| }
|
|
|
| @@ -8759,7 +9144,8 @@
|
| // to the way accessors are implemented, it is set for both the getter
|
| // and setter on the first call to DefineAccessor and ignored on
|
| // subsequent calls.
|
| -static MaybeObject* Runtime_DefineAccessor(Arguments args) {
|
| +static MaybeObject* Runtime_DefineAccessor(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| RUNTIME_ASSERT(args.length() == 4 || args.length() == 5);
|
| // Compute attributes.
|
| PropertyAttributes attributes = NONE;
|
| @@ -8779,7 +9165,8 @@
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_LookupAccessor(Arguments args) {
|
| +static MaybeObject* Runtime_LookupAccessor(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| ASSERT(args.length() == 3);
|
| CONVERT_CHECKED(JSObject, obj, args[0]);
|
| CONVERT_CHECKED(String, name, args[1]);
|
| @@ -8789,7 +9176,8 @@
|
|
|
|
|
| #ifdef ENABLE_DEBUGGER_SUPPORT
|
| -static MaybeObject* Runtime_DebugBreak(Arguments args) {
|
| +static MaybeObject* Runtime_DebugBreak(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| ASSERT(args.length() == 0);
|
| return Execution::DebugBreakHelper();
|
| }
|
| @@ -8811,27 +9199,31 @@
|
| // args[0]: debug event listener function to set or null or undefined for
|
| // clearing the event listener function
|
| // args[1]: object supplied during callback
|
| -static MaybeObject* Runtime_SetDebugEventListener(Arguments args) {
|
| +static MaybeObject* Runtime_SetDebugEventListener(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| ASSERT(args.length() == 2);
|
| RUNTIME_ASSERT(args[0]->IsJSFunction() ||
|
| args[0]->IsUndefined() ||
|
| args[0]->IsNull());
|
| Handle<Object> callback = args.at<Object>(0);
|
| Handle<Object> data = args.at<Object>(1);
|
| - Debugger::SetEventListener(callback, data);
|
| + isolate->debugger()->SetEventListener(callback, data);
|
|
|
| - return Heap::undefined_value();
|
| + return isolate->heap()->undefined_value();
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_Break(Arguments args) {
|
| +static MaybeObject* Runtime_Break(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| ASSERT(args.length() == 0);
|
| - StackGuard::DebugBreak();
|
| - return Heap::undefined_value();
|
| + isolate->stack_guard()->DebugBreak();
|
| + return isolate->heap()->undefined_value();
|
| }
|
|
|
|
|
| -static MaybeObject* DebugLookupResultValue(Object* receiver, String* name,
|
| +static MaybeObject* DebugLookupResultValue(Heap* heap,
|
| + Object* receiver,
|
| + String* name,
|
| LookupResult* result,
|
| bool* caught_exception) {
|
| Object* value;
|
| @@ -8839,7 +9231,7 @@
|
| case NORMAL:
|
| value = result->holder()->GetNormalizedProperty(result);
|
| if (value->IsTheHole()) {
|
| - return Heap::undefined_value();
|
| + return heap->undefined_value();
|
| }
|
| return value;
|
| case FIELD:
|
| @@ -8847,7 +9239,7 @@
|
| JSObject::cast(
|
| result->holder())->FastPropertyAt(result->GetFieldIndex());
|
| if (value->IsTheHole()) {
|
| - return Heap::undefined_value();
|
| + return heap->undefined_value();
|
| }
|
| return value;
|
| case CONSTANT_FUNCTION:
|
| @@ -8860,8 +9252,8 @@
|
| if (!maybe_value->ToObject(&value)) {
|
| if (maybe_value->IsRetryAfterGC()) return maybe_value;
|
| ASSERT(maybe_value->IsException());
|
| - maybe_value = Top::pending_exception();
|
| - Top::clear_pending_exception();
|
| + maybe_value = heap->isolate()->pending_exception();
|
| + heap->isolate()->clear_pending_exception();
|
| if (caught_exception != NULL) {
|
| *caught_exception = true;
|
| }
|
| @@ -8869,19 +9261,19 @@
|
| }
|
| return value;
|
| } else {
|
| - return Heap::undefined_value();
|
| + return heap->undefined_value();
|
| }
|
| }
|
| case INTERCEPTOR:
|
| case MAP_TRANSITION:
|
| case CONSTANT_TRANSITION:
|
| case NULL_DESCRIPTOR:
|
| - return Heap::undefined_value();
|
| + return heap->undefined_value();
|
| default:
|
| UNREACHABLE();
|
| }
|
| UNREACHABLE();
|
| - return Heap::undefined_value();
|
| + return heap->undefined_value();
|
| }
|
|
|
|
|
| @@ -8897,8 +9289,10 @@
|
| // 4: Setter function if defined
|
| // Items 2-4 are only filled if the property has either a getter or a setter
|
| // defined through __defineGetter__ and/or __defineSetter__.
|
| -static MaybeObject* Runtime_DebugGetPropertyDetails(Arguments args) {
|
| - HandleScope scope;
|
| +static MaybeObject* Runtime_DebugGetPropertyDetails(
|
| + RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| + HandleScope scope(isolate);
|
|
|
| ASSERT(args.length() == 2);
|
|
|
| @@ -8911,9 +9305,9 @@
|
| // into the embedding application can occour, and the embedding application
|
| // could have the assumption that its own global context is the current
|
| // context and not some internal debugger context.
|
| - SaveContext save;
|
| - if (Debug::InDebugger()) {
|
| - Top::set_context(*Debug::debugger_entry()->GetContext());
|
| + SaveContext save(isolate);
|
| + if (isolate->debug()->InDebugger()) {
|
| + isolate->set_context(*isolate->debug()->debugger_entry()->GetContext());
|
| }
|
|
|
| // Skip the global proxy as it has no properties and always delegates to the
|
| @@ -8927,17 +9321,17 @@
|
| // if so.
|
| uint32_t index;
|
| if (name->AsArrayIndex(&index)) {
|
| - Handle<FixedArray> details = Factory::NewFixedArray(2);
|
| + Handle<FixedArray> details = isolate->factory()->NewFixedArray(2);
|
| Object* element_or_char;
|
| { MaybeObject* maybe_element_or_char =
|
| - Runtime::GetElementOrCharAt(obj, index);
|
| + Runtime::GetElementOrCharAt(isolate, obj, index);
|
| if (!maybe_element_or_char->ToObject(&element_or_char)) {
|
| return maybe_element_or_char;
|
| }
|
| }
|
| details->set(0, element_or_char);
|
| details->set(1, PropertyDetails(NONE, NORMAL).AsSmi());
|
| - return *Factory::NewJSArrayWithElements(details);
|
| + return *isolate->factory()->NewJSArrayWithElements(details);
|
| }
|
|
|
| // Find the number of objects making up this.
|
| @@ -8955,7 +9349,8 @@
|
| PropertyType result_type = result.type();
|
| Handle<Object> result_callback_obj;
|
| if (result_type == CALLBACKS) {
|
| - result_callback_obj = Handle<Object>(result.GetCallbackObject());
|
| + result_callback_obj = Handle<Object>(result.GetCallbackObject(),
|
| + isolate);
|
| }
|
| Smi* property_details = result.GetPropertyDetails().AsSmi();
|
| // DebugLookupResultValue can cause GC so details from LookupResult needs
|
| @@ -8963,40 +9358,42 @@
|
| bool caught_exception = false;
|
| Object* raw_value;
|
| { MaybeObject* maybe_raw_value =
|
| - DebugLookupResultValue(*obj, *name, &result, &caught_exception);
|
| + DebugLookupResultValue(isolate->heap(), *obj, *name,
|
| + &result, &caught_exception);
|
| if (!maybe_raw_value->ToObject(&raw_value)) return maybe_raw_value;
|
| }
|
| - Handle<Object> value(raw_value);
|
| + Handle<Object> value(raw_value, isolate);
|
|
|
| // If the callback object is a fixed array then it contains JavaScript
|
| // getter and/or setter.
|
| bool hasJavaScriptAccessors = result_type == CALLBACKS &&
|
| result_callback_obj->IsFixedArray();
|
| Handle<FixedArray> details =
|
| - Factory::NewFixedArray(hasJavaScriptAccessors ? 5 : 2);
|
| + isolate->factory()->NewFixedArray(hasJavaScriptAccessors ? 5 : 2);
|
| details->set(0, *value);
|
| details->set(1, property_details);
|
| if (hasJavaScriptAccessors) {
|
| details->set(2,
|
| - caught_exception ? Heap::true_value()
|
| - : Heap::false_value());
|
| + caught_exception ? isolate->heap()->true_value()
|
| + : isolate->heap()->false_value());
|
| details->set(3, FixedArray::cast(*result_callback_obj)->get(0));
|
| details->set(4, FixedArray::cast(*result_callback_obj)->get(1));
|
| }
|
|
|
| - return *Factory::NewJSArrayWithElements(details);
|
| + return *isolate->factory()->NewJSArrayWithElements(details);
|
| }
|
| if (i < length - 1) {
|
| jsproto = Handle<JSObject>(JSObject::cast(jsproto->GetPrototype()));
|
| }
|
| }
|
|
|
| - return Heap::undefined_value();
|
| + return isolate->heap()->undefined_value();
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_DebugGetProperty(Arguments args) {
|
| - HandleScope scope;
|
| +static MaybeObject* Runtime_DebugGetProperty(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| + HandleScope scope(isolate);
|
|
|
| ASSERT(args.length() == 2);
|
|
|
| @@ -9006,15 +9403,17 @@
|
| LookupResult result;
|
| obj->Lookup(*name, &result);
|
| if (result.IsProperty()) {
|
| - return DebugLookupResultValue(*obj, *name, &result, NULL);
|
| + return DebugLookupResultValue(isolate->heap(), *obj, *name, &result, NULL);
|
| }
|
| - return Heap::undefined_value();
|
| + return isolate->heap()->undefined_value();
|
| }
|
|
|
|
|
| // Return the property type calculated from the property details.
|
| // args[0]: smi with property details.
|
| -static MaybeObject* Runtime_DebugPropertyTypeFromDetails(Arguments args) {
|
| +static MaybeObject* Runtime_DebugPropertyTypeFromDetails(
|
| + RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| ASSERT(args.length() == 1);
|
| CONVERT_CHECKED(Smi, details, args[0]);
|
| PropertyType type = PropertyDetails(details).type();
|
| @@ -9024,7 +9423,9 @@
|
|
|
| // Return the property attribute calculated from the property details.
|
| // args[0]: smi with property details.
|
| -static MaybeObject* Runtime_DebugPropertyAttributesFromDetails(Arguments args) {
|
| +static MaybeObject* Runtime_DebugPropertyAttributesFromDetails(
|
| + RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| ASSERT(args.length() == 1);
|
| CONVERT_CHECKED(Smi, details, args[0]);
|
| PropertyAttributes attributes = PropertyDetails(details).attributes();
|
| @@ -9034,7 +9435,9 @@
|
|
|
| // Return the property insertion index calculated from the property details.
|
| // args[0]: smi with property details.
|
| -static MaybeObject* Runtime_DebugPropertyIndexFromDetails(Arguments args) {
|
| +static MaybeObject* Runtime_DebugPropertyIndexFromDetails(
|
| + RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| ASSERT(args.length() == 1);
|
| CONVERT_CHECKED(Smi, details, args[0]);
|
| int index = PropertyDetails(details).index();
|
| @@ -9045,8 +9448,10 @@
|
| // Return property value from named interceptor.
|
| // args[0]: object
|
| // args[1]: property name
|
| -static MaybeObject* Runtime_DebugNamedInterceptorPropertyValue(Arguments args) {
|
| - HandleScope scope;
|
| +static MaybeObject* Runtime_DebugNamedInterceptorPropertyValue(
|
| + RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| + HandleScope scope(isolate);
|
| ASSERT(args.length() == 2);
|
| CONVERT_ARG_CHECKED(JSObject, obj, 0);
|
| RUNTIME_ASSERT(obj->HasNamedInterceptor());
|
| @@ -9061,8 +9466,9 @@
|
| // args[0]: object
|
| // args[1]: index
|
| static MaybeObject* Runtime_DebugIndexedInterceptorElementValue(
|
| - Arguments args) {
|
| - HandleScope scope;
|
| + RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| + HandleScope scope(isolate);
|
| ASSERT(args.length() == 2);
|
| CONVERT_ARG_CHECKED(JSObject, obj, 0);
|
| RUNTIME_ASSERT(obj->HasIndexedInterceptor());
|
| @@ -9072,31 +9478,35 @@
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_CheckExecutionState(Arguments args) {
|
| +static MaybeObject* Runtime_CheckExecutionState(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| ASSERT(args.length() >= 1);
|
| CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]);
|
| // Check that the break id is valid.
|
| - if (Debug::break_id() == 0 || break_id != Debug::break_id()) {
|
| - return Top::Throw(Heap::illegal_execution_state_symbol());
|
| + if (isolate->debug()->break_id() == 0 ||
|
| + break_id != isolate->debug()->break_id()) {
|
| + return isolate->Throw(
|
| + isolate->heap()->illegal_execution_state_symbol());
|
| }
|
|
|
| - return Heap::true_value();
|
| + return isolate->heap()->true_value();
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_GetFrameCount(Arguments args) {
|
| - HandleScope scope;
|
| +static MaybeObject* Runtime_GetFrameCount(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| + HandleScope scope(isolate);
|
| ASSERT(args.length() == 1);
|
|
|
| // Check arguments.
|
| Object* result;
|
| - { MaybeObject* maybe_result = Runtime_CheckExecutionState(args);
|
| + { MaybeObject* maybe_result = Runtime_CheckExecutionState(args, isolate);
|
| if (!maybe_result->ToObject(&result)) return maybe_result;
|
| }
|
|
|
| // Count all frames which are relevant to debugging stack trace.
|
| int n = 0;
|
| - StackFrame::Id id = Debug::break_frame_id();
|
| + StackFrame::Id id = isolate->debug()->break_frame_id();
|
| if (id == StackFrame::NO_ID) {
|
| // If there is no JavaScript stack frame count is 0.
|
| return Smi::FromInt(0);
|
| @@ -9134,22 +9544,24 @@
|
| // Arguments name, value
|
| // Locals name, value
|
| // Return value if any
|
| -static MaybeObject* Runtime_GetFrameDetails(Arguments args) {
|
| - HandleScope scope;
|
| +static MaybeObject* Runtime_GetFrameDetails(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| + HandleScope scope(isolate);
|
| ASSERT(args.length() == 2);
|
|
|
| // Check arguments.
|
| Object* check;
|
| - { MaybeObject* maybe_check = Runtime_CheckExecutionState(args);
|
| + { MaybeObject* maybe_check = Runtime_CheckExecutionState(args, isolate);
|
| if (!maybe_check->ToObject(&check)) return maybe_check;
|
| }
|
| CONVERT_NUMBER_CHECKED(int, index, Int32, args[1]);
|
| + Heap* heap = isolate->heap();
|
|
|
| // Find the relevant frame with the requested index.
|
| - StackFrame::Id id = Debug::break_frame_id();
|
| + StackFrame::Id id = isolate->debug()->break_frame_id();
|
| if (id == StackFrame::NO_ID) {
|
| // If there are no JavaScript stack frames return undefined.
|
| - return Heap::undefined_value();
|
| + return heap->undefined_value();
|
| }
|
| int count = 0;
|
| JavaScriptFrameIterator it(id);
|
| @@ -9157,24 +9569,25 @@
|
| if (count == index) break;
|
| count++;
|
| }
|
| - if (it.done()) return Heap::undefined_value();
|
| + if (it.done()) return heap->undefined_value();
|
|
|
| bool is_optimized_frame =
|
| - it.frame()->code()->kind() == Code::OPTIMIZED_FUNCTION;
|
| + it.frame()->LookupCode(isolate)->kind() == Code::OPTIMIZED_FUNCTION;
|
|
|
| // Traverse the saved contexts chain to find the active context for the
|
| // selected frame.
|
| - SaveContext* save = Top::save_context();
|
| + SaveContext* save = isolate->save_context();
|
| while (save != NULL && !save->below(it.frame())) {
|
| save = save->prev();
|
| }
|
| ASSERT(save != NULL);
|
|
|
| // Get the frame id.
|
| - Handle<Object> frame_id(WrapFrameId(it.frame()->id()));
|
| + Handle<Object> frame_id(WrapFrameId(it.frame()->id()), isolate);
|
|
|
| // Find source position.
|
| - int position = it.frame()->code()->SourcePosition(it.frame()->pc());
|
| + int position =
|
| + it.frame()->LookupCode(isolate)->SourcePosition(it.frame()->pc());
|
|
|
| // Check for constructor frame.
|
| bool constructor = it.frame()->IsConstructor();
|
| @@ -9192,7 +9605,8 @@
|
| // TODO(1240907): Hide compiler-introduced stack variables
|
| // (e.g. .result)? For users of the debugger, they will probably be
|
| // confusing.
|
| - Handle<FixedArray> locals = Factory::NewFixedArray(info.NumberOfLocals() * 2);
|
| + Handle<FixedArray> locals =
|
| + isolate->factory()->NewFixedArray(info.NumberOfLocals() * 2);
|
|
|
| // Fill in the names of the locals.
|
| for (int i = 0; i < info.NumberOfLocals(); i++) {
|
| @@ -9207,7 +9621,7 @@
|
| //
|
| // TODO(1140): We should be able to get the correct values
|
| // for locals in optimized frames.
|
| - locals->set(i * 2 + 1, Heap::undefined_value());
|
| + locals->set(i * 2 + 1, isolate->heap()->undefined_value());
|
| } else if (i < info.number_of_stack_slots()) {
|
| // Get the value from the stack.
|
| locals->set(i * 2 + 1, it.frame()->GetExpression(i));
|
| @@ -9228,12 +9642,12 @@
|
| // frame or if the frame is optimized it cannot be at a return.
|
| bool at_return = false;
|
| if (!is_optimized_frame && index == 0) {
|
| - at_return = Debug::IsBreakAtReturn(it.frame());
|
| + at_return = isolate->debug()->IsBreakAtReturn(it.frame());
|
| }
|
|
|
| // If positioned just before return find the value to be returned and add it
|
| // to the frame information.
|
| - Handle<Object> return_value = Factory::undefined_value();
|
| + Handle<Object> return_value = isolate->factory()->undefined_value();
|
| if (at_return) {
|
| StackFrameIterator it2;
|
| Address internal_frame_sp = NULL;
|
| @@ -9249,7 +9663,8 @@
|
| // entering the debug break exit frame.
|
| if (internal_frame_sp != NULL) {
|
| return_value =
|
| - Handle<Object>(Memory::Object_at(internal_frame_sp));
|
| + Handle<Object>(Memory::Object_at(internal_frame_sp),
|
| + isolate);
|
| break;
|
| }
|
| }
|
| @@ -9279,7 +9694,7 @@
|
| int details_size = kFrameDetailsFirstDynamicIndex +
|
| 2 * (argument_count + info.NumberOfLocals()) +
|
| (at_return ? 1 : 0);
|
| - Handle<FixedArray> details = Factory::NewFixedArray(details_size);
|
| + Handle<FixedArray> details = isolate->factory()->NewFixedArray(details_size);
|
|
|
| // Add the frame id.
|
| details->set(kFrameDetailsFrameIdIndex, *frame_id);
|
| @@ -9298,18 +9713,19 @@
|
| if (position != RelocInfo::kNoPosition) {
|
| details->set(kFrameDetailsSourcePositionIndex, Smi::FromInt(position));
|
| } else {
|
| - details->set(kFrameDetailsSourcePositionIndex, Heap::undefined_value());
|
| + details->set(kFrameDetailsSourcePositionIndex, heap->undefined_value());
|
| }
|
|
|
| // Add the constructor information.
|
| - details->set(kFrameDetailsConstructCallIndex, Heap::ToBoolean(constructor));
|
| + details->set(kFrameDetailsConstructCallIndex, heap->ToBoolean(constructor));
|
|
|
| // Add the at return information.
|
| - details->set(kFrameDetailsAtReturnIndex, Heap::ToBoolean(at_return));
|
| + details->set(kFrameDetailsAtReturnIndex, heap->ToBoolean(at_return));
|
|
|
| // Add information on whether this frame is invoked in the debugger context.
|
| details->set(kFrameDetailsDebuggerFrameIndex,
|
| - Heap::ToBoolean(*save->context() == *Debug::debug_context()));
|
| + heap->ToBoolean(*save->context() ==
|
| + *isolate->debug()->debug_context()));
|
|
|
| // Fill the dynamic part.
|
| int details_index = kFrameDetailsFirstDynamicIndex;
|
| @@ -9320,7 +9736,7 @@
|
| if (i < info.number_of_parameters()) {
|
| details->set(details_index++, *info.parameter_name(i));
|
| } else {
|
| - details->set(details_index++, Heap::undefined_value());
|
| + details->set(details_index++, heap->undefined_value());
|
| }
|
|
|
| // Parameter value. If we are inspecting an optimized frame, use
|
| @@ -9332,7 +9748,7 @@
|
| (i < it.frame()->ComputeParametersCount())) {
|
| details->set(details_index++, it.frame()->GetParameter(i));
|
| } else {
|
| - details->set(details_index++, Heap::undefined_value());
|
| + details->set(details_index++, heap->undefined_value());
|
| }
|
| }
|
|
|
| @@ -9349,7 +9765,7 @@
|
| // Add the receiver (same as in function frame).
|
| // THIS MUST BE DONE LAST SINCE WE MIGHT ADVANCE
|
| // THE FRAME ITERATOR TO WRAP THE RECEIVER.
|
| - Handle<Object> receiver(it.frame()->receiver());
|
| + Handle<Object> receiver(it.frame()->receiver(), isolate);
|
| if (!receiver->IsJSObject()) {
|
| // If the receiver is NOT a JSObject we have hit an optimization
|
| // where a value object is not converted into a wrapped JS objects.
|
| @@ -9359,17 +9775,19 @@
|
| it.Advance();
|
| Handle<Context> calling_frames_global_context(
|
| Context::cast(Context::cast(it.frame()->context())->global_context()));
|
| - receiver = Factory::ToObject(receiver, calling_frames_global_context);
|
| + receiver =
|
| + isolate->factory()->ToObject(receiver, calling_frames_global_context);
|
| }
|
| details->set(kFrameDetailsReceiverIndex, *receiver);
|
|
|
| ASSERT_EQ(details_size, details_index);
|
| - return *Factory::NewJSArrayWithElements(details);
|
| + return *isolate->factory()->NewJSArrayWithElements(details);
|
| }
|
|
|
|
|
| // Copy all the context locals into an object used to materialize a scope.
|
| static bool CopyContextLocalsToScopeObject(
|
| + Isolate* isolate,
|
| Handle<SerializedScopeInfo> serialized_scope_info,
|
| ScopeInfo<>& scope_info,
|
| Handle<Context> context,
|
| @@ -9382,11 +9800,13 @@
|
| *scope_info.context_slot_name(i), NULL);
|
|
|
| // Don't include the arguments shadow (.arguments) context variable.
|
| - if (*scope_info.context_slot_name(i) != Heap::arguments_shadow_symbol()) {
|
| + if (*scope_info.context_slot_name(i) !=
|
| + isolate->heap()->arguments_shadow_symbol()) {
|
| RETURN_IF_EMPTY_HANDLE_VALUE(
|
| + isolate,
|
| SetProperty(scope_object,
|
| scope_info.context_slot_name(i),
|
| - Handle<Object>(context->get(context_index)),
|
| + Handle<Object>(context->get(context_index), isolate),
|
| NONE,
|
| kNonStrictMode),
|
| false);
|
| @@ -9399,7 +9819,8 @@
|
|
|
| // Create a plain JSObject which materializes the local scope for the specified
|
| // frame.
|
| -static Handle<JSObject> MaterializeLocalScope(JavaScriptFrame* frame) {
|
| +static Handle<JSObject> MaterializeLocalScope(Isolate* isolate,
|
| + JavaScriptFrame* frame) {
|
| Handle<JSFunction> function(JSFunction::cast(frame->function()));
|
| Handle<SharedFunctionInfo> shared(function->shared());
|
| Handle<SerializedScopeInfo> serialized_scope_info(shared->scope_info());
|
| @@ -9407,14 +9828,16 @@
|
|
|
| // Allocate and initialize a JSObject with all the arguments, stack locals
|
| // heap locals and extension properties of the debugged function.
|
| - Handle<JSObject> local_scope = Factory::NewJSObject(Top::object_function());
|
| + Handle<JSObject> local_scope =
|
| + isolate->factory()->NewJSObject(isolate->object_function());
|
|
|
| // First fill all parameters.
|
| for (int i = 0; i < scope_info.number_of_parameters(); ++i) {
|
| RETURN_IF_EMPTY_HANDLE_VALUE(
|
| + isolate,
|
| SetProperty(local_scope,
|
| scope_info.parameter_name(i),
|
| - Handle<Object>(frame->GetParameter(i)),
|
| + Handle<Object>(frame->GetParameter(i), isolate),
|
| NONE,
|
| kNonStrictMode),
|
| Handle<JSObject>());
|
| @@ -9423,9 +9846,10 @@
|
| // Second fill all stack locals.
|
| for (int i = 0; i < scope_info.number_of_stack_slots(); i++) {
|
| RETURN_IF_EMPTY_HANDLE_VALUE(
|
| + isolate,
|
| SetProperty(local_scope,
|
| scope_info.stack_slot_name(i),
|
| - Handle<Object>(frame->GetExpression(i)),
|
| + Handle<Object>(frame->GetExpression(i), isolate),
|
| NONE,
|
| kNonStrictMode),
|
| Handle<JSObject>());
|
| @@ -9434,7 +9858,8 @@
|
| // Third fill all context locals.
|
| Handle<Context> frame_context(Context::cast(frame->context()));
|
| Handle<Context> function_context(frame_context->fcontext());
|
| - if (!CopyContextLocalsToScopeObject(serialized_scope_info, scope_info,
|
| + if (!CopyContextLocalsToScopeObject(isolate,
|
| + serialized_scope_info, scope_info,
|
| function_context, local_scope)) {
|
| return Handle<JSObject>();
|
| }
|
| @@ -9451,6 +9876,7 @@
|
| ASSERT(keys->get(i)->IsString());
|
| Handle<String> key(String::cast(keys->get(i)));
|
| RETURN_IF_EMPTY_HANDLE_VALUE(
|
| + isolate,
|
| SetProperty(local_scope,
|
| key,
|
| GetProperty(ext, key),
|
| @@ -9466,7 +9892,8 @@
|
|
|
| // Create a plain JSObject which materializes the closure content for the
|
| // context.
|
| -static Handle<JSObject> MaterializeClosure(Handle<Context> context) {
|
| +static Handle<JSObject> MaterializeClosure(Isolate* isolate,
|
| + Handle<Context> context) {
|
| ASSERT(context->is_function_context());
|
|
|
| Handle<SharedFunctionInfo> shared(context->closure()->shared());
|
| @@ -9475,12 +9902,13 @@
|
|
|
| // Allocate and initialize a JSObject with all the content of theis function
|
| // closure.
|
| - Handle<JSObject> closure_scope = Factory::NewJSObject(Top::object_function());
|
| + Handle<JSObject> closure_scope =
|
| + isolate->factory()->NewJSObject(isolate->object_function());
|
|
|
| // Check whether the arguments shadow object exists.
|
| int arguments_shadow_index =
|
| - shared->scope_info()->ContextSlotIndex(Heap::arguments_shadow_symbol(),
|
| - NULL);
|
| + shared->scope_info()->ContextSlotIndex(
|
| + isolate->heap()->arguments_shadow_symbol(), NULL);
|
| if (arguments_shadow_index >= 0) {
|
| // In this case all the arguments are available in the arguments shadow
|
| // object.
|
| @@ -9490,9 +9918,10 @@
|
| // We don't expect exception-throwing getters on the arguments shadow.
|
| Object* element = arguments_shadow->GetElement(i)->ToObjectUnchecked();
|
| RETURN_IF_EMPTY_HANDLE_VALUE(
|
| + isolate,
|
| SetProperty(closure_scope,
|
| scope_info.parameter_name(i),
|
| - Handle<Object>(element),
|
| + Handle<Object>(element, isolate),
|
| NONE,
|
| kNonStrictMode),
|
| Handle<JSObject>());
|
| @@ -9500,7 +9929,8 @@
|
| }
|
|
|
| // Fill all context locals to the context extension.
|
| - if (!CopyContextLocalsToScopeObject(serialized_scope_info, scope_info,
|
| + if (!CopyContextLocalsToScopeObject(isolate,
|
| + serialized_scope_info, scope_info,
|
| context, closure_scope)) {
|
| return Handle<JSObject>();
|
| }
|
| @@ -9514,7 +9944,8 @@
|
| // Names of variables introduced by eval are strings.
|
| ASSERT(keys->get(i)->IsString());
|
| Handle<String> key(String::cast(keys->get(i)));
|
| - RETURN_IF_EMPTY_HANDLE_VALUE(
|
| + RETURN_IF_EMPTY_HANDLE_VALUE(
|
| + isolate,
|
| SetProperty(closure_scope,
|
| key,
|
| GetProperty(ext, key),
|
| @@ -9545,8 +9976,9 @@
|
| ScopeTypeCatch
|
| };
|
|
|
| - explicit ScopeIterator(JavaScriptFrame* frame)
|
| - : frame_(frame),
|
| + ScopeIterator(Isolate* isolate, JavaScriptFrame* frame)
|
| + : isolate_(isolate),
|
| + frame_(frame),
|
| function_(JSFunction::cast(frame->function())),
|
| context_(Context::cast(frame->context())),
|
| local_done_(false),
|
| @@ -9559,7 +9991,7 @@
|
| // Checking for the existence of .result seems fragile, but the scope info
|
| // saved with the code object does not otherwise have that information.
|
| int index = function_->shared()->scope_info()->
|
| - StackSlotIndex(Heap::result_symbol());
|
| + StackSlotIndex(isolate_->heap()->result_symbol());
|
| at_local_ = index < 0;
|
| } else if (context_->is_function_context()) {
|
| at_local_ = true;
|
| @@ -9637,7 +10069,7 @@
|
| break;
|
| case ScopeIterator::ScopeTypeLocal:
|
| // Materialize the content of the local scope into a JSObject.
|
| - return MaterializeLocalScope(frame_);
|
| + return MaterializeLocalScope(isolate_, frame_);
|
| break;
|
| case ScopeIterator::ScopeTypeWith:
|
| case ScopeIterator::ScopeTypeCatch:
|
| @@ -9646,7 +10078,7 @@
|
| break;
|
| case ScopeIterator::ScopeTypeClosure:
|
| // Materialize the content of the closure scope into a JSObject.
|
| - return MaterializeClosure(CurrentContext());
|
| + return MaterializeClosure(isolate_, CurrentContext());
|
| break;
|
| }
|
| UNREACHABLE();
|
| @@ -9725,6 +10157,7 @@
|
| #endif
|
|
|
| private:
|
| + Isolate* isolate_;
|
| JavaScriptFrame* frame_;
|
| Handle<JSFunction> function_;
|
| Handle<Context> context_;
|
| @@ -9735,13 +10168,14 @@
|
| };
|
|
|
|
|
| -static MaybeObject* Runtime_GetScopeCount(Arguments args) {
|
| - HandleScope scope;
|
| +static MaybeObject* Runtime_GetScopeCount(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| + HandleScope scope(isolate);
|
| ASSERT(args.length() == 2);
|
|
|
| // Check arguments.
|
| Object* check;
|
| - { MaybeObject* maybe_check = Runtime_CheckExecutionState(args);
|
| + { MaybeObject* maybe_check = Runtime_CheckExecutionState(args, isolate);
|
| if (!maybe_check->ToObject(&check)) return maybe_check;
|
| }
|
| CONVERT_CHECKED(Smi, wrapped_id, args[1]);
|
| @@ -9753,7 +10187,7 @@
|
|
|
| // Count the visible scopes.
|
| int n = 0;
|
| - for (ScopeIterator it(frame); !it.Done(); it.Next()) {
|
| + for (ScopeIterator it(isolate, frame); !it.Done(); it.Next()) {
|
| n++;
|
| }
|
|
|
| @@ -9773,13 +10207,14 @@
|
| // The array returned contains the following information:
|
| // 0: Scope type
|
| // 1: Scope object
|
| -static MaybeObject* Runtime_GetScopeDetails(Arguments args) {
|
| - HandleScope scope;
|
| +static MaybeObject* Runtime_GetScopeDetails(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| + HandleScope scope(isolate);
|
| ASSERT(args.length() == 3);
|
|
|
| // Check arguments.
|
| Object* check;
|
| - { MaybeObject* maybe_check = Runtime_CheckExecutionState(args);
|
| + { MaybeObject* maybe_check = Runtime_CheckExecutionState(args, isolate);
|
| if (!maybe_check->ToObject(&check)) return maybe_check;
|
| }
|
| CONVERT_CHECKED(Smi, wrapped_id, args[1]);
|
| @@ -9792,57 +10227,60 @@
|
|
|
| // Find the requested scope.
|
| int n = 0;
|
| - ScopeIterator it(frame);
|
| + ScopeIterator it(isolate, frame);
|
| for (; !it.Done() && n < index; it.Next()) {
|
| n++;
|
| }
|
| if (it.Done()) {
|
| - return Heap::undefined_value();
|
| + return isolate->heap()->undefined_value();
|
| }
|
|
|
| // Calculate the size of the result.
|
| int details_size = kScopeDetailsSize;
|
| - Handle<FixedArray> details = Factory::NewFixedArray(details_size);
|
| + Handle<FixedArray> details = isolate->factory()->NewFixedArray(details_size);
|
|
|
| // Fill in scope details.
|
| details->set(kScopeDetailsTypeIndex, Smi::FromInt(it.Type()));
|
| Handle<JSObject> scope_object = it.ScopeObject();
|
| - RETURN_IF_EMPTY_HANDLE(scope_object);
|
| + RETURN_IF_EMPTY_HANDLE(isolate, scope_object);
|
| details->set(kScopeDetailsObjectIndex, *scope_object);
|
|
|
| - return *Factory::NewJSArrayWithElements(details);
|
| + return *isolate->factory()->NewJSArrayWithElements(details);
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_DebugPrintScopes(Arguments args) {
|
| - HandleScope scope;
|
| +static MaybeObject* Runtime_DebugPrintScopes(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| + HandleScope scope(isolate);
|
| ASSERT(args.length() == 0);
|
|
|
| #ifdef DEBUG
|
| // Print the scopes for the top frame.
|
| StackFrameLocator locator;
|
| JavaScriptFrame* frame = locator.FindJavaScriptFrame(0);
|
| - for (ScopeIterator it(frame); !it.Done(); it.Next()) {
|
| + for (ScopeIterator it(isolate, frame); !it.Done(); it.Next()) {
|
| it.DebugPrint();
|
| }
|
| #endif
|
| - return Heap::undefined_value();
|
| + return isolate->heap()->undefined_value();
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_GetThreadCount(Arguments args) {
|
| - HandleScope scope;
|
| +static MaybeObject* Runtime_GetThreadCount(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| + HandleScope scope(isolate);
|
| ASSERT(args.length() == 1);
|
|
|
| // Check arguments.
|
| Object* result;
|
| - { MaybeObject* maybe_result = Runtime_CheckExecutionState(args);
|
| + { MaybeObject* maybe_result = Runtime_CheckExecutionState(args, isolate);
|
| if (!maybe_result->ToObject(&result)) return maybe_result;
|
| }
|
|
|
| // Count all archived V8 threads.
|
| int n = 0;
|
| - for (ThreadState* thread = ThreadState::FirstInUse();
|
| + for (ThreadState* thread =
|
| + isolate->thread_manager()->FirstThreadStateInUse();
|
| thread != NULL;
|
| thread = thread->Next()) {
|
| n++;
|
| @@ -9864,70 +10302,78 @@
|
| // The array returned contains the following information:
|
| // 0: Is current thread?
|
| // 1: Thread id
|
| -static MaybeObject* Runtime_GetThreadDetails(Arguments args) {
|
| - HandleScope scope;
|
| +static MaybeObject* Runtime_GetThreadDetails(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| + HandleScope scope(isolate);
|
| ASSERT(args.length() == 2);
|
|
|
| // Check arguments.
|
| Object* check;
|
| - { MaybeObject* maybe_check = Runtime_CheckExecutionState(args);
|
| + { MaybeObject* maybe_check = Runtime_CheckExecutionState(args, isolate);
|
| if (!maybe_check->ToObject(&check)) return maybe_check;
|
| }
|
| CONVERT_NUMBER_CHECKED(int, index, Int32, args[1]);
|
|
|
| // Allocate array for result.
|
| - Handle<FixedArray> details = Factory::NewFixedArray(kThreadDetailsSize);
|
| + Handle<FixedArray> details =
|
| + isolate->factory()->NewFixedArray(kThreadDetailsSize);
|
|
|
| // Thread index 0 is current thread.
|
| if (index == 0) {
|
| // Fill the details.
|
| - details->set(kThreadDetailsCurrentThreadIndex, Heap::true_value());
|
| + details->set(kThreadDetailsCurrentThreadIndex,
|
| + isolate->heap()->true_value());
|
| details->set(kThreadDetailsThreadIdIndex,
|
| - Smi::FromInt(ThreadManager::CurrentId()));
|
| + Smi::FromInt(
|
| + isolate->thread_manager()->CurrentId()));
|
| } else {
|
| // Find the thread with the requested index.
|
| int n = 1;
|
| - ThreadState* thread = ThreadState::FirstInUse();
|
| + ThreadState* thread =
|
| + isolate->thread_manager()->FirstThreadStateInUse();
|
| while (index != n && thread != NULL) {
|
| thread = thread->Next();
|
| n++;
|
| }
|
| if (thread == NULL) {
|
| - return Heap::undefined_value();
|
| + return isolate->heap()->undefined_value();
|
| }
|
|
|
| // Fill the details.
|
| - details->set(kThreadDetailsCurrentThreadIndex, Heap::false_value());
|
| + details->set(kThreadDetailsCurrentThreadIndex,
|
| + isolate->heap()->false_value());
|
| details->set(kThreadDetailsThreadIdIndex, Smi::FromInt(thread->id()));
|
| }
|
|
|
| // Convert to JS array and return.
|
| - return *Factory::NewJSArrayWithElements(details);
|
| + return *isolate->factory()->NewJSArrayWithElements(details);
|
| }
|
|
|
|
|
| // Sets the disable break state
|
| // args[0]: disable break state
|
| -static MaybeObject* Runtime_SetDisableBreak(Arguments args) {
|
| - HandleScope scope;
|
| +static MaybeObject* Runtime_SetDisableBreak(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| + HandleScope scope(isolate);
|
| ASSERT(args.length() == 1);
|
| CONVERT_BOOLEAN_CHECKED(disable_break, args[0]);
|
| - Debug::set_disable_break(disable_break);
|
| - return Heap::undefined_value();
|
| + isolate->debug()->set_disable_break(disable_break);
|
| + return isolate->heap()->undefined_value();
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_GetBreakLocations(Arguments args) {
|
| - HandleScope scope;
|
| +static MaybeObject* Runtime_GetBreakLocations(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| + HandleScope scope(isolate);
|
| ASSERT(args.length() == 1);
|
|
|
| CONVERT_ARG_CHECKED(JSFunction, fun, 0);
|
| Handle<SharedFunctionInfo> shared(fun->shared());
|
| // Find the number of break points
|
| Handle<Object> break_locations = Debug::GetSourceBreakLocations(shared);
|
| - if (break_locations->IsUndefined()) return Heap::undefined_value();
|
| + if (break_locations->IsUndefined()) return isolate->heap()->undefined_value();
|
| // Return array as JS array
|
| - return *Factory::NewJSArrayWithElements(
|
| + return *isolate->factory()->NewJSArrayWithElements(
|
| Handle<FixedArray>::cast(break_locations));
|
| }
|
|
|
| @@ -9936,8 +10382,9 @@
|
| // args[0]: function
|
| // args[1]: number: break source position (within the function source)
|
| // args[2]: number: break point object
|
| -static MaybeObject* Runtime_SetFunctionBreakPoint(Arguments args) {
|
| - HandleScope scope;
|
| +static MaybeObject* Runtime_SetFunctionBreakPoint(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| + HandleScope scope(isolate);
|
| ASSERT(args.length() == 3);
|
| CONVERT_ARG_CHECKED(JSFunction, fun, 0);
|
| Handle<SharedFunctionInfo> shared(fun->shared());
|
| @@ -9946,13 +10393,15 @@
|
| Handle<Object> break_point_object_arg = args.at<Object>(2);
|
|
|
| // Set break point.
|
| - Debug::SetBreakPoint(shared, break_point_object_arg, &source_position);
|
| + isolate->debug()->SetBreakPoint(shared, break_point_object_arg,
|
| + &source_position);
|
|
|
| return Smi::FromInt(source_position);
|
| }
|
|
|
|
|
| -Object* Runtime::FindSharedFunctionInfoInScript(Handle<Script> script,
|
| +Object* Runtime::FindSharedFunctionInfoInScript(Isolate* isolate,
|
| + Handle<Script> script,
|
| int position) {
|
| // Iterate the heap looking for SharedFunctionInfo generated from the
|
| // script. The inner most SharedFunctionInfo containing the source position
|
| @@ -10011,7 +10460,7 @@
|
| }
|
|
|
| if (target.is_null()) {
|
| - return Heap::undefined_value();
|
| + return isolate->heap()->undefined_value();
|
| }
|
|
|
| // If the candidate found is compiled we are done. NOTE: when lazy
|
| @@ -10035,8 +10484,9 @@
|
| // args[0]: script to set break point in
|
| // args[1]: number: break source position (within the script source)
|
| // args[2]: number: break point object
|
| -static MaybeObject* Runtime_SetScriptBreakPoint(Arguments args) {
|
| - HandleScope scope;
|
| +static MaybeObject* Runtime_SetScriptBreakPoint(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| + HandleScope scope(isolate);
|
| ASSERT(args.length() == 3);
|
| CONVERT_ARG_CHECKED(JSValue, wrapper, 0);
|
| CONVERT_NUMBER_CHECKED(int32_t, source_position, Int32, args[1]);
|
| @@ -10048,7 +10498,7 @@
|
| Handle<Script> script(Script::cast(wrapper->value()));
|
|
|
| Object* result = Runtime::FindSharedFunctionInfoInScript(
|
| - script, source_position);
|
| + isolate, script, source_position);
|
| if (!result->IsUndefined()) {
|
| Handle<SharedFunctionInfo> shared(SharedFunctionInfo::cast(result));
|
| // Find position within function. The script position might be before the
|
| @@ -10059,33 +10509,35 @@
|
| } else {
|
| position = source_position - shared->start_position();
|
| }
|
| - Debug::SetBreakPoint(shared, break_point_object_arg, &position);
|
| + isolate->debug()->SetBreakPoint(shared, break_point_object_arg, &position);
|
| position += shared->start_position();
|
| return Smi::FromInt(position);
|
| }
|
| - return Heap::undefined_value();
|
| + return isolate->heap()->undefined_value();
|
| }
|
|
|
|
|
| // Clear a break point
|
| // args[0]: number: break point object
|
| -static MaybeObject* Runtime_ClearBreakPoint(Arguments args) {
|
| - HandleScope scope;
|
| +static MaybeObject* Runtime_ClearBreakPoint(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| + HandleScope scope(isolate);
|
| ASSERT(args.length() == 1);
|
| Handle<Object> break_point_object_arg = args.at<Object>(0);
|
|
|
| // Clear break point.
|
| - Debug::ClearBreakPoint(break_point_object_arg);
|
| + isolate->debug()->ClearBreakPoint(break_point_object_arg);
|
|
|
| - return Heap::undefined_value();
|
| + return isolate->heap()->undefined_value();
|
| }
|
|
|
|
|
| // Change the state of break on exceptions.
|
| // args[0]: Enum value indicating whether to affect caught/uncaught exceptions.
|
| // args[1]: Boolean indicating on/off.
|
| -static MaybeObject* Runtime_ChangeBreakOnException(Arguments args) {
|
| - HandleScope scope;
|
| +static MaybeObject* Runtime_ChangeBreakOnException(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| + HandleScope scope(isolate);
|
| ASSERT(args.length() == 2);
|
| RUNTIME_ASSERT(args[0]->IsNumber());
|
| CONVERT_BOOLEAN_CHECKED(enable, args[1]);
|
| @@ -10095,21 +10547,22 @@
|
| ExceptionBreakType type =
|
| static_cast<ExceptionBreakType>(NumberToUint32(args[0]));
|
| // Update break point state.
|
| - Debug::ChangeBreakOnException(type, enable);
|
| - return Heap::undefined_value();
|
| + isolate->debug()->ChangeBreakOnException(type, enable);
|
| + return isolate->heap()->undefined_value();
|
| }
|
|
|
|
|
| // Returns the state of break on exceptions
|
| // args[0]: boolean indicating uncaught exceptions
|
| -static MaybeObject* Runtime_IsBreakOnException(Arguments args) {
|
| - HandleScope scope;
|
| +static MaybeObject* Runtime_IsBreakOnException(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| + HandleScope scope(isolate);
|
| ASSERT(args.length() == 1);
|
| RUNTIME_ASSERT(args[0]->IsNumber());
|
|
|
| ExceptionBreakType type =
|
| static_cast<ExceptionBreakType>(NumberToUint32(args[0]));
|
| - bool result = Debug::IsBreakOnException(type);
|
| + bool result = isolate->debug()->IsBreakOnException(type);
|
| return Smi::FromInt(result);
|
| }
|
|
|
| @@ -10119,16 +10572,17 @@
|
| // args[1]: step action from the enumeration StepAction
|
| // args[2]: number of times to perform the step, for step out it is the number
|
| // of frames to step down.
|
| -static MaybeObject* Runtime_PrepareStep(Arguments args) {
|
| - HandleScope scope;
|
| +static MaybeObject* Runtime_PrepareStep(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| + HandleScope scope(isolate);
|
| ASSERT(args.length() == 3);
|
| // Check arguments.
|
| Object* check;
|
| - { MaybeObject* maybe_check = Runtime_CheckExecutionState(args);
|
| + { MaybeObject* maybe_check = Runtime_CheckExecutionState(args, isolate);
|
| if (!maybe_check->ToObject(&check)) return maybe_check;
|
| }
|
| if (!args[1]->IsNumber() || !args[2]->IsNumber()) {
|
| - return Top::Throw(Heap::illegal_argument_symbol());
|
| + return isolate->Throw(isolate->heap()->illegal_argument_symbol());
|
| }
|
|
|
| // Get the step action and check validity.
|
| @@ -10138,30 +10592,32 @@
|
| step_action != StepOut &&
|
| step_action != StepInMin &&
|
| step_action != StepMin) {
|
| - return Top::Throw(Heap::illegal_argument_symbol());
|
| + return isolate->Throw(isolate->heap()->illegal_argument_symbol());
|
| }
|
|
|
| // Get the number of steps.
|
| int step_count = NumberToInt32(args[2]);
|
| if (step_count < 1) {
|
| - return Top::Throw(Heap::illegal_argument_symbol());
|
| + return isolate->Throw(isolate->heap()->illegal_argument_symbol());
|
| }
|
|
|
| // Clear all current stepping setup.
|
| - Debug::ClearStepping();
|
| + isolate->debug()->ClearStepping();
|
|
|
| // Prepare step.
|
| - Debug::PrepareStep(static_cast<StepAction>(step_action), step_count);
|
| - return Heap::undefined_value();
|
| + isolate->debug()->PrepareStep(static_cast<StepAction>(step_action),
|
| + step_count);
|
| + return isolate->heap()->undefined_value();
|
| }
|
|
|
|
|
| // Clear all stepping set by PrepareStep.
|
| -static MaybeObject* Runtime_ClearStepping(Arguments args) {
|
| - HandleScope scope;
|
| +static MaybeObject* Runtime_ClearStepping(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| + HandleScope scope(isolate);
|
| ASSERT(args.length() == 0);
|
| - Debug::ClearStepping();
|
| - return Heap::undefined_value();
|
| + isolate->debug()->ClearStepping();
|
| + return isolate->heap()->undefined_value();
|
| }
|
|
|
|
|
| @@ -10178,15 +10634,15 @@
|
| Handle<Context> previous(context_chain->previous());
|
| Handle<JSObject> extension(JSObject::cast(context_chain->extension()));
|
| Handle<Context> context = CopyWithContextChain(function_context, previous);
|
| - return Factory::NewWithContext(context,
|
| - extension,
|
| - context_chain->IsCatchContext());
|
| + return context->GetIsolate()->factory()->NewWithContext(
|
| + context, extension, context_chain->IsCatchContext());
|
| }
|
|
|
|
|
| // Helper function to find or create the arguments object for
|
| // Runtime_DebugEvaluate.
|
| -static Handle<Object> GetArgumentsObject(JavaScriptFrame* frame,
|
| +static Handle<Object> GetArgumentsObject(Isolate* isolate,
|
| + JavaScriptFrame* frame,
|
| Handle<JSFunction> function,
|
| Handle<SerializedScopeInfo> scope_info,
|
| const ScopeInfo<>* sinfo,
|
| @@ -10196,22 +10652,24 @@
|
| // does not support eval) then create an 'arguments' object.
|
| int index;
|
| if (sinfo->number_of_stack_slots() > 0) {
|
| - index = scope_info->StackSlotIndex(Heap::arguments_symbol());
|
| + index = scope_info->StackSlotIndex(isolate->heap()->arguments_symbol());
|
| if (index != -1) {
|
| - return Handle<Object>(frame->GetExpression(index));
|
| + return Handle<Object>(frame->GetExpression(index), isolate);
|
| }
|
| }
|
|
|
| if (sinfo->number_of_context_slots() > Context::MIN_CONTEXT_SLOTS) {
|
| - index = scope_info->ContextSlotIndex(Heap::arguments_symbol(), NULL);
|
| + index = scope_info->ContextSlotIndex(isolate->heap()->arguments_symbol(),
|
| + NULL);
|
| if (index != -1) {
|
| - return Handle<Object>(function_context->get(index));
|
| + return Handle<Object>(function_context->get(index), isolate);
|
| }
|
| }
|
|
|
| const int length = frame->ComputeParametersCount();
|
| - Handle<JSObject> arguments = Factory::NewArgumentsObject(function, length);
|
| - Handle<FixedArray> array = Factory::NewFixedArray(length);
|
| + Handle<JSObject> arguments =
|
| + isolate->factory()->NewArgumentsObject(function, length);
|
| + Handle<FixedArray> array = isolate->factory()->NewFixedArray(length);
|
|
|
| AssertNoAllocation no_gc;
|
| WriteBarrierMode mode = array->GetWriteBarrierMode(no_gc);
|
| @@ -10223,6 +10681,10 @@
|
| }
|
|
|
|
|
| +static const char kSourceStr[] =
|
| + "(function(arguments,__source__){return eval(__source__);})";
|
| +
|
| +
|
| // Evaluate a piece of JavaScript in the context of a stack frame for
|
| // debugging. This is accomplished by creating a new context which in its
|
| // extension part has all the parameters and locals of the function on the
|
| @@ -10234,14 +10696,16 @@
|
| // stack frame presenting the same view of the values of parameters and
|
| // local variables as if the piece of JavaScript was evaluated at the point
|
| // where the function on the stack frame is currently stopped.
|
| -static MaybeObject* Runtime_DebugEvaluate(Arguments args) {
|
| - HandleScope scope;
|
| +static MaybeObject* Runtime_DebugEvaluate(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| + HandleScope scope(isolate);
|
|
|
| // Check the execution state and decode arguments frame and source to be
|
| // evaluated.
|
| ASSERT(args.length() == 5);
|
| Object* check_result;
|
| - { MaybeObject* maybe_check_result = Runtime_CheckExecutionState(args);
|
| + { MaybeObject* maybe_check_result = Runtime_CheckExecutionState(args,
|
| + isolate);
|
| if (!maybe_check_result->ToObject(&check_result)) {
|
| return maybe_check_result;
|
| }
|
| @@ -10264,13 +10728,13 @@
|
|
|
| // Traverse the saved contexts chain to find the active context for the
|
| // selected frame.
|
| - SaveContext* save = Top::save_context();
|
| + SaveContext* save = isolate->save_context();
|
| while (save != NULL && !save->below(frame)) {
|
| save = save->prev();
|
| }
|
| ASSERT(save != NULL);
|
| - SaveContext savex;
|
| - Top::set_context(*(save->context()));
|
| + SaveContext savex(isolate);
|
| + isolate->set_context(*(save->context()));
|
|
|
| // Create the (empty) function replacing the function on the stack frame for
|
| // the purpose of evaluating in the context created below. It is important
|
| @@ -10279,7 +10743,8 @@
|
| // in Context::Lookup, where context slots for parameters and local variables
|
| // are looked at before the extension object.
|
| Handle<JSFunction> go_between =
|
| - Factory::NewFunction(Factory::empty_string(), Factory::undefined_value());
|
| + isolate->factory()->NewFunction(isolate->factory()->empty_string(),
|
| + isolate->factory()->undefined_value());
|
| go_between->set_context(function->context());
|
| #ifdef DEBUG
|
| ScopeInfo<> go_between_sinfo(go_between->shared()->scope_info());
|
| @@ -10288,13 +10753,14 @@
|
| #endif
|
|
|
| // Materialize the content of the local scope into a JSObject.
|
| - Handle<JSObject> local_scope = MaterializeLocalScope(frame);
|
| - RETURN_IF_EMPTY_HANDLE(local_scope);
|
| + Handle<JSObject> local_scope = MaterializeLocalScope(isolate, frame);
|
| + RETURN_IF_EMPTY_HANDLE(isolate, local_scope);
|
|
|
| // Allocate a new context for the debug evaluation and set the extension
|
| // object build.
|
| Handle<Context> context =
|
| - Factory::NewFunctionContext(Context::MIN_CONTEXT_SLOTS, go_between);
|
| + isolate->factory()->NewFunctionContext(Context::MIN_CONTEXT_SLOTS,
|
| + go_between);
|
| context->set_extension(*local_scope);
|
| // Copy any with contexts present and chain them in front of this context.
|
| Handle<Context> frame_context(Context::cast(frame->context()));
|
| @@ -10302,7 +10768,7 @@
|
| context = CopyWithContextChain(frame_context, context);
|
|
|
| if (additional_context->IsJSObject()) {
|
| - context = Factory::NewWithContext(context,
|
| + context = isolate->factory()->NewWithContext(context,
|
| Handle<JSObject>::cast(additional_context), false);
|
| }
|
|
|
| @@ -10311,12 +10777,10 @@
|
| // 'arguments'. This it to have access to what would have been 'arguments' in
|
| // the function being debugged.
|
| // function(arguments,__source__) {return eval(__source__);}
|
| - static const char* source_str =
|
| - "(function(arguments,__source__){return eval(__source__);})";
|
| - static const int source_str_length = StrLength(source_str);
|
| +
|
| Handle<String> function_source =
|
| - Factory::NewStringFromAscii(Vector<const char>(source_str,
|
| - source_str_length));
|
| + isolate->factory()->NewStringFromAscii(
|
| + Vector<const char>(kSourceStr, sizeof(kSourceStr) - 1));
|
|
|
| // Currently, the eval code will be executed in non-strict mode,
|
| // even in the strict code context.
|
| @@ -10327,17 +10791,18 @@
|
| kNonStrictMode);
|
| if (shared.is_null()) return Failure::Exception();
|
| Handle<JSFunction> compiled_function =
|
| - Factory::NewFunctionFromSharedFunctionInfo(shared, context);
|
| + isolate->factory()->NewFunctionFromSharedFunctionInfo(shared, context);
|
|
|
| // Invoke the result of the compilation to get the evaluation function.
|
| bool has_pending_exception;
|
| - Handle<Object> receiver(frame->receiver());
|
| + Handle<Object> receiver(frame->receiver(), isolate);
|
| Handle<Object> evaluation_function =
|
| Execution::Call(compiled_function, receiver, 0, NULL,
|
| &has_pending_exception);
|
| if (has_pending_exception) return Failure::Exception();
|
|
|
| - Handle<Object> arguments = GetArgumentsObject(frame, function, scope_info,
|
| + Handle<Object> arguments = GetArgumentsObject(isolate, frame,
|
| + function, scope_info,
|
| &sinfo, function_context);
|
|
|
| // Invoke the evaluation function and return the result.
|
| @@ -10359,14 +10824,16 @@
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_DebugEvaluateGlobal(Arguments args) {
|
| - HandleScope scope;
|
| +static MaybeObject* Runtime_DebugEvaluateGlobal(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| + HandleScope scope(isolate);
|
|
|
| // Check the execution state and decode arguments frame and source to be
|
| // evaluated.
|
| ASSERT(args.length() == 4);
|
| Object* check_result;
|
| - { MaybeObject* maybe_check_result = Runtime_CheckExecutionState(args);
|
| + { MaybeObject* maybe_check_result = Runtime_CheckExecutionState(args,
|
| + isolate);
|
| if (!maybe_check_result->ToObject(&check_result)) {
|
| return maybe_check_result;
|
| }
|
| @@ -10379,28 +10846,30 @@
|
| DisableBreak disable_break_save(disable_break);
|
|
|
| // Enter the top context from before the debugger was invoked.
|
| - SaveContext save;
|
| + SaveContext save(isolate);
|
| SaveContext* top = &save;
|
| - while (top != NULL && *top->context() == *Debug::debug_context()) {
|
| + while (top != NULL && *top->context() == *isolate->debug()->debug_context()) {
|
| top = top->prev();
|
| }
|
| if (top != NULL) {
|
| - Top::set_context(*top->context());
|
| + isolate->set_context(*top->context());
|
| }
|
|
|
| // Get the global context now set to the top context from before the
|
| // debugger was invoked.
|
| - Handle<Context> context = Top::global_context();
|
| + Handle<Context> context = isolate->global_context();
|
|
|
| bool is_global = true;
|
|
|
| if (additional_context->IsJSObject()) {
|
| // Create a function context first, than put 'with' context on top of it.
|
| - Handle<JSFunction> go_between = Factory::NewFunction(
|
| - Factory::empty_string(), Factory::undefined_value());
|
| + Handle<JSFunction> go_between = isolate->factory()->NewFunction(
|
| + isolate->factory()->empty_string(),
|
| + isolate->factory()->undefined_value());
|
| go_between->set_context(*context);
|
| context =
|
| - Factory::NewFunctionContext(Context::MIN_CONTEXT_SLOTS, go_between);
|
| + isolate->factory()->NewFunctionContext(
|
| + Context::MIN_CONTEXT_SLOTS, go_between);
|
| context->set_extension(JSObject::cast(*additional_context));
|
| is_global = false;
|
| }
|
| @@ -10412,12 +10881,13 @@
|
| Compiler::CompileEval(source, context, is_global, kNonStrictMode);
|
| if (shared.is_null()) return Failure::Exception();
|
| Handle<JSFunction> compiled_function =
|
| - Handle<JSFunction>(Factory::NewFunctionFromSharedFunctionInfo(shared,
|
| - context));
|
| + Handle<JSFunction>(
|
| + isolate->factory()->NewFunctionFromSharedFunctionInfo(shared,
|
| + context));
|
|
|
| // Invoke the result of the compilation to get the evaluation function.
|
| bool has_pending_exception;
|
| - Handle<Object> receiver = Top::global();
|
| + Handle<Object> receiver = isolate->global();
|
| Handle<Object> result =
|
| Execution::Call(compiled_function, receiver, 0, NULL,
|
| &has_pending_exception);
|
| @@ -10426,12 +10896,13 @@
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_DebugGetLoadedScripts(Arguments args) {
|
| - HandleScope scope;
|
| +static MaybeObject* Runtime_DebugGetLoadedScripts(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| + HandleScope scope(isolate);
|
| ASSERT(args.length() == 0);
|
|
|
| // Fill the script objects.
|
| - Handle<FixedArray> instances = Debug::GetLoadedScripts();
|
| + Handle<FixedArray> instances = isolate->debug()->GetLoadedScripts();
|
|
|
| // Convert the script objects to proper JS objects.
|
| for (int i = 0; i < instances->length(); i++) {
|
| @@ -10446,7 +10917,8 @@
|
| }
|
|
|
| // Return result as a JS array.
|
| - Handle<JSObject> result = Factory::NewJSObject(Top::array_function());
|
| + Handle<JSObject> result =
|
| + isolate->factory()->NewJSObject(isolate->array_function());
|
| Handle<JSArray>::cast(result)->SetContent(*instances);
|
| return *result;
|
| }
|
| @@ -10526,11 +10998,12 @@
|
| // args[0]: the object to find references to
|
| // args[1]: constructor function for instances to exclude (Mirror)
|
| // args[2]: the the maximum number of objects to return
|
| -static MaybeObject* Runtime_DebugReferencedBy(Arguments args) {
|
| +static MaybeObject* Runtime_DebugReferencedBy(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| ASSERT(args.length() == 3);
|
|
|
| // First perform a full GC in order to avoid references from dead objects.
|
| - Heap::CollectAllGarbage(false);
|
| + isolate->heap()->CollectAllGarbage(false);
|
|
|
| // Check parameters.
|
| CONVERT_CHECKED(JSObject, target, args[0]);
|
| @@ -10542,7 +11015,7 @@
|
|
|
| // Get the constructor function for context extension and arguments array.
|
| JSObject* arguments_boilerplate =
|
| - Top::context()->global_context()->arguments_boilerplate();
|
| + isolate->context()->global_context()->arguments_boilerplate();
|
| JSFunction* arguments_function =
|
| JSFunction::cast(arguments_boilerplate->map()->constructor());
|
|
|
| @@ -10553,7 +11026,7 @@
|
|
|
| // Allocate an array to hold the result.
|
| Object* object;
|
| - { MaybeObject* maybe_object = Heap::AllocateFixedArray(count);
|
| + { MaybeObject* maybe_object = isolate->heap()->AllocateFixedArray(count);
|
| if (!maybe_object->ToObject(&object)) return maybe_object;
|
| }
|
| FixedArray* instances = FixedArray::cast(object);
|
| @@ -10564,8 +11037,8 @@
|
|
|
| // Return result as JS array.
|
| Object* result;
|
| - { MaybeObject* maybe_result = Heap::AllocateJSObject(
|
| - Top::context()->global_context()->array_function());
|
| + { MaybeObject* maybe_result = isolate->heap()->AllocateJSObject(
|
| + isolate->context()->global_context()->array_function());
|
| if (!maybe_result->ToObject(&result)) return maybe_result;
|
| }
|
| JSArray::cast(result)->SetContent(instances);
|
| @@ -10606,11 +11079,12 @@
|
| // Scan the heap for objects constructed by a specific function.
|
| // args[0]: the constructor to find instances of
|
| // args[1]: the the maximum number of objects to return
|
| -static MaybeObject* Runtime_DebugConstructedBy(Arguments args) {
|
| +static MaybeObject* Runtime_DebugConstructedBy(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| ASSERT(args.length() == 2);
|
|
|
| // First perform a full GC in order to avoid dead objects.
|
| - Heap::CollectAllGarbage(false);
|
| + isolate->heap()->CollectAllGarbage(false);
|
|
|
| // Check parameters.
|
| CONVERT_CHECKED(JSFunction, constructor, args[0]);
|
| @@ -10623,7 +11097,7 @@
|
|
|
| // Allocate an array to hold the result.
|
| Object* object;
|
| - { MaybeObject* maybe_object = Heap::AllocateFixedArray(count);
|
| + { MaybeObject* maybe_object = isolate->heap()->AllocateFixedArray(count);
|
| if (!maybe_object->ToObject(&object)) return maybe_object;
|
| }
|
| FixedArray* instances = FixedArray::cast(object);
|
| @@ -10633,8 +11107,8 @@
|
|
|
| // Return result as JS array.
|
| Object* result;
|
| - { MaybeObject* maybe_result = Heap::AllocateJSObject(
|
| - Top::context()->global_context()->array_function());
|
| + { MaybeObject* maybe_result = isolate->heap()->AllocateJSObject(
|
| + isolate->context()->global_context()->array_function());
|
| if (!maybe_result->ToObject(&result)) return maybe_result;
|
| }
|
| JSArray::cast(result)->SetContent(instances);
|
| @@ -10644,7 +11118,8 @@
|
|
|
| // Find the effective prototype object as returned by __proto__.
|
| // args[0]: the object to find the prototype for.
|
| -static MaybeObject* Runtime_DebugGetPrototype(Arguments args) {
|
| +static MaybeObject* Runtime_DebugGetPrototype(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| ASSERT(args.length() == 1);
|
|
|
| CONVERT_CHECKED(JSObject, obj, args[0]);
|
| @@ -10654,16 +11129,19 @@
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_SystemBreak(Arguments args) {
|
| +static MaybeObject* Runtime_SystemBreak(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| ASSERT(args.length() == 0);
|
| CPU::DebugBreak();
|
| - return Heap::undefined_value();
|
| + return isolate->heap()->undefined_value();
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_DebugDisassembleFunction(Arguments args) {
|
| +static MaybeObject* Runtime_DebugDisassembleFunction(
|
| + RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| #ifdef DEBUG
|
| - HandleScope scope;
|
| + HandleScope scope(isolate);
|
| ASSERT(args.length() == 1);
|
| // Get the function and make sure it is compiled.
|
| CONVERT_ARG_CHECKED(JSFunction, func, 0);
|
| @@ -10673,13 +11151,15 @@
|
| }
|
| func->code()->PrintLn();
|
| #endif // DEBUG
|
| - return Heap::undefined_value();
|
| + return isolate->heap()->undefined_value();
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_DebugDisassembleConstructor(Arguments args) {
|
| +static MaybeObject* Runtime_DebugDisassembleConstructor(
|
| + RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| #ifdef DEBUG
|
| - HandleScope scope;
|
| + HandleScope scope(isolate);
|
| ASSERT(args.length() == 1);
|
| // Get the function and make sure it is compiled.
|
| CONVERT_ARG_CHECKED(JSFunction, func, 0);
|
| @@ -10689,11 +11169,13 @@
|
| }
|
| shared->construct_stub()->PrintLn();
|
| #endif // DEBUG
|
| - return Heap::undefined_value();
|
| + return isolate->heap()->undefined_value();
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_FunctionGetInferredName(Arguments args) {
|
| +static MaybeObject* Runtime_FunctionGetInferredName(
|
| + RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 1);
|
|
|
| @@ -10703,7 +11185,7 @@
|
|
|
|
|
| static int FindSharedFunctionInfosForScript(Script* script,
|
| - FixedArray* buffer) {
|
| + FixedArray* buffer) {
|
| AssertNoAllocation no_allocations;
|
|
|
| int counter = 0;
|
| @@ -10730,9 +11212,10 @@
|
| // to this script. Returns JSArray of SharedFunctionInfo wrapped
|
| // in OpaqueReferences.
|
| static MaybeObject* Runtime_LiveEditFindSharedFunctionInfosForScript(
|
| - Arguments args) {
|
| + RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| ASSERT(args.length() == 1);
|
| - HandleScope scope;
|
| + HandleScope scope(isolate);
|
| CONVERT_CHECKED(JSValue, script_value, args[0]);
|
|
|
| Handle<Script> script = Handle<Script>(Script::cast(script_value->value()));
|
| @@ -10740,14 +11223,14 @@
|
| const int kBufferSize = 32;
|
|
|
| Handle<FixedArray> array;
|
| - array = Factory::NewFixedArray(kBufferSize);
|
| + array = isolate->factory()->NewFixedArray(kBufferSize);
|
| int number = FindSharedFunctionInfosForScript(*script, *array);
|
| if (number > kBufferSize) {
|
| - array = Factory::NewFixedArray(number);
|
| + array = isolate->factory()->NewFixedArray(number);
|
| FindSharedFunctionInfosForScript(*script, *array);
|
| }
|
|
|
| - Handle<JSArray> result = Factory::NewJSArrayWithElements(array);
|
| + Handle<JSArray> result = isolate->factory()->NewJSArrayWithElements(array);
|
| result->set_length(Smi::FromInt(number));
|
|
|
| LiveEdit::WrapSharedFunctionInfos(result);
|
| @@ -10762,16 +11245,18 @@
|
| // Returns a JSArray of compilation infos. The array is ordered so that
|
| // each function with all its descendant is always stored in a continues range
|
| // with the function itself going first. The root function is a script function.
|
| -static MaybeObject* Runtime_LiveEditGatherCompileInfo(Arguments args) {
|
| +static MaybeObject* Runtime_LiveEditGatherCompileInfo(
|
| + RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| ASSERT(args.length() == 2);
|
| - HandleScope scope;
|
| + HandleScope scope(isolate);
|
| CONVERT_CHECKED(JSValue, script, args[0]);
|
| CONVERT_ARG_CHECKED(String, source, 1);
|
| Handle<Script> script_handle = Handle<Script>(Script::cast(script->value()));
|
|
|
| JSArray* result = LiveEdit::GatherCompileInfo(script_handle, source);
|
|
|
| - if (Top::has_pending_exception()) {
|
| + if (isolate->has_pending_exception()) {
|
| return Failure::Exception();
|
| }
|
|
|
| @@ -10781,12 +11266,13 @@
|
| // Changes the source of the script to a new_source.
|
| // If old_script_name is provided (i.e. is a String), also creates a copy of
|
| // the script with its original source and sends notification to debugger.
|
| -static MaybeObject* Runtime_LiveEditReplaceScript(Arguments args) {
|
| +static MaybeObject* Runtime_LiveEditReplaceScript(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| ASSERT(args.length() == 3);
|
| - HandleScope scope;
|
| + HandleScope scope(isolate);
|
| CONVERT_CHECKED(JSValue, original_script_value, args[0]);
|
| CONVERT_ARG_CHECKED(String, new_source, 1);
|
| - Handle<Object> old_script_name(args[2]);
|
| + Handle<Object> old_script_name(args[2], isolate);
|
|
|
| CONVERT_CHECKED(Script, original_script_pointer,
|
| original_script_value->value());
|
| @@ -10800,23 +11286,27 @@
|
| Handle<Script> script_handle(Script::cast(old_script));
|
| return *(GetScriptWrapper(script_handle));
|
| } else {
|
| - return Heap::null_value();
|
| + return isolate->heap()->null_value();
|
| }
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_LiveEditFunctionSourceUpdated(Arguments args) {
|
| +static MaybeObject* Runtime_LiveEditFunctionSourceUpdated(
|
| + RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| ASSERT(args.length() == 1);
|
| - HandleScope scope;
|
| + HandleScope scope(isolate);
|
| CONVERT_ARG_CHECKED(JSArray, shared_info, 0);
|
| return LiveEdit::FunctionSourceUpdated(shared_info);
|
| }
|
|
|
|
|
| // Replaces code of SharedFunctionInfo with a new one.
|
| -static MaybeObject* Runtime_LiveEditReplaceFunctionCode(Arguments args) {
|
| +static MaybeObject* Runtime_LiveEditReplaceFunctionCode(
|
| + RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| ASSERT(args.length() == 2);
|
| - HandleScope scope;
|
| + HandleScope scope(isolate);
|
| CONVERT_ARG_CHECKED(JSArray, new_compile_info, 0);
|
| CONVERT_ARG_CHECKED(JSArray, shared_info, 1);
|
|
|
| @@ -10824,17 +11314,19 @@
|
| }
|
|
|
| // Connects SharedFunctionInfo to another script.
|
| -static MaybeObject* Runtime_LiveEditFunctionSetScript(Arguments args) {
|
| +static MaybeObject* Runtime_LiveEditFunctionSetScript(
|
| + RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| ASSERT(args.length() == 2);
|
| - HandleScope scope;
|
| - Handle<Object> function_object(args[0]);
|
| - Handle<Object> script_object(args[1]);
|
| + HandleScope scope(isolate);
|
| + Handle<Object> function_object(args[0], isolate);
|
| + Handle<Object> script_object(args[1], isolate);
|
|
|
| if (function_object->IsJSValue()) {
|
| Handle<JSValue> function_wrapper = Handle<JSValue>::cast(function_object);
|
| if (script_object->IsJSValue()) {
|
| CONVERT_CHECKED(Script, script, JSValue::cast(*script_object)->value());
|
| - script_object = Handle<Object>(script);
|
| + script_object = Handle<Object>(script, isolate);
|
| }
|
|
|
| LiveEdit::SetFunctionScript(function_wrapper, script_object);
|
| @@ -10843,15 +11335,17 @@
|
| // and we check it in this function.
|
| }
|
|
|
| - return Heap::undefined_value();
|
| + return isolate->heap()->undefined_value();
|
| }
|
|
|
|
|
| // In a code of a parent function replaces original function as embedded object
|
| // with a substitution one.
|
| -static MaybeObject* Runtime_LiveEditReplaceRefToNestedFunction(Arguments args) {
|
| +static MaybeObject* Runtime_LiveEditReplaceRefToNestedFunction(
|
| + RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| ASSERT(args.length() == 3);
|
| - HandleScope scope;
|
| + HandleScope scope(isolate);
|
|
|
| CONVERT_ARG_CHECKED(JSValue, parent_wrapper, 0);
|
| CONVERT_ARG_CHECKED(JSValue, orig_wrapper, 1);
|
| @@ -10860,7 +11354,7 @@
|
| LiveEdit::ReplaceRefToNestedFunction(parent_wrapper, orig_wrapper,
|
| subst_wrapper);
|
|
|
| - return Heap::undefined_value();
|
| + return isolate->heap()->undefined_value();
|
| }
|
|
|
|
|
| @@ -10869,9 +11363,11 @@
|
| // array of groups of 3 numbers:
|
| // (change_begin, change_end, change_end_new_position).
|
| // Each group describes a change in text; groups are sorted by change_begin.
|
| -static MaybeObject* Runtime_LiveEditPatchFunctionPositions(Arguments args) {
|
| +static MaybeObject* Runtime_LiveEditPatchFunctionPositions(
|
| + RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| ASSERT(args.length() == 2);
|
| - HandleScope scope;
|
| + HandleScope scope(isolate);
|
| CONVERT_ARG_CHECKED(JSArray, shared_array, 0);
|
| CONVERT_ARG_CHECKED(JSArray, position_change_array, 1);
|
|
|
| @@ -10883,9 +11379,11 @@
|
| // checks that none of them have activations on stacks (of any thread).
|
| // Returns array of the same length with corresponding results of
|
| // LiveEdit::FunctionPatchabilityStatus type.
|
| -static MaybeObject* Runtime_LiveEditCheckAndDropActivations(Arguments args) {
|
| +static MaybeObject* Runtime_LiveEditCheckAndDropActivations(
|
| + RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| ASSERT(args.length() == 2);
|
| - HandleScope scope;
|
| + HandleScope scope(isolate);
|
| CONVERT_ARG_CHECKED(JSArray, shared_array, 0);
|
| CONVERT_BOOLEAN_CHECKED(do_drop, args[1]);
|
|
|
| @@ -10895,9 +11393,10 @@
|
| // Compares 2 strings line-by-line, then token-wise and returns diff in form
|
| // of JSArray of triplets (pos1, pos1_end, pos2_end) describing list
|
| // of diff chunks.
|
| -static MaybeObject* Runtime_LiveEditCompareStrings(Arguments args) {
|
| +static MaybeObject* Runtime_LiveEditCompareStrings(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| ASSERT(args.length() == 2);
|
| - HandleScope scope;
|
| + HandleScope scope(isolate);
|
| CONVERT_ARG_CHECKED(String, s1, 0);
|
| CONVERT_ARG_CHECKED(String, s2, 1);
|
|
|
| @@ -10905,20 +11404,21 @@
|
| }
|
|
|
|
|
| -
|
| // A testing entry. Returns statement position which is the closest to
|
| // source_position.
|
| -static MaybeObject* Runtime_GetFunctionCodePositionFromSource(Arguments args) {
|
| +static MaybeObject* Runtime_GetFunctionCodePositionFromSource(
|
| + RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| ASSERT(args.length() == 2);
|
| - HandleScope scope;
|
| + HandleScope scope(isolate);
|
| CONVERT_ARG_CHECKED(JSFunction, function, 0);
|
| CONVERT_NUMBER_CHECKED(int32_t, source_position, Int32, args[1]);
|
|
|
| - Handle<Code> code(function->code());
|
| + Handle<Code> code(function->code(), isolate);
|
|
|
| if (code->kind() != Code::FUNCTION &&
|
| code->kind() != Code::OPTIMIZED_FUNCTION) {
|
| - return Heap::undefined_value();
|
| + return isolate->heap()->undefined_value();
|
| }
|
|
|
| RelocIterator it(*code, RelocInfo::ModeMask(RelocInfo::STATEMENT_POSITION));
|
| @@ -10945,9 +11445,10 @@
|
| // Calls specified function with or without entering the debugger.
|
| // This is used in unit tests to run code as if debugger is entered or simply
|
| // to have a stack with C++ frame in the middle.
|
| -static MaybeObject* Runtime_ExecuteInDebugContext(Arguments args) {
|
| +static MaybeObject* Runtime_ExecuteInDebugContext(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| ASSERT(args.length() == 2);
|
| - HandleScope scope;
|
| + HandleScope scope(isolate);
|
| CONVERT_ARG_CHECKED(JSFunction, function, 0);
|
| CONVERT_BOOLEAN_CHECKED(without_debugger, args[1]);
|
|
|
| @@ -10955,11 +11456,11 @@
|
| bool pending_exception;
|
| {
|
| if (without_debugger) {
|
| - result = Execution::Call(function, Top::global(), 0, NULL,
|
| + result = Execution::Call(function, isolate->global(), 0, NULL,
|
| &pending_exception);
|
| } else {
|
| EnterDebugger enter_debugger;
|
| - result = Execution::Call(function, Top::global(), 0, NULL,
|
| + result = Execution::Call(function, isolate->global(), 0, NULL,
|
| &pending_exception);
|
| }
|
| }
|
| @@ -10972,61 +11473,68 @@
|
|
|
|
|
| // Sets a v8 flag.
|
| -static MaybeObject* Runtime_SetFlags(Arguments args) {
|
| +static MaybeObject* Runtime_SetFlags(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| CONVERT_CHECKED(String, arg, args[0]);
|
| SmartPointer<char> flags =
|
| arg->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL);
|
| FlagList::SetFlagsFromString(*flags, StrLength(*flags));
|
| - return Heap::undefined_value();
|
| + return isolate->heap()->undefined_value();
|
| }
|
|
|
|
|
| // Performs a GC.
|
| // Presently, it only does a full GC.
|
| -static MaybeObject* Runtime_CollectGarbage(Arguments args) {
|
| - Heap::CollectAllGarbage(true);
|
| - return Heap::undefined_value();
|
| +static MaybeObject* Runtime_CollectGarbage(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| + isolate->heap()->CollectAllGarbage(true);
|
| + return isolate->heap()->undefined_value();
|
| }
|
|
|
|
|
| // Gets the current heap usage.
|
| -static MaybeObject* Runtime_GetHeapUsage(Arguments args) {
|
| - int usage = static_cast<int>(Heap::SizeOfObjects());
|
| +static MaybeObject* Runtime_GetHeapUsage(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| + int usage = static_cast<int>(isolate->heap()->SizeOfObjects());
|
| if (!Smi::IsValid(usage)) {
|
| - return *Factory::NewNumberFromInt(usage);
|
| + return *isolate->factory()->NewNumberFromInt(usage);
|
| }
|
| return Smi::FromInt(usage);
|
| }
|
|
|
|
|
| // Captures a live object list from the present heap.
|
| -static MaybeObject* Runtime_HasLOLEnabled(Arguments args) {
|
| +static MaybeObject* Runtime_HasLOLEnabled(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| #ifdef LIVE_OBJECT_LIST
|
| - return Heap::true_value();
|
| + return isolate->heap()->true_value();
|
| #else
|
| - return Heap::false_value();
|
| + return isolate->heap()->false_value();
|
| #endif
|
| }
|
|
|
|
|
| // Captures a live object list from the present heap.
|
| -static MaybeObject* Runtime_CaptureLOL(Arguments args) {
|
| +static MaybeObject* Runtime_CaptureLOL(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| #ifdef LIVE_OBJECT_LIST
|
| return LiveObjectList::Capture();
|
| #else
|
| - return Heap::undefined_value();
|
| + return isolate->heap()->undefined_value();
|
| #endif
|
| }
|
|
|
|
|
| // Deletes the specified live object list.
|
| -static MaybeObject* Runtime_DeleteLOL(Arguments args) {
|
| +static MaybeObject* Runtime_DeleteLOL(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| #ifdef LIVE_OBJECT_LIST
|
| CONVERT_SMI_CHECKED(id, args[0]);
|
| bool success = LiveObjectList::Delete(id);
|
| - return success ? Heap::true_value() : Heap::false_value();
|
| + return success ? isolate->heap()->true_value() :
|
| + isolate->heap()->false_value();
|
| #else
|
| - return Heap::undefined_value();
|
| + return isolate->heap()->undefined_value();
|
| #endif
|
| }
|
|
|
| @@ -11036,7 +11544,8 @@
|
| // specified by id1 and id2.
|
| // If id1 is 0 (i.e. not a valid lol), then the whole of lol id2 will be
|
| // dumped.
|
| -static MaybeObject* Runtime_DumpLOL(Arguments args) {
|
| +static MaybeObject* Runtime_DumpLOL(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| #ifdef LIVE_OBJECT_LIST
|
| HandleScope scope;
|
| CONVERT_SMI_CHECKED(id1, args[0]);
|
| @@ -11047,40 +11556,43 @@
|
| EnterDebugger enter_debugger;
|
| return LiveObjectList::Dump(id1, id2, start, count, filter_obj);
|
| #else
|
| - return Heap::undefined_value();
|
| + return isolate->heap()->undefined_value();
|
| #endif
|
| }
|
|
|
|
|
| // Gets the specified object as requested by the debugger.
|
| // This is only used for obj ids shown in live object lists.
|
| -static MaybeObject* Runtime_GetLOLObj(Arguments args) {
|
| +static MaybeObject* Runtime_GetLOLObj(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| #ifdef LIVE_OBJECT_LIST
|
| CONVERT_SMI_CHECKED(obj_id, args[0]);
|
| Object* result = LiveObjectList::GetObj(obj_id);
|
| return result;
|
| #else
|
| - return Heap::undefined_value();
|
| + return isolate->heap()->undefined_value();
|
| #endif
|
| }
|
|
|
|
|
| // Gets the obj id for the specified address if valid.
|
| // This is only used for obj ids shown in live object lists.
|
| -static MaybeObject* Runtime_GetLOLObjId(Arguments args) {
|
| +static MaybeObject* Runtime_GetLOLObjId(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| #ifdef LIVE_OBJECT_LIST
|
| HandleScope scope;
|
| CONVERT_ARG_CHECKED(String, address, 0);
|
| Object* result = LiveObjectList::GetObjId(address);
|
| return result;
|
| #else
|
| - return Heap::undefined_value();
|
| + return isolate->heap()->undefined_value();
|
| #endif
|
| }
|
|
|
|
|
| // Gets the retainers that references the specified object alive.
|
| -static MaybeObject* Runtime_GetLOLObjRetainers(Arguments args) {
|
| +static MaybeObject* Runtime_GetLOLObjRetainers(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| #ifdef LIVE_OBJECT_LIST
|
| HandleScope scope;
|
| CONVERT_SMI_CHECKED(obj_id, args[0]);
|
| @@ -11114,13 +11626,14 @@
|
| limit,
|
| filter_obj);
|
| #else
|
| - return Heap::undefined_value();
|
| + return isolate->heap()->undefined_value();
|
| #endif
|
| }
|
|
|
|
|
| // Gets the reference path between 2 objects.
|
| -static MaybeObject* Runtime_GetLOLPath(Arguments args) {
|
| +static MaybeObject* Runtime_GetLOLPath(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| #ifdef LIVE_OBJECT_LIST
|
| HandleScope scope;
|
| CONVERT_SMI_CHECKED(obj_id1, args[0]);
|
| @@ -11136,45 +11649,48 @@
|
| LiveObjectList::GetPath(obj_id1, obj_id2, instance_filter);
|
| return result;
|
| #else
|
| - return Heap::undefined_value();
|
| + return isolate->heap()->undefined_value();
|
| #endif
|
| }
|
|
|
|
|
| // Generates the response to a debugger request for a list of all
|
| // previously captured live object lists.
|
| -static MaybeObject* Runtime_InfoLOL(Arguments args) {
|
| +static MaybeObject* Runtime_InfoLOL(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| #ifdef LIVE_OBJECT_LIST
|
| CONVERT_SMI_CHECKED(start, args[0]);
|
| CONVERT_SMI_CHECKED(count, args[1]);
|
| return LiveObjectList::Info(start, count);
|
| #else
|
| - return Heap::undefined_value();
|
| + return isolate->heap()->undefined_value();
|
| #endif
|
| }
|
|
|
|
|
| // Gets a dump of the specified object as requested by the debugger.
|
| // This is only used for obj ids shown in live object lists.
|
| -static MaybeObject* Runtime_PrintLOLObj(Arguments args) {
|
| +static MaybeObject* Runtime_PrintLOLObj(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| #ifdef LIVE_OBJECT_LIST
|
| HandleScope scope;
|
| CONVERT_SMI_CHECKED(obj_id, args[0]);
|
| Object* result = LiveObjectList::PrintObj(obj_id);
|
| return result;
|
| #else
|
| - return Heap::undefined_value();
|
| + return isolate->heap()->undefined_value();
|
| #endif
|
| }
|
|
|
|
|
| // Resets and releases all previously captured live object lists.
|
| -static MaybeObject* Runtime_ResetLOL(Arguments args) {
|
| +static MaybeObject* Runtime_ResetLOL(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| #ifdef LIVE_OBJECT_LIST
|
| LiveObjectList::Reset();
|
| - return Heap::undefined_value();
|
| + return isolate->heap()->undefined_value();
|
| #else
|
| - return Heap::undefined_value();
|
| + return isolate->heap()->undefined_value();
|
| #endif
|
| }
|
|
|
| @@ -11184,7 +11700,8 @@
|
| // specified by id1 and id2.
|
| // If id1 is 0 (i.e. not a valid lol), then the whole of lol id2 will be
|
| // summarized.
|
| -static MaybeObject* Runtime_SummarizeLOL(Arguments args) {
|
| +static MaybeObject* Runtime_SummarizeLOL(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| #ifdef LIVE_OBJECT_LIST
|
| HandleScope scope;
|
| CONVERT_SMI_CHECKED(id1, args[0]);
|
| @@ -11194,7 +11711,7 @@
|
| EnterDebugger enter_debugger;
|
| return LiveObjectList::Summarize(id1, id2, filter_obj);
|
| #else
|
| - return Heap::undefined_value();
|
| + return isolate->heap()->undefined_value();
|
| #endif
|
| }
|
|
|
| @@ -11202,25 +11719,27 @@
|
|
|
|
|
| #ifdef ENABLE_LOGGING_AND_PROFILING
|
| -static MaybeObject* Runtime_ProfilerResume(Arguments args) {
|
| +static MaybeObject* Runtime_ProfilerResume(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 2);
|
|
|
| CONVERT_CHECKED(Smi, smi_modules, args[0]);
|
| CONVERT_CHECKED(Smi, smi_tag, args[1]);
|
| v8::V8::ResumeProfilerEx(smi_modules->value(), smi_tag->value());
|
| - return Heap::undefined_value();
|
| + return isolate->heap()->undefined_value();
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_ProfilerPause(Arguments args) {
|
| +static MaybeObject* Runtime_ProfilerPause(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| NoHandleAllocation ha;
|
| ASSERT(args.length() == 2);
|
|
|
| CONVERT_CHECKED(Smi, smi_modules, args[0]);
|
| CONVERT_CHECKED(Smi, smi_tag, args[1]);
|
| v8::V8::PauseProfilerEx(smi_modules->value(), smi_tag->value());
|
| - return Heap::undefined_value();
|
| + return isolate->heap()->undefined_value();
|
| }
|
|
|
| #endif // ENABLE_LOGGING_AND_PROFILING
|
| @@ -11250,7 +11769,7 @@
|
| }
|
|
|
| // If no script with the requested script data is found return undefined.
|
| - if (script.is_null()) return Factory::undefined_value();
|
| + if (script.is_null()) return FACTORY->undefined_value();
|
|
|
| // Return the script found.
|
| return GetScriptWrapper(script);
|
| @@ -11260,8 +11779,9 @@
|
| // 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
|
| -static MaybeObject* Runtime_GetScript(Arguments args) {
|
| - HandleScope scope;
|
| +static MaybeObject* Runtime_GetScript(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| + HandleScope scope(isolate);
|
|
|
| ASSERT(args.length() == 1);
|
|
|
| @@ -11305,17 +11825,19 @@
|
| // Collect the raw data for a stack trace. Returns an array of 4
|
| // element segments each containing a receiver, function, code and
|
| // native code offset.
|
| -static MaybeObject* Runtime_CollectStackTrace(Arguments args) {
|
| +static MaybeObject* Runtime_CollectStackTrace(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| ASSERT_EQ(args.length(), 2);
|
| Handle<Object> caller = args.at<Object>(0);
|
| CONVERT_NUMBER_CHECKED(int32_t, limit, Int32, args[1]);
|
|
|
| - HandleScope scope;
|
| + HandleScope scope(isolate);
|
| + Factory* factory = isolate->factory();
|
|
|
| limit = Max(limit, 0); // Ensure that limit is not negative.
|
| int initial_size = Min(limit, 10);
|
| Handle<FixedArray> elements =
|
| - Factory::NewFixedArrayWithHoles(initial_size * 4);
|
| + factory->NewFixedArrayWithHoles(initial_size * 4);
|
|
|
| StackFrameIterator iter;
|
| // If the caller parameter is a function we skip frames until we're
|
| @@ -11334,7 +11856,7 @@
|
| if (cursor + 4 > elements->length()) {
|
| int new_capacity = JSObject::NewElementsCapacity(elements->length());
|
| Handle<FixedArray> new_elements =
|
| - Factory::NewFixedArrayWithHoles(new_capacity);
|
| + factory->NewFixedArrayWithHoles(new_capacity);
|
| for (int i = 0; i < cursor; i++) {
|
| new_elements->set(i, elements->get(i));
|
| }
|
| @@ -11354,36 +11876,40 @@
|
| }
|
| iter.Advance();
|
| }
|
| - Handle<JSArray> result = Factory::NewJSArrayWithElements(elements);
|
| + Handle<JSArray> result = factory->NewJSArrayWithElements(elements);
|
| result->set_length(Smi::FromInt(cursor));
|
| return *result;
|
| }
|
|
|
|
|
| // Returns V8 version as a string.
|
| -static MaybeObject* Runtime_GetV8Version(Arguments args) {
|
| +static MaybeObject* Runtime_GetV8Version(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| ASSERT_EQ(args.length(), 0);
|
|
|
| NoHandleAllocation ha;
|
|
|
| const char* version_string = v8::V8::GetVersion();
|
|
|
| - return Heap::AllocateStringFromAscii(CStrVector(version_string), NOT_TENURED);
|
| + return isolate->heap()->AllocateStringFromAscii(CStrVector(version_string),
|
| + NOT_TENURED);
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_Abort(Arguments args) {
|
| +static MaybeObject* Runtime_Abort(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| ASSERT(args.length() == 2);
|
| OS::PrintError("abort: %s\n", reinterpret_cast<char*>(args[0]) +
|
| Smi::cast(args[1])->value());
|
| - Top::PrintStack();
|
| + isolate->PrintStack();
|
| OS::Abort();
|
| UNREACHABLE();
|
| return NULL;
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_GetFromCache(Arguments args) {
|
| +static MaybeObject* Runtime_GetFromCache(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| // This is only called from codegen, so checks might be more lax.
|
| CONVERT_CHECKED(JSFunctionResultCache, cache, args[0]);
|
| Object* key = args[1];
|
| @@ -11417,7 +11943,7 @@
|
| }
|
|
|
| // There is no value in the cache. Invoke the function and cache result.
|
| - HandleScope scope;
|
| + HandleScope scope(isolate);
|
|
|
| Handle<JSFunctionResultCache> cache_handle(cache);
|
| Handle<Object> key_handle(key);
|
| @@ -11426,7 +11952,7 @@
|
| Handle<JSFunction> factory(JSFunction::cast(
|
| cache_handle->get(JSFunctionResultCache::kFactoryIndex)));
|
| // TODO(antonm): consider passing a receiver when constructing a cache.
|
| - Handle<Object> receiver(Top::global_context()->global());
|
| + Handle<Object> receiver(isolate->global_context()->global());
|
| // This handle is nor shared, nor used later, so it's safe.
|
| Object** argv[] = { key_handle.location() };
|
| bool pending_exception = false;
|
| @@ -11475,39 +12001,46 @@
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_NewMessageObject(Arguments args) {
|
| - HandleScope scope;
|
| +static MaybeObject* Runtime_NewMessageObject(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| + HandleScope scope(isolate);
|
| CONVERT_ARG_CHECKED(String, type, 0);
|
| CONVERT_ARG_CHECKED(JSArray, arguments, 1);
|
| - return *Factory::NewJSMessageObject(type,
|
| - arguments,
|
| - 0,
|
| - 0,
|
| - Factory::undefined_value(),
|
| - Factory::undefined_value(),
|
| - Factory::undefined_value());
|
| + return *isolate->factory()->NewJSMessageObject(
|
| + type,
|
| + arguments,
|
| + 0,
|
| + 0,
|
| + isolate->factory()->undefined_value(),
|
| + isolate->factory()->undefined_value(),
|
| + isolate->factory()->undefined_value());
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_MessageGetType(Arguments args) {
|
| +static MaybeObject* Runtime_MessageGetType(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| CONVERT_CHECKED(JSMessageObject, message, args[0]);
|
| return message->type();
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_MessageGetArguments(Arguments args) {
|
| +static MaybeObject* Runtime_MessageGetArguments(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| CONVERT_CHECKED(JSMessageObject, message, args[0]);
|
| return message->arguments();
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_MessageGetStartPosition(Arguments args) {
|
| +static MaybeObject* Runtime_MessageGetStartPosition(
|
| + RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| CONVERT_CHECKED(JSMessageObject, message, args[0]);
|
| return Smi::FromInt(message->start_position());
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_MessageGetScript(Arguments args) {
|
| +static MaybeObject* Runtime_MessageGetScript(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| CONVERT_CHECKED(JSMessageObject, message, args[0]);
|
| return message->script();
|
| }
|
| @@ -11516,7 +12049,8 @@
|
| #ifdef DEBUG
|
| // ListNatives is ONLY used by the fuzz-natives.js in debug mode
|
| // Exclude the code in release mode.
|
| -static MaybeObject* Runtime_ListNatives(Arguments args) {
|
| +static MaybeObject* Runtime_ListNatives(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| ASSERT(args.length() == 0);
|
| HandleScope scope;
|
| #define COUNT_ENTRY(Name, argc, ressize) + 1
|
| @@ -11525,7 +12059,8 @@
|
| INLINE_FUNCTION_LIST(COUNT_ENTRY)
|
| INLINE_RUNTIME_FUNCTION_LIST(COUNT_ENTRY);
|
| #undef COUNT_ENTRY
|
| - Handle<FixedArray> elements = Factory::NewFixedArray(entry_count);
|
| + Factory* factory = isolate->factory();
|
| + Handle<FixedArray> elements = factory->NewFixedArray(entry_count);
|
| int index = 0;
|
| bool inline_runtime_functions = false;
|
| #define ADD_ENTRY(Name, argc, ressize) \
|
| @@ -11534,16 +12069,16 @@
|
| Handle<String> name; \
|
| /* Inline runtime functions have an underscore in front of the name. */ \
|
| if (inline_runtime_functions) { \
|
| - name = Factory::NewStringFromAscii( \
|
| + name = factory->NewStringFromAscii( \
|
| Vector<const char>("_" #Name, StrLength("_" #Name))); \
|
| } else { \
|
| - name = Factory::NewStringFromAscii( \
|
| + name = factory->NewStringFromAscii( \
|
| Vector<const char>(#Name, StrLength(#Name))); \
|
| } \
|
| - Handle<FixedArray> pair_elements = Factory::NewFixedArray(2); \
|
| + Handle<FixedArray> pair_elements = factory->NewFixedArray(2); \
|
| pair_elements->set(0, *name); \
|
| pair_elements->set(1, Smi::FromInt(argc)); \
|
| - Handle<JSArray> pair = Factory::NewJSArrayWithElements(pair_elements); \
|
| + Handle<JSArray> pair = factory->NewJSArrayWithElements(pair_elements); \
|
| elements->set(index++, *pair); \
|
| }
|
| inline_runtime_functions = false;
|
| @@ -11553,23 +12088,24 @@
|
| INLINE_RUNTIME_FUNCTION_LIST(ADD_ENTRY)
|
| #undef ADD_ENTRY
|
| ASSERT_EQ(index, entry_count);
|
| - Handle<JSArray> result = Factory::NewJSArrayWithElements(elements);
|
| + Handle<JSArray> result = factory->NewJSArrayWithElements(elements);
|
| return *result;
|
| }
|
| #endif
|
|
|
|
|
| -static MaybeObject* Runtime_Log(Arguments args) {
|
| +static MaybeObject* Runtime_Log(RUNTIME_CALLING_CONVENTION) {
|
| + RUNTIME_GET_ISOLATE;
|
| ASSERT(args.length() == 2);
|
| CONVERT_CHECKED(String, format, args[0]);
|
| CONVERT_CHECKED(JSArray, elms, args[1]);
|
| Vector<const char> chars = format->ToAsciiVector();
|
| - Logger::LogRuntime(chars, elms);
|
| - return Heap::undefined_value();
|
| + LOGGER->LogRuntime(chars, elms);
|
| + return isolate->heap()->undefined_value();
|
| }
|
|
|
|
|
| -static MaybeObject* Runtime_IS_VAR(Arguments args) {
|
| +static MaybeObject* Runtime_IS_VAR(RUNTIME_CALLING_CONVENTION) {
|
| UNREACHABLE(); // implemented as macro in the parser
|
| return NULL;
|
| }
|
| @@ -11587,20 +12123,22 @@
|
| { Runtime::kInline##name, Runtime::INLINE, \
|
| "_" #name, NULL, number_of_args, result_size },
|
|
|
| -Runtime::Function kIntrinsicFunctions[] = {
|
| +static const Runtime::Function kIntrinsicFunctions[] = {
|
| RUNTIME_FUNCTION_LIST(F)
|
| INLINE_FUNCTION_LIST(I)
|
| INLINE_RUNTIME_FUNCTION_LIST(I)
|
| };
|
|
|
|
|
| -MaybeObject* Runtime::InitializeIntrinsicFunctionNames(Object* dictionary) {
|
| +MaybeObject* Runtime::InitializeIntrinsicFunctionNames(Heap* heap,
|
| + Object* dictionary) {
|
| + ASSERT(Isolate::Current()->heap() == heap);
|
| ASSERT(dictionary != NULL);
|
| ASSERT(StringDictionary::cast(dictionary)->NumberOfElements() == 0);
|
| for (int i = 0; i < kNumFunctions; ++i) {
|
| Object* name_symbol;
|
| { MaybeObject* maybe_name_symbol =
|
| - Heap::LookupAsciiSymbol(kIntrinsicFunctions[i].name);
|
| + heap->LookupAsciiSymbol(kIntrinsicFunctions[i].name);
|
| if (!maybe_name_symbol->ToObject(&name_symbol)) return maybe_name_symbol;
|
| }
|
| StringDictionary* string_dictionary = StringDictionary::cast(dictionary);
|
| @@ -11619,10 +12157,11 @@
|
| }
|
|
|
|
|
| -Runtime::Function* Runtime::FunctionForSymbol(Handle<String> name) {
|
| - int entry = Heap::intrinsic_function_names()->FindEntry(*name);
|
| +const Runtime::Function* Runtime::FunctionForSymbol(Handle<String> name) {
|
| + Heap* heap = name->GetHeap();
|
| + int entry = heap->intrinsic_function_names()->FindEntry(*name);
|
| if (entry != kNotFound) {
|
| - Object* smi_index = Heap::intrinsic_function_names()->ValueAt(entry);
|
| + Object* smi_index = heap->intrinsic_function_names()->ValueAt(entry);
|
| int function_index = Smi::cast(smi_index)->value();
|
| return &(kIntrinsicFunctions[function_index]);
|
| }
|
| @@ -11630,7 +12169,7 @@
|
| }
|
|
|
|
|
| -Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) {
|
| +const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) {
|
| return &(kIntrinsicFunctions[static_cast<int>(id)]);
|
| }
|
|
|
| @@ -11640,12 +12179,12 @@
|
| if (failure->IsRetryAfterGC()) {
|
| // Try to do a garbage collection; ignore it if it fails. The C
|
| // entry stub will throw an out-of-memory exception in that case.
|
| - Heap::CollectGarbage(failure->allocation_space());
|
| + HEAP->CollectGarbage(failure->allocation_space());
|
| } else {
|
| // Handle last resort GC and make sure to allow future allocations
|
| // to grow the heap without causing GCs (if possible).
|
| - Counters::gc_last_resort_from_js.Increment();
|
| - Heap::CollectAllGarbage(false);
|
| + COUNTERS->gc_last_resort_from_js()->Increment();
|
| + HEAP->CollectAllGarbage(false);
|
| }
|
| }
|
|
|
|
|