Revision: 5546
Author: [email protected]
Date: Tue Sep 28 07:20:01 2010
Log: [Isolates] More handle improvements:
o Automatically extract the current isolate when creating heap object
handles.
o Pass isolate to HandleScope.
o Pass isolate to more runtime functions and prefer Isolate* to
Heap*.
Review URL: http://codereview.chromium.org/3473024
http://code.google.com/p/v8/source/detail?r=5546
Modified:
/branches/experimental/isolates/src/handles-inl.h
/branches/experimental/isolates/src/handles.cc
/branches/experimental/isolates/src/handles.h
/branches/experimental/isolates/src/ic.cc
/branches/experimental/isolates/src/runtime.cc
/branches/experimental/isolates/src/runtime.h
/branches/experimental/isolates/test/cctest/test-func-name-inference.cc
=======================================
--- /branches/experimental/isolates/src/handles-inl.h Mon Sep 27 09:58:02
2010
+++ /branches/experimental/isolates/src/handles-inl.h Tue Sep 28 07:20:01
2010
@@ -43,6 +43,11 @@
location_ = HandleScope::CreateHandle(obj, Isolate::Current());
}
+template<class T>
+Handle<T>::Handle(HeapObject* obj) {
+ location_ = HandleScope::CreateHandle<T>(obj, obj->GetIsolate());
+}
+
template<class T>
Handle<T>::Handle(T* obj, Isolate* isolate) {
@@ -57,11 +62,38 @@
ASSERT(reinterpret_cast<Address>(*location_) != kHandleZapValue);
return *BitCast<T**>(location_);
}
+
+
+// Helper class to zero out the number of extensions in the handle
+// scope data after it has been saved.
+// This is only necessary for HandleScope constructor to get the right
+// order of effects.
+class HandleScopeDataTransfer {
+ public:
+ typedef v8::ImplementationUtilities::HandleScopeData Data;
+
+ explicit HandleScopeDataTransfer(Data* data) : data_(data) {}
+ ~HandleScopeDataTransfer() { data_->extensions = 0; }
+
+ // Called before the destructor to get the data to save.
+ Data* data() { return data_; }
+
+ private:
+ Data* data_;
+
+ DISALLOW_COPY_AND_ASSIGN(HandleScopeDataTransfer);
+};
HandleScope::HandleScope()
- : previous_(*Isolate::Current()->handle_scope_data()) {
- Isolate::Current()->handle_scope_data()->extensions = 0;
+ : previous_(*HandleScopeDataTransfer(
+ Isolate::Current()->handle_scope_data()).data()) {
+}
+
+
+HandleScope::HandleScope(Isolate* isolate)
+ :
previous_(*HandleScopeDataTransfer(isolate->handle_scope_data()).data()) {
+ ASSERT(isolate == Isolate::Current());
}
=======================================
--- /branches/experimental/isolates/src/handles.cc Fri Sep 24 17:27:22 2010
+++ /branches/experimental/isolates/src/handles.cc Tue Sep 28 07:20:01 2010
@@ -257,9 +257,10 @@
Handle<Object> key,
Handle<Object> value,
PropertyAttributes attributes) {
- Heap* heap = HEAP;
+ Isolate* isolate = Isolate::Current();
CALL_HEAP_FUNCTION(
- Runtime::SetObjectProperty(heap, object, key, value, attributes),
Object);
+ Runtime::SetObjectProperty(isolate, object, key, value, attributes),
+ Object);
}
@@ -267,8 +268,10 @@
Handle<Object> key,
Handle<Object> value,
PropertyAttributes attributes) {
+ Isolate* isolate = object->GetIsolate();
CALL_HEAP_FUNCTION(
- Runtime::ForceSetObjectProperty(object, key, value, attributes),
Object);
+ Runtime::ForceSetObjectProperty(isolate, object, key, value,
attributes),
+ Object);
}
@@ -283,8 +286,8 @@
Handle<Object> ForceDeleteProperty(Handle<JSObject> object,
Handle<Object> key) {
- Heap* heap = HEAP;
- CALL_HEAP_FUNCTION(Runtime::ForceDeleteObjectProperty(heap, object, key),
+ Isolate* isolate = object->GetIsolate();
+ CALL_HEAP_FUNCTION(Runtime::ForceDeleteObjectProperty(isolate, object,
key),
Object);
}
@@ -319,8 +322,8 @@
Handle<Object> GetProperty(Handle<Object> obj,
Handle<Object> key) {
- Heap* heap = HEAP;
- CALL_HEAP_FUNCTION(Runtime::GetObjectProperty(heap, obj, key), Object);
+ Isolate* isolate = Isolate::Current();
+ CALL_HEAP_FUNCTION(Runtime::GetObjectProperty(isolate, obj, key),
Object);
}
=======================================
--- /branches/experimental/isolates/src/handles.h Mon Sep 27 09:58:02 2010
+++ /branches/experimental/isolates/src/handles.h Tue Sep 28 07:20:01 2010
@@ -44,6 +44,7 @@
public:
INLINE(explicit Handle(T** location)) { location_ = location; }
INLINE(explicit Handle(T* obj));
+ INLINE(explicit Handle(HeapObject* obj));
INLINE(Handle(T* obj, Isolate* isolate));
INLINE(Handle()) : location_(NULL) {}
@@ -109,6 +110,7 @@
class HandleScope {
public:
inline HandleScope();
+ explicit inline HandleScope(Isolate* isolate);
~HandleScope() {
Leave(&previous_);
=======================================
--- /branches/experimental/isolates/src/ic.cc Fri Sep 24 17:27:22 2010
+++ /branches/experimental/isolates/src/ic.cc Tue Sep 28 07:20:01 2010
@@ -736,8 +736,7 @@
#endif
}
}
- Heap* heap = HEAP;
- Object* result = Runtime::GetObjectProperty(heap, object, key);
+ Object* result = Runtime::GetObjectProperty(isolate(), object, key);
if (result->IsJSFunction()) return result;
result = TryCallAsFunction(result);
return result->IsJSFunction() ?
@@ -1093,7 +1092,7 @@
HandleScope scope;
// Rewrite to the generic keyed load stub.
if (FLAG_use_ic) set_target(generic_stub());
- return Runtime::GetElementOrCharAt(HEAP, object, index);
+ return Runtime::GetElementOrCharAt(isolate(), object, index);
}
// Named lookup.
@@ -1158,7 +1157,7 @@
}
// Get the property.
- return Runtime::GetObjectProperty(HEAP, object, key);
+ return Runtime::GetObjectProperty(isolate(), object, key);
}
@@ -1533,7 +1532,7 @@
}
// Set the property.
- return Runtime::SetObjectProperty(HEAP, object, key, value, NONE);
+ return Runtime::SetObjectProperty(isolate(), object, key, value, NONE);
}
=======================================
--- /branches/experimental/isolates/src/runtime.cc Mon Sep 27 10:17:32 2010
+++ /branches/experimental/isolates/src/runtime.cc Tue Sep 28 07:20:01 2010
@@ -102,11 +102,12 @@
type name = NumberTo##Type(obj);
-MUST_USE_RESULT static Object* DeepCopyBoilerplate(Heap* heap,
+MUST_USE_RESULT static Object* DeepCopyBoilerplate(Isolate* isolate,
JSObject* boilerplate) {
- StackLimitCheck check(heap->isolate());
- if (check.HasOverflowed()) return heap->isolate()->StackOverflow();
-
+ StackLimitCheck check(isolate);
+ if (check.HasOverflowed()) return isolate->StackOverflow();
+
+ Heap* heap = isolate->heap();
Object* result = heap->CopyJSObject(boilerplate);
if (result->IsFailure()) return result;
JSObject* copy = JSObject::cast(result);
@@ -118,7 +119,7 @@
Object* value = properties->get(i);
if (value->IsJSObject()) {
JSObject* js_object = JSObject::cast(value);
- result = DeepCopyBoilerplate(heap, js_object);
+ result = DeepCopyBoilerplate(isolate, js_object);
if (result->IsFailure()) return result;
properties->set(i, result);
}
@@ -128,7 +129,7 @@
Object* value = copy->InObjectPropertyAt(i);
if (value->IsJSObject()) {
JSObject* js_object = JSObject::cast(value);
- result = DeepCopyBoilerplate(heap, js_object);
+ result = DeepCopyBoilerplate(isolate, js_object);
if (result->IsFailure()) return result;
copy->InObjectPropertyAtPut(i, result);
}
@@ -151,7 +152,7 @@
ASSERT(!value->IsFailure());
if (value->IsJSObject()) {
JSObject* js_object = JSObject::cast(value);
- result = DeepCopyBoilerplate(heap, js_object);
+ result = DeepCopyBoilerplate(isolate, js_object);
if (result->IsFailure()) return result;
result = copy->SetProperty(key_string, result, NONE);
if (result->IsFailure()) return result;
@@ -166,7 +167,7 @@
case JSObject::FAST_ELEMENTS: {
FixedArray* elements = FixedArray::cast(copy->elements());
if (elements->map() == heap->fixed_cow_array_map()) {
-
heap->isolate()->counters()->cow_arrays_created_runtime()->Increment();
+ isolate->counters()->cow_arrays_created_runtime()->Increment();
#ifdef DEBUG
for (int i = 0; i < elements->length(); i++) {
ASSERT(!elements->get(i)->IsJSObject());
@@ -177,7 +178,7 @@
Object* value = elements->get(i);
if (value->IsJSObject()) {
JSObject* js_object = JSObject::cast(value);
- result = DeepCopyBoilerplate(heap, js_object);
+ result = DeepCopyBoilerplate(isolate, js_object);
if (result->IsFailure()) return result;
elements->set(i, result);
}
@@ -194,7 +195,7 @@
Object* value = element_dictionary->ValueAt(i);
if (value->IsJSObject()) {
JSObject* js_object = JSObject::cast(value);
- result = DeepCopyBoilerplate(heap, js_object);
+ result = DeepCopyBoilerplate(isolate, js_object);
if (result->IsFailure()) return result;
element_dictionary->ValueAtPut(i, result);
}
@@ -213,7 +214,7 @@
static Object* Runtime_CloneLiteralBoilerplate(RUNTIME_CALLING_CONVENTION)
{
RUNTIME_GET_ISOLATE;
CONVERT_CHECKED(JSObject, boilerplate, args[0]);
- return DeepCopyBoilerplate(isolate->heap(), boilerplate);
+ return DeepCopyBoilerplate(isolate, boilerplate);
}
@@ -278,11 +279,13 @@
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) {
@@ -311,13 +314,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;
@@ -353,6 +356,7 @@
static Handle<Object> CreateArrayLiteralBoilerplate(
+ Isolate* isolate,
Handle<FixedArray> literals,
Handle<FixedArray> elements) {
// Create the JSArray.
@@ -360,7 +364,8 @@
JSFunction::GlobalContextFromLiterals(*literals)->array_function());
Handle<Object> object = 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);
@@ -379,7 +384,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);
}
@@ -393,16 +398,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();
@@ -418,13 +424,14 @@
// 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.
@@ -435,7 +442,7 @@
static Object* Runtime_CreateObjectLiteral(RUNTIME_CALLING_CONVENTION) {
RUNTIME_GET_ISOLATE;
- HandleScope scope;
+ HandleScope scope(isolate);
ASSERT(args.length() == 4);
CONVERT_ARG_CHECKED(FixedArray, literals, 0);
CONVERT_SMI_CHECKED(literals_index, args[1]);
@@ -444,22 +451,23 @@
bool should_have_fast_elements = fast_elements == 1;
// Check if boilerplate exists. If not, create it first.
- Handle<Object> boilerplate(literals->get(literals_index));
+ Handle<Object> boilerplate(literals->get(literals_index), isolate);
if (*boilerplate == isolate->heap()->undefined_value()) {
- boilerplate = CreateObjectLiteralBoilerplate(literals,
+ 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(isolate->heap(),
JSObject::cast(*boilerplate));
+ return DeepCopyBoilerplate(isolate, JSObject::cast(*boilerplate));
}
static Object*
Runtime_CreateObjectLiteralShallow(RUNTIME_CALLING_CONVENTION) {
RUNTIME_GET_ISOLATE;
- HandleScope scope;
+ HandleScope scope(isolate);
ASSERT(args.length() == 4);
CONVERT_ARG_CHECKED(FixedArray, literals, 0);
CONVERT_SMI_CHECKED(literals_index, args[1]);
@@ -468,9 +476,10 @@
bool should_have_fast_elements = fast_elements == 1;
// Check if boilerplate exists. If not, create it first.
- Handle<Object> boilerplate(literals->get(literals_index));
+ Handle<Object> boilerplate(literals->get(literals_index), isolate);
if (*boilerplate == isolate->heap()->undefined_value()) {
- boilerplate = CreateObjectLiteralBoilerplate(literals,
+ boilerplate = CreateObjectLiteralBoilerplate(isolate,
+ literals,
constant_properties,
should_have_fast_elements);
if (boilerplate.is_null()) return Failure::Exception();
@@ -483,36 +492,36 @@
static Object* Runtime_CreateArrayLiteral(RUNTIME_CALLING_CONVENTION) {
RUNTIME_GET_ISOLATE;
- 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);
// Check if boilerplate exists. If not, create it first.
- Handle<Object> boilerplate(literals->get(literals_index));
+ Handle<Object> boilerplate(literals->get(literals_index), isolate);
if (*boilerplate == isolate->heap()->undefined_value()) {
- boilerplate = CreateArrayLiteralBoilerplate(literals, elements);
+ 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(isolate->heap(),
JSObject::cast(*boilerplate));
+ return DeepCopyBoilerplate(isolate, JSObject::cast(*boilerplate));
}
static Object*
Runtime_CreateArrayLiteralShallow(RUNTIME_CALLING_CONVENTION) {
RUNTIME_GET_ISOLATE;
- 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);
// Check if boilerplate exists. If not, create it first.
- Handle<Object> boilerplate(literals->get(literals_index));
+ Handle<Object> boilerplate(literals->get(literals_index), isolate);
if (*boilerplate == isolate->heap()->undefined_value()) {
- boilerplate = CreateArrayLiteralBoilerplate(literals, elements);
+ 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);
@@ -655,7 +664,7 @@
RUNTIME_GET_ISOLATE;
ASSERT(args.length() == 2);
Heap* heap = isolate->heap();
- HandleScope scope;
+ HandleScope scope(isolate);
Handle<FixedArray> elms = Factory::NewFixedArray(DESCRIPTOR_SIZE);
Handle<JSArray> desc = Factory::NewJSArrayWithElements(elms);
LookupResult result;
@@ -779,7 +788,7 @@
static Object* Runtime_RegExpCompile(RUNTIME_CALLING_CONVENTION) {
RUNTIME_GET_ISOLATE;
- HandleScope scope;
+ HandleScope scope(isolate);
ASSERT(args.length() == 3);
CONVERT_ARG_CHECKED(JSRegExp, re, 0);
CONVERT_ARG_CHECKED(String, pattern, 1);
@@ -792,7 +801,7 @@
static Object* Runtime_CreateApiFunction(RUNTIME_CALLING_CONVENTION) {
RUNTIME_GET_ISOLATE;
- HandleScope scope;
+ HandleScope scope(isolate);
ASSERT(args.length() == 1);
CONVERT_ARG_CHECKED(FunctionTemplateInfo, data, 0);
return *Factory::CreateApiFunction(data);
@@ -867,7 +876,7 @@
static Object* ThrowRedeclarationError(Isolate* isolate,
const char* type,
Handle<String> name) {
- HandleScope scope;
+ HandleScope scope(isolate);
Handle<Object> type_handle =
Factory::NewStringFromAscii(CStrVector(type));
Handle<Object> args[2] = { type_handle, name };
Handle<Object> error =
@@ -878,7 +887,7 @@
static Object* Runtime_DeclareGlobals(RUNTIME_CALLING_CONVENTION) {
RUNTIME_GET_ISOLATE;
- HandleScope scope;
+ HandleScope scope(isolate);
Handle<GlobalObject> global = Handle<GlobalObject>(
isolate->context()->global());
@@ -895,9 +904,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 =
@@ -992,7 +1001,7 @@
static Object* Runtime_DeclareContextSlot(RUNTIME_CALLING_CONVENTION) {
RUNTIME_GET_ISOLATE;
- HandleScope scope;
+ HandleScope scope(isolate);
ASSERT(args.length() == 4);
CONVERT_ARG_CHECKED(Context, context, 0);
@@ -1000,7 +1009,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());
@@ -1067,7 +1076,7 @@
// or undefined, and use the correct mode (e.g. READ_ONLY attribute for
// constant declarations).
ASSERT(!context_ext->HasLocalProperty(*name));
- Handle<Object> value(isolate->heap()->undefined_value());
+ Handle<Object> value(isolate->heap()->undefined_value(), isolate);
if (*initial_value != NULL) value = initial_value;
SetProperty(context_ext, name, value, mode);
ASSERT(context_ext->GetLocalPropertyAttribute(*name) == mode);
@@ -1122,7 +1131,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;
@@ -1256,10 +1265,10 @@
static Object*
Runtime_InitializeConstContextSlot(RUNTIME_CALLING_CONVENTION) {
RUNTIME_GET_ISOLATE;
- HandleScope scope;
+ 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]));
@@ -1364,7 +1373,7 @@
static Object* Runtime_OptimizeObjectForAddingMultipleProperties(
RUNTIME_CALLING_CONVENTION) {
RUNTIME_GET_ISOLATE;
- HandleScope scope;
+ HandleScope scope(isolate);
ASSERT(args.length() == 2);
CONVERT_ARG_CHECKED(JSObject, object, 0);
CONVERT_SMI_CHECKED(properties, args[1]);
@@ -1377,7 +1386,7 @@
static Object* Runtime_RegExpExec(RUNTIME_CALLING_CONVENTION) {
RUNTIME_GET_ISOLATE;
- HandleScope scope;
+ HandleScope scope(isolate);
ASSERT(args.length() == 4);
CONVERT_ARG_CHECKED(JSRegExp, regexp, 0);
CONVERT_ARG_CHECKED(String, subject, 1);
@@ -1415,7 +1424,7 @@
if (new_object->IsFailure()) return new_object;
{
AssertNoAllocation no_gc;
- HandleScope scope;
+ HandleScope scope(isolate);
reinterpret_cast<HeapObject*>(new_object)->
set_map(isolate->global_context()->regexp_result_map());
}
@@ -1543,7 +1552,7 @@
static Object*
Runtime_FinishArrayPrototypeSetup(RUNTIME_CALLING_CONVENTION) {
RUNTIME_GET_ISOLATE;
- HandleScope scope;
+ HandleScope scope(isolate);
ASSERT(args.length() == 1);
CONVERT_ARG_CHECKED(JSArray, prototype, 0);
// This is necessary to enable fast checks for absence of elements
@@ -1572,7 +1581,7 @@
static Object* Runtime_SpecialArrayFunctions(RUNTIME_CALLING_CONVENTION) {
RUNTIME_GET_ISOLATE;
- HandleScope scope;
+ HandleScope scope(isolate);
ASSERT(args.length() == 1);
CONVERT_ARG_CHECKED(JSObject, holder, 0);
@@ -1599,7 +1608,7 @@
static Object*
Runtime_MaterializeRegExpLiteral(RUNTIME_CALLING_CONVENTION) {
RUNTIME_GET_ISOLATE;
- HandleScope scope;
+ HandleScope scope(isolate);
ASSERT(args.length() == 4);
CONVERT_ARG_CHECKED(FixedArray, literals, 0);
int index = Smi::cast(args[1])->value();
@@ -1665,11 +1674,11 @@
static Object* Runtime_FunctionGetScript(RUNTIME_CALLING_CONVENTION) {
RUNTIME_GET_ISOLATE;
- HandleScope scope;
+ HandleScope scope(isolate);
ASSERT(args.length() == 1);
CONVERT_CHECKED(JSFunction, fun, args[0]);
- Handle<Object> script = Handle<Object>(fun->shared()->script());
+ Handle<Object> script = Handle<Object>(fun->shared()->script(), isolate);
if (!script->IsScript()) return isolate->heap()->undefined_value();
return *GetScriptWrapper(Handle<Script>::cast(script));
@@ -1776,7 +1785,7 @@
static Object* Runtime_SetCode(RUNTIME_CALLING_CONVENTION) {
RUNTIME_GET_ISOLATE;
- HandleScope scope;
+ HandleScope scope(isolate);
ASSERT(args.length() == 2);
CONVERT_ARG_CHECKED(JSFunction, target, 0);
@@ -1835,7 +1844,7 @@
static Object* Runtime_SetExpectedNumberOfProperties(
RUNTIME_CALLING_CONVENTION) {
RUNTIME_GET_ISOLATE;
- HandleScope scope;
+ HandleScope scope(isolate);
ASSERT(args.length() == 2);
CONVERT_ARG_CHECKED(JSFunction, function, 0);
CONVERT_SMI_CHECKED(num, args[1]);
@@ -1845,14 +1854,14 @@
}
-static Object* CharFromCode(Heap* heap, Object* char_code) {
+static Object* 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();
}
@@ -1895,7 +1904,7 @@
RUNTIME_GET_ISOLATE;
NoHandleAllocation ha;
ASSERT(args.length() == 1);
- return CharFromCode(isolate->heap(), args[0]);
+ return CharFromCode(isolate, args[0]);
}
@@ -2385,7 +2394,7 @@
-static Object* StringReplaceRegExpWithString(Heap* heap,
+static Object* StringReplaceRegExpWithString(Isolate* isolate,
String* subject,
JSRegExp* regexp,
String* replacement,
@@ -2393,7 +2402,7 @@
ASSERT(subject->IsFlat());
ASSERT(replacement->IsFlat());
- HandleScope handles;
+ HandleScope handles(isolate);
int length = subject->length();
Handle<String> subject_handle(subject);
@@ -2427,7 +2436,9 @@
// conservatively.
int expected_parts =
(compiled_replacement.parts() + 1) * (is_global ? 4 : 1) + 1;
- ReplacementStringBuilder builder(heap, subject_handle, expected_parts);
+ ReplacementStringBuilder builder(isolate->heap(),
+ subject_handle,
+ expected_parts);
// Index of end of last match.
int prev = 0;
@@ -2443,7 +2454,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;
@@ -2494,13 +2505,13 @@
template <typename ResultSeqString>
-static Object* StringReplaceRegExpWithEmptyString(Heap* heap,
+static Object* 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);
@@ -2514,7 +2525,6 @@
ASSERT(last_match_info_handle->HasFastElements());
- HandleScope loop_scope;
int start, end;
{
AssertNoAllocation match_info_array_is_not_in_a_handle;
@@ -2528,7 +2538,7 @@
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) {
@@ -2584,7 +2594,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 =
@@ -2604,7 +2614,7 @@
}
if (position == 0) {
- return heap->empty_string();
+ return isolate->heap()->empty_string();
}
// Shorten string and fill
@@ -2616,7 +2626,7 @@
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;
}
@@ -2653,14 +2663,14 @@
if (replacement->length() == 0) {
if (subject->HasOnlyAsciiChars()) {
return StringReplaceRegExpWithEmptyString<SeqAsciiString>(
- isolate->heap(), subject, regexp, last_match_info);
+ isolate, subject, regexp, last_match_info);
} else {
return StringReplaceRegExpWithEmptyString<SeqTwoByteString>(
- isolate->heap(), subject, regexp, last_match_info);
+ isolate, subject, regexp, last_match_info);
}
}
- return StringReplaceRegExpWithString(isolate->heap(),
+ return StringReplaceRegExpWithString(isolate,
subject,
regexp,
replacement,
@@ -2724,7 +2734,7 @@
static Object* Runtime_StringIndexOf(RUNTIME_CALLING_CONVENTION) {
RUNTIME_GET_ISOLATE;
- HandleScope scope; // create a new handle scope
+ HandleScope scope(isolate); // create a new handle scope
ASSERT(args.length() == 3);
CONVERT_ARG_CHECKED(String, sub, 0);
@@ -2777,7 +2787,7 @@
static Object* Runtime_StringLastIndexOf(RUNTIME_CALLING_CONVENTION) {
RUNTIME_GET_ISOLATE;
- HandleScope scope; // create a new handle scope
+ HandleScope scope(isolate); // create a new handle scope
ASSERT(args.length() == 3);
CONVERT_ARG_CHECKED(String, sub, 0);
@@ -3118,6 +3128,7 @@
static RegExpImpl::IrregexpResult SearchRegExpNoCaptureMultiple(
+ Isolate* isolate,
Handle<String> subject,
Handle<JSRegExp> regexp,
Handle<JSArray> last_match_array,
@@ -3148,7 +3159,7 @@
match_start);
}
match_end = register_vector[1];
- HandleScope loop_scope;
+ HandleScope loop_scope(isolate);
builder->Add(*Factory::NewSubString(subject, match_start,
match_end));
if (match_start != match_end) {
pos = match_end;
@@ -3182,7 +3193,7 @@
static RegExpImpl::IrregexpResult SearchRegExpMultiple(
- Heap* heap,
+ Isolate* isolate,
Handle<String> subject,
Handle<JSRegExp> regexp,
Handle<JSArray> last_match_array,
@@ -3226,7 +3237,7 @@
{
// 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);
@@ -3245,7 +3256,7 @@
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));
@@ -3338,13 +3349,17 @@
RegExpImpl::IrregexpResult result;
if (regexp->CaptureCount() == 0) {
- result = SearchRegExpNoCaptureMultiple(subject,
+ result = SearchRegExpNoCaptureMultiple(isolate,
+ subject,
regexp,
last_match_info,
&builder);
} else {
- result = SearchRegExpMultiple(isolate->heap(), 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
isolate->heap()->null_value();
@@ -3479,7 +3494,7 @@
}
-Object* Runtime::GetElementOrCharAt(Heap* heap,
+Object* Runtime::GetElementOrCharAt(Isolate* isolate,
Handle<Object> object,
uint32_t index) {
// Handle [] indexing on Strings
@@ -3510,23 +3525,23 @@
}
-Object* Runtime::GetObjectProperty(Heap* heap,
+Object* 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 heap->isolate()->Throw(*error);
+ return isolate->Throw(*error);
}
// Check if the given key is an array index.
uint32_t index;
if (key->ToArrayIndex(&index)) {
- return GetElementOrCharAt(heap, object, index);
+ return GetElementOrCharAt(isolate, object, index);
}
// Convert the key to a string - possibly by calling back into
JavaScript.
@@ -3544,7 +3559,7 @@
// Check if the name is trivially convertible to an index and get
// the element if so.
if (name->AsArrayIndex(&index)) {
- return GetElementOrCharAt(heap, object, index);
+ return GetElementOrCharAt(isolate, object, index);
} else {
PropertyAttributes attr;
return object->GetProperty(*name, &attr);
@@ -3560,7 +3575,7 @@
Handle<Object> object = args.at<Object>(0);
Handle<Object> key = args.at<Object>(1);
- return Runtime::GetObjectProperty(isolate->heap(), object, key);
+ return Runtime::GetObjectProperty(isolate, object, key);
}
@@ -3619,7 +3634,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();
Handle<Object> result = GetCharAt(str, index);
@@ -3627,7 +3642,7 @@
}
// Fall back to GetObjectProperty.
- return Runtime::GetObjectProperty(isolate->heap(),
+ return Runtime::GetObjectProperty(isolate,
args.at<Object>(0),
args.at<Object>(1));
}
@@ -3637,7 +3652,7 @@
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]);
@@ -3666,7 +3681,7 @@
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);
@@ -3714,24 +3729,23 @@
attr);
}
- return Runtime::SetObjectProperty(isolate->heap(), js_object, name,
obj_value,
- attr);
+ return Runtime::SetObjectProperty(isolate, js_object, name, obj_value,
attr);
}
-Object* Runtime::SetObjectProperty(Heap* heap,
+Object* Runtime::SetObjectProperty(Isolate* isolate,
Handle<Object> object,
Handle<Object> key,
Handle<Object> value,
PropertyAttributes attr) {
- 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 heap->isolate()->Throw(*error);
+ return isolate->Throw(*error);
}
// If the object isn't a JavaScript object, we ignore the store.
@@ -3785,11 +3799,12 @@
}
-Object* Runtime::ForceSetObjectProperty(Handle<JSObject> js_object,
+Object* 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;
@@ -3834,10 +3849,10 @@
}
-Object* Runtime::ForceDeleteObjectProperty(Heap* heap,
+Object* 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;
@@ -3849,7 +3864,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);
@@ -3890,8 +3905,7 @@
(unchecked_value & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0);
attributes = static_cast<PropertyAttributes>(unchecked_value);
}
- return Runtime::SetObjectProperty(isolate->heap(), object, key, value,
- attributes);
+ return Runtime::SetObjectProperty(isolate, object, key, value,
attributes);
}
@@ -3931,20 +3945,21 @@
}
-static Object* HasLocalPropertyImplementation(Heap* heap,
+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(heap,
Handle<JSObject>::cast(proto),
+ return HasLocalPropertyImplementation(isolate,
+ Handle<JSObject>::cast(proto),
key);
}
- return heap->false_value();
+ return isolate->heap()->false_value();
}
@@ -3962,8 +3977,8 @@
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(isolate->heap(),
+ HandleScope scope(isolate);
+ return HasLocalPropertyImplementation(isolate,
Handle<JSObject>(object),
Handle<String>(key));
} else if (obj->IsString()) {
@@ -4030,7 +4045,7 @@
static Object* Runtime_GetPropertyNames(RUNTIME_CALLING_CONVENTION) {
RUNTIME_GET_ISOLATE;
- HandleScope scope;
+ HandleScope scope(isolate);
ASSERT(args.length() == 1);
CONVERT_ARG_CHECKED(JSObject, object, 0);
return *GetKeysFor(object);
@@ -4050,7 +4065,7 @@
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);
@@ -4081,7 +4096,7 @@
// args[0]: object
static Object* Runtime_GetLocalPropertyNames(RUNTIME_CALLING_CONVENTION) {
RUNTIME_GET_ISOLATE;
- HandleScope scope;
+ HandleScope scope(isolate);
ASSERT(args.length() == 1);
if (!args[0]->IsJSObject()) {
return isolate->heap()->undefined_value();
@@ -4167,7 +4182,7 @@
// args[0]: object
static Object* Runtime_GetLocalElementNames(RUNTIME_CALLING_CONVENTION) {
RUNTIME_GET_ISOLATE;
- HandleScope scope;
+ HandleScope scope(isolate);
ASSERT(args.length() == 1);
if (!args[0]->IsJSObject()) {
return isolate->heap()->undefined_value();
@@ -4185,7 +4200,7 @@
// args[0]: object
static Object* Runtime_GetInterceptorInfo(RUNTIME_CALLING_CONVENTION) {
RUNTIME_GET_ISOLATE;
- HandleScope scope;
+ HandleScope scope(isolate);
ASSERT(args.length() == 1);
if (!args[0]->IsJSObject()) {
return Smi::FromInt(0);
@@ -4205,7 +4220,7 @@
static Object* Runtime_GetNamedInterceptorPropertyNames(
RUNTIME_CALLING_CONVENTION) {
RUNTIME_GET_ISOLATE;
- HandleScope scope;
+ HandleScope scope(isolate);
ASSERT(args.length() == 1);
CONVERT_ARG_CHECKED(JSObject, obj, 0);
@@ -4222,7 +4237,7 @@
static Object* Runtime_GetIndexedInterceptorElementNames(
RUNTIME_CALLING_CONVENTION) {
RUNTIME_GET_ISOLATE;
- HandleScope scope;
+ HandleScope scope(isolate);
ASSERT(args.length() == 1);
CONVERT_ARG_CHECKED(JSObject, obj, 0);
@@ -4238,7 +4253,7 @@
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);
Handle<FixedArray> contents = GetKeysInFixedArrayFor(object,
LOCAL_ONLY);
@@ -4253,8 +4268,8 @@
copy->set(i, entry);
} else {
ASSERT(entry->IsNumber());
- HandleScope scope;
- Handle<Object> entry_handle(entry);
+ HandleScope scope(isolate);
+ Handle<Object> entry_handle(entry, isolate);
Handle<Object> entry_str = Factory::NumberToString(entry_handle);
copy->set(i, *entry_str);
}
@@ -4284,7 +4299,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);
@@ -4311,7 +4326,7 @@
static Object* Runtime_ToFastProperties(RUNTIME_CALLING_CONVENTION) {
RUNTIME_GET_ISOLATE;
- HandleScope scope;
+ HandleScope scope(isolate);
ASSERT(args.length() == 1);
Handle<Object> object = args.at<Object>(0);
@@ -4327,7 +4342,7 @@
static Object* Runtime_ToSlowProperties(RUNTIME_CALLING_CONVENTION) {
RUNTIME_GET_ISOLATE;
- HandleScope scope;
+ HandleScope scope(isolate);
***The diff for this file has been truncated for email.***
=======================================
--- /branches/experimental/isolates/src/runtime.h Fri Sep 24 17:27:22 2010
+++ /branches/experimental/isolates/src/runtime.h Tue Sep 28 07:20:01 2010
@@ -513,32 +513,33 @@
// Support getting the characters in a string using [] notation as
// in Firefox/SpiderMonkey, Safari and Opera.
- static Object* GetElementOrCharAt(Heap* heap,
+ static Object* GetElementOrCharAt(Isolate* isolate,
Handle<Object> object,
uint32_t index);
static Object* GetElement(Handle<Object> object, uint32_t index);
- static Object* SetObjectProperty(Heap* heap,
+ static Object* SetObjectProperty(Isolate* isolate,
Handle<Object> object,
Handle<Object> key,
Handle<Object> value,
PropertyAttributes attr);
- static Object* ForceSetObjectProperty(Handle<JSObject> object,
+ static Object* ForceSetObjectProperty(Isolate* isolate,
+ Handle<JSObject> object,
Handle<Object> key,
Handle<Object> value,
PropertyAttributes attr);
- static Object* ForceDeleteObjectProperty(Heap* heap,
+ static Object* ForceDeleteObjectProperty(Isolate* isolate,
Handle<JSObject> object,
Handle<Object> key);
- static Object* GetObjectProperty(Heap* heap,
+ static Object* GetObjectProperty(Isolate* isolate,
Handle<Object> object,
Handle<Object> key);
// This function is used in FunctionNameUsing* tests.
- static Object* FindSharedFunctionInfoInScript(Heap* heap,
+ static Object* FindSharedFunctionInfoInScript(Isolate* isolate,
Handle<Script> script,
int position);
=======================================
--- /branches/experimental/isolates/test/cctest/test-func-name-inference.cc
Fri Aug 6 15:56:35 2010
+++ /branches/experimental/isolates/test/cctest/test-func-name-inference.cc
Tue Sep 28 07:20:01 2010
@@ -88,7 +88,9 @@
#ifdef ENABLE_DEBUGGER_SUPPORT
// Obtain SharedFunctionInfo for the function.
Object* shared_func_info_ptr =
- Runtime::FindSharedFunctionInfoInScript(HEAP, i_script, func_pos);
+ Runtime::FindSharedFunctionInfoInScript(Isolate::Current(),
+ i_script,
+ func_pos);
CHECK(shared_func_info_ptr != HEAP->undefined_value());
Handle<SharedFunctionInfo> shared_func_info(
SharedFunctionInfo::cast(shared_func_info_ptr));
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev