Index: src/execution.cc |
diff --git a/src/execution.cc b/src/execution.cc |
index 2021c0ff1ff0afa5575ec48573d1b27a949dcad6..29955faff1919b7ed05ec39f5e43a72750f2780e 100644 |
--- a/src/execution.cc |
+++ b/src/execution.cc |
@@ -66,13 +66,13 @@ void StackGuard::reset_limits(const ExecutionAccess& lock) { |
} |
-static Handle<Object> Invoke(bool construct, |
- Handle<JSFunction> func, |
+static Handle<Object> Invoke(bool is_construct, |
+ Handle<JSFunction> function, |
Handle<Object> receiver, |
int argc, |
- Object*** args, |
+ Handle<Object> args[], |
bool* has_pending_exception) { |
- Isolate* isolate = func->GetIsolate(); |
+ Isolate* isolate = function->GetIsolate(); |
// Entering JavaScript. |
VMState state(isolate, JS); |
@@ -80,19 +80,15 @@ static Handle<Object> Invoke(bool construct, |
// Placeholder for return value. |
MaybeObject* value = reinterpret_cast<Object*>(kZapValue); |
- typedef Object* (*JSEntryFunction)( |
- byte* entry, |
- Object* function, |
- Object* receiver, |
- int argc, |
- Object*** args); |
+ typedef Object* (*JSEntryFunction)(byte* entry, |
+ Object* function, |
+ Object* receiver, |
+ int argc, |
+ Object*** args); |
- Handle<Code> code; |
- if (construct) { |
- code = isolate->factory()->js_construct_entry_code(); |
- } else { |
- code = isolate->factory()->js_entry_code(); |
- } |
+ Handle<Code> code = is_construct |
+ ? isolate->factory()->js_construct_entry_code() |
+ : isolate->factory()->js_entry_code(); |
// Convert calls on global objects to be calls on the global |
// receiver instead to avoid having a 'this' pointer which refers |
@@ -104,21 +100,22 @@ static Handle<Object> Invoke(bool construct, |
// Make sure that the global object of the context we're about to |
// make the current one is indeed a global object. |
- ASSERT(func->context()->global()->IsGlobalObject()); |
+ ASSERT(function->context()->global()->IsGlobalObject()); |
{ |
// Save and restore context around invocation and block the |
// allocation of handles without explicit handle scopes. |
SaveContext save(isolate); |
NoHandleAllocation na; |
- JSEntryFunction entry = FUNCTION_CAST<JSEntryFunction>(code->entry()); |
+ JSEntryFunction stub_entry = FUNCTION_CAST<JSEntryFunction>(code->entry()); |
// Call the function through the right JS entry stub. |
- byte* entry_address = func->code()->entry(); |
- JSFunction* function = *func; |
- Object* receiver_pointer = *receiver; |
- value = CALL_GENERATED_CODE(entry, entry_address, function, |
- receiver_pointer, argc, args); |
+ byte* function_entry = function->code()->entry(); |
+ JSFunction* func = *function; |
+ Object* recv = *receiver; |
+ Object*** argv = reinterpret_cast<Object***>(args); |
+ value = |
+ CALL_GENERATED_CODE(stub_entry, function_entry, func, recv, argc, argv); |
} |
#ifdef DEBUG |
@@ -147,7 +144,7 @@ static Handle<Object> Invoke(bool construct, |
Handle<Object> Execution::Call(Handle<Object> callable, |
Handle<Object> receiver, |
int argc, |
- Object*** args, |
+ Handle<Object> argv[], |
bool* pending_exception, |
bool convert_receiver) { |
*pending_exception = false; |
@@ -173,13 +170,15 @@ Handle<Object> Execution::Call(Handle<Object> callable, |
if (*pending_exception) return callable; |
} |
- return Invoke(false, func, receiver, argc, args, pending_exception); |
+ return Invoke(false, func, receiver, argc, argv, pending_exception); |
} |
-Handle<Object> Execution::New(Handle<JSFunction> func, int argc, |
- Object*** args, bool* pending_exception) { |
- return Invoke(true, func, Isolate::Current()->global(), argc, args, |
+Handle<Object> Execution::New(Handle<JSFunction> func, |
+ int argc, |
+ Handle<Object> argv[], |
+ bool* pending_exception) { |
+ return Invoke(true, func, Isolate::Current()->global(), argc, argv, |
pending_exception); |
} |
@@ -187,7 +186,7 @@ Handle<Object> Execution::New(Handle<JSFunction> func, int argc, |
Handle<Object> Execution::TryCall(Handle<JSFunction> func, |
Handle<Object> receiver, |
int argc, |
- Object*** args, |
+ Handle<Object> args[], |
bool* caught_exception) { |
// Enter a try-block while executing the JavaScript code. To avoid |
// duplicate error printing it must be non-verbose. Also, to avoid |
@@ -573,14 +572,15 @@ void StackGuard::InitThread(const ExecutionAccess& lock) { |
// --- C a l l s t o n a t i v e s --- |
-#define RETURN_NATIVE_CALL(name, argc, argv, has_pending_exception) \ |
- do { \ |
- Isolate* isolate = Isolate::Current(); \ |
- Object** args[argc] = argv; \ |
- ASSERT(has_pending_exception != NULL); \ |
- return Call(isolate->name##_fun(), \ |
- isolate->js_builtins_object(), argc, args, \ |
- has_pending_exception); \ |
+#define RETURN_NATIVE_CALL(name, args, has_pending_exception) \ |
+ do { \ |
+ Isolate* isolate = Isolate::Current(); \ |
+ Handle<Object> argv[] = args; \ |
+ ASSERT(has_pending_exception != NULL); \ |
+ return Call(isolate->name##_fun(), \ |
+ isolate->js_builtins_object(), \ |
+ ARRAY_SIZE(argv), argv, \ |
rossberg
2011/10/05 13:10:17
I guess it doesn't matter much, because the macro
Kevin Millikin (Chromium)
2011/10/05 13:47:26
Yeah, it's a bit dangerous and the programmer has
|
+ has_pending_exception); \ |
} while (false) |
@@ -601,44 +601,44 @@ Handle<Object> Execution::ToBoolean(Handle<Object> obj) { |
Handle<Object> Execution::ToNumber(Handle<Object> obj, bool* exc) { |
- RETURN_NATIVE_CALL(to_number, 1, { obj.location() }, exc); |
+ RETURN_NATIVE_CALL(to_number, { obj }, exc); |
} |
Handle<Object> Execution::ToString(Handle<Object> obj, bool* exc) { |
- RETURN_NATIVE_CALL(to_string, 1, { obj.location() }, exc); |
+ RETURN_NATIVE_CALL(to_string, { obj }, exc); |
} |
Handle<Object> Execution::ToDetailString(Handle<Object> obj, bool* exc) { |
- RETURN_NATIVE_CALL(to_detail_string, 1, { obj.location() }, exc); |
+ RETURN_NATIVE_CALL(to_detail_string, { obj }, exc); |
} |
Handle<Object> Execution::ToObject(Handle<Object> obj, bool* exc) { |
if (obj->IsSpecObject()) return obj; |
- RETURN_NATIVE_CALL(to_object, 1, { obj.location() }, exc); |
+ RETURN_NATIVE_CALL(to_object, { obj }, exc); |
} |
Handle<Object> Execution::ToInteger(Handle<Object> obj, bool* exc) { |
- RETURN_NATIVE_CALL(to_integer, 1, { obj.location() }, exc); |
+ RETURN_NATIVE_CALL(to_integer, { obj }, exc); |
} |
Handle<Object> Execution::ToUint32(Handle<Object> obj, bool* exc) { |
- RETURN_NATIVE_CALL(to_uint32, 1, { obj.location() }, exc); |
+ RETURN_NATIVE_CALL(to_uint32, { obj }, exc); |
} |
Handle<Object> Execution::ToInt32(Handle<Object> obj, bool* exc) { |
- RETURN_NATIVE_CALL(to_int32, 1, { obj.location() }, exc); |
+ RETURN_NATIVE_CALL(to_int32, { obj }, exc); |
} |
Handle<Object> Execution::NewDate(double time, bool* exc) { |
Handle<Object> time_obj = FACTORY->NewNumber(time); |
- RETURN_NATIVE_CALL(create_date, 1, { time_obj.location() }, exc); |
+ RETURN_NATIVE_CALL(create_date, { time_obj }, exc); |
} |
@@ -675,7 +675,7 @@ Handle<Object> Execution::CharAt(Handle<String> string, uint32_t index) { |
bool caught_exception; |
Handle<Object> index_object = factory->NewNumberFromInt(int_index); |
- Object** index_arg[] = { index_object.location() }; |
+ Handle<Object> index_arg[] = { index_object }; |
Handle<Object> result = TryCall(Handle<JSFunction>::cast(char_at), |
string, |
ARRAY_SIZE(index_arg), |
@@ -689,7 +689,8 @@ Handle<Object> Execution::CharAt(Handle<String> string, uint32_t index) { |
Handle<JSFunction> Execution::InstantiateFunction( |
- Handle<FunctionTemplateInfo> data, bool* exc) { |
+ Handle<FunctionTemplateInfo> data, |
+ bool* exc) { |
Isolate* isolate = data->GetIsolate(); |
// Fast case: see if the function has already been instantiated |
int serial_number = Smi::cast(data->serial_number())->value(); |
@@ -698,10 +699,12 @@ Handle<JSFunction> Execution::InstantiateFunction( |
GetElementNoExceptionThrown(serial_number); |
if (elm->IsJSFunction()) return Handle<JSFunction>(JSFunction::cast(elm)); |
// The function has not yet been instantiated in this context; do it. |
- Object** args[1] = { Handle<Object>::cast(data).location() }; |
- Handle<Object> result = |
- Call(isolate->instantiate_fun(), |
- isolate->js_builtins_object(), 1, args, exc); |
+ Handle<Object> args[] = { data }; |
+ Handle<Object> result = Call(isolate->instantiate_fun(), |
+ isolate->js_builtins_object(), |
+ ARRAY_SIZE(args), |
+ args, |
+ exc); |
if (*exc) return Handle<JSFunction>::null(); |
return Handle<JSFunction>::cast(result); |
} |
@@ -728,10 +731,12 @@ Handle<JSObject> Execution::InstantiateObject(Handle<ObjectTemplateInfo> data, |
ASSERT(!*exc); |
return Handle<JSObject>(JSObject::cast(result)); |
} else { |
- Object** args[1] = { Handle<Object>::cast(data).location() }; |
- Handle<Object> result = |
- Call(isolate->instantiate_fun(), |
- isolate->js_builtins_object(), 1, args, exc); |
+ Handle<Object> args[] = { data }; |
+ Handle<Object> result = Call(isolate->instantiate_fun(), |
+ isolate->js_builtins_object(), |
+ ARRAY_SIZE(args), |
+ args, |
+ exc); |
if (*exc) return Handle<JSObject>::null(); |
return Handle<JSObject>::cast(result); |
} |
@@ -742,9 +747,12 @@ void Execution::ConfigureInstance(Handle<Object> instance, |
Handle<Object> instance_template, |
bool* exc) { |
Isolate* isolate = Isolate::Current(); |
- Object** args[2] = { instance.location(), instance_template.location() }; |
+ Handle<Object> args[] = { instance, instance_template }; |
Execution::Call(isolate->configure_instance_fun(), |
- isolate->js_builtins_object(), 2, args, exc); |
+ isolate->js_builtins_object(), |
+ ARRAY_SIZE(args), |
+ args, |
+ exc); |
} |
@@ -753,16 +761,13 @@ Handle<String> Execution::GetStackTraceLine(Handle<Object> recv, |
Handle<Object> pos, |
Handle<Object> is_global) { |
Isolate* isolate = fun->GetIsolate(); |
- const int argc = 4; |
- Object** args[argc] = { recv.location(), |
- Handle<Object>::cast(fun).location(), |
- pos.location(), |
- is_global.location() }; |
+ Handle<Object> args[] = { recv, fun, pos, is_global }; |
bool caught_exception; |
- Handle<Object> result = |
- TryCall(isolate->get_stack_trace_line_fun(), |
- isolate->js_builtins_object(), argc, args, |
- &caught_exception); |
+ Handle<Object> result = TryCall(isolate->get_stack_trace_line_fun(), |
+ isolate->js_builtins_object(), |
+ ARRAY_SIZE(args), |
+ args, |
+ &caught_exception); |
if (caught_exception || !result->IsString()) { |
return isolate->factory()->empty_symbol(); |
} |