Push version 2.2.24 to trunk.
Added API for capturing stack traces for uncaught exceptions.
Fixed crash bug when preparsing from a non-external V8 string (issue 775).
Fixed JSON.parse bug causing input not to be converted to string (issue 764).
Added ES5 Object.freeze and Object.isFrozen.
Performance improvements on all platforms.
git-svn-id: http://v8.googlecode.com/svn/trunk@5060 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
diff --git a/src/runtime.cc b/src/runtime.cc
index 4a0fe7a..535d9a9 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -1606,9 +1606,10 @@
if (!EnsureCompiled(shared, KEEP_EXCEPTION)) {
return Failure::Exception();
}
- // Set the code, formal parameter count, and the length of the target
- // function.
+ // Set the code, scope info, formal parameter count,
+ // and the length of the target function.
target->set_code(fun->code());
+ target->shared()->set_scope_info(shared->scope_info());
target->shared()->set_length(shared->length());
target->shared()->set_formal_parameter_count(
shared->formal_parameter_count());
@@ -5608,6 +5609,14 @@
}
+static Object* Runtime_NumberAlloc(Arguments args) {
+ NoHandleAllocation ha;
+ ASSERT(args.length() == 0);
+
+ return Heap::NumberFromDouble(9876543210.0);
+}
+
+
static Object* Runtime_NumberDiv(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
@@ -6860,7 +6869,8 @@
ASSERT(args.length() == 1);
CONVERT_CHECKED(JSFunction, function, args[0]);
- int length = ScopeInfo<>::NumberOfContextSlots(function->code());
+ int length =
+ ScopeInfo<>::NumberOfContextSlots(function->shared()->scope_info());
Object* result = Heap::AllocateFunctionContext(length, function);
if (result->IsFailure()) return result;
@@ -8480,9 +8490,10 @@
// Check for constructor frame.
bool constructor = it.frame()->IsConstructor();
- // Get code and read scope info from it for local variable information.
- Handle<Code> code(it.frame()->code());
- ScopeInfo<> info(*code);
+ // Get scope info and read from it for local variable information.
+ Handle<JSFunction> function(JSFunction::cast(it.frame()->function()));
+ Handle<Object> scope_info(function->shared()->scope_info());
+ ScopeInfo<> info(*scope_info);
// Get the context.
Handle<Context> context(Context::cast(it.frame()->context()));
@@ -8510,7 +8521,8 @@
}
ASSERT(context->is_function_context());
locals->set(i * 2 + 1,
- context->get(ScopeInfo<>::ContextSlotIndex(*code, *name,
+ context->get(ScopeInfo<>::ContextSlotIndex(*scope_info,
+ *name,
NULL)));
}
}
@@ -8651,7 +8663,7 @@
// Copy all the context locals into an object used to materialize a scope.
-static void CopyContextLocalsToScopeObject(Handle<Code> code,
+static void CopyContextLocalsToScopeObject(Handle<SharedFunctionInfo> shared,
ScopeInfo<>& scope_info,
Handle<Context> context,
Handle<JSObject> scope_object) {
@@ -8660,7 +8672,7 @@
i < scope_info.number_of_context_slots();
i++) {
int context_index =
- ScopeInfo<>::ContextSlotIndex(*code,
+ ScopeInfo<>::ContextSlotIndex(shared->scope_info(),
*scope_info.context_slot_name(i),
NULL);
@@ -8678,8 +8690,8 @@
// frame.
static Handle<JSObject> MaterializeLocalScope(JavaScriptFrame* frame) {
Handle<JSFunction> function(JSFunction::cast(frame->function()));
- Handle<Code> code(function->code());
- ScopeInfo<> scope_info(*code);
+ Handle<SharedFunctionInfo> shared(function->shared());
+ ScopeInfo<> scope_info(shared->scope_info());
// Allocate and initialize a JSObject with all the arguments, stack locals
// heap locals and extension properties of the debugged function.
@@ -8702,7 +8714,7 @@
// Third fill all context locals.
Handle<Context> frame_context(Context::cast(frame->context()));
Handle<Context> function_context(frame_context->fcontext());
- CopyContextLocalsToScopeObject(code, scope_info,
+ CopyContextLocalsToScopeObject(shared, scope_info,
function_context, local_scope);
// Finally copy any properties from the function context extension. This will
@@ -8729,8 +8741,8 @@
static Handle<JSObject> MaterializeClosure(Handle<Context> context) {
ASSERT(context->is_function_context());
- Handle<Code> code(context->closure()->code());
- ScopeInfo<> scope_info(*code);
+ Handle<SharedFunctionInfo> shared(context->closure()->shared());
+ ScopeInfo<> scope_info(shared->scope_info());
// Allocate and initialize a JSObject with all the content of theis function
// closure.
@@ -8738,7 +8750,7 @@
// Check whether the arguments shadow object exists.
int arguments_shadow_index =
- ScopeInfo<>::ContextSlotIndex(*code,
+ ScopeInfo<>::ContextSlotIndex(shared->scope_info(),
Heap::arguments_shadow_symbol(),
NULL);
if (arguments_shadow_index >= 0) {
@@ -8754,7 +8766,7 @@
}
// Fill all context locals to the context extension.
- CopyContextLocalsToScopeObject(code, scope_info, context, closure_scope);
+ CopyContextLocalsToScopeObject(shared, scope_info, context, closure_scope);
// Finally copy any properties from the function context extension. This will
// be variables introduced by eval.
@@ -8803,8 +8815,8 @@
// created for evaluating top level code and it is not a real local scope.
// Checking for the existence of .result seems fragile, but the scope info
// saved with the code object does not otherwise have that information.
- Handle<Code> code(function_->code());
- int index = ScopeInfo<>::StackSlotIndex(*code, Heap::result_symbol());
+ int index = ScopeInfo<>::StackSlotIndex(function_->shared()->scope_info(),
+ Heap::result_symbol());
at_local_ = index < 0;
} else if (context_->is_function_context()) {
at_local_ = true;
@@ -8918,8 +8930,7 @@
case ScopeIterator::ScopeTypeLocal: {
PrintF("Local:\n");
- Handle<Code> code(function_->code());
- ScopeInfo<> scope_info(*code);
+ ScopeInfo<> scope_info(function_->shared()->scope_info());
scope_info.Print();
if (!CurrentContext().is_null()) {
CurrentContext()->Print();
@@ -9443,7 +9454,7 @@
// Runtime_DebugEvaluate.
static Handle<Object> GetArgumentsObject(JavaScriptFrame* frame,
Handle<JSFunction> function,
- Handle<Code> code,
+ Handle<Object> scope_info,
const ScopeInfo<>* sinfo,
Handle<Context> function_context) {
// Try to find the value of 'arguments' to pass as parameter. If it is not
@@ -9451,14 +9462,14 @@
// does not support eval) then create an 'arguments' object.
int index;
if (sinfo->number_of_stack_slots() > 0) {
- index = ScopeInfo<>::StackSlotIndex(*code, Heap::arguments_symbol());
+ index = ScopeInfo<>::StackSlotIndex(*scope_info, Heap::arguments_symbol());
if (index != -1) {
return Handle<Object>(frame->GetExpression(index));
}
}
if (sinfo->number_of_context_slots() > Context::MIN_CONTEXT_SLOTS) {
- index = ScopeInfo<>::ContextSlotIndex(*code, Heap::arguments_symbol(),
+ index = ScopeInfo<>::ContextSlotIndex(*scope_info, Heap::arguments_symbol(),
NULL);
if (index != -1) {
return Handle<Object>(function_context->get(index));
@@ -9510,8 +9521,8 @@
JavaScriptFrameIterator it(id);
JavaScriptFrame* frame = it.frame();
Handle<JSFunction> function(JSFunction::cast(frame->function()));
- Handle<Code> code(function->code());
- ScopeInfo<> sinfo(*code);
+ Handle<Object> scope_info(function->shared()->scope_info());
+ ScopeInfo<> sinfo(*scope_info);
// Traverse the saved contexts chain to find the active context for the
// selected frame.
@@ -9533,7 +9544,7 @@
Factory::NewFunction(Factory::empty_string(), Factory::undefined_value());
go_between->set_context(function->context());
#ifdef DEBUG
- ScopeInfo<> go_between_sinfo(go_between->shared()->code());
+ ScopeInfo<> go_between_sinfo(go_between->shared()->scope_info());
ASSERT(go_between_sinfo.number_of_parameters() == 0);
ASSERT(go_between_sinfo.number_of_context_slots() == 0);
#endif
@@ -9579,8 +9590,8 @@
&has_pending_exception);
if (has_pending_exception) return Failure::Exception();
- Handle<Object> arguments = GetArgumentsObject(frame, function, code, &sinfo,
- function_context);
+ Handle<Object> arguments = GetArgumentsObject(frame, function, scope_info,
+ &sinfo, function_context);
// Invoke the evaluation function and return the result.
const int argc = 2;