| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 7183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7194 return Heap::undefined_value(); | 7194 return Heap::undefined_value(); |
| 7195 } | 7195 } |
| 7196 | 7196 |
| 7197 | 7197 |
| 7198 static MaybeObject* Runtime_CompileForOnStackReplacement(Arguments args) { | 7198 static MaybeObject* Runtime_CompileForOnStackReplacement(Arguments args) { |
| 7199 HandleScope scope; | 7199 HandleScope scope; |
| 7200 ASSERT(args.length() == 1); | 7200 ASSERT(args.length() == 1); |
| 7201 CONVERT_ARG_CHECKED(JSFunction, function, 0); | 7201 CONVERT_ARG_CHECKED(JSFunction, function, 0); |
| 7202 | 7202 |
| 7203 // We're not prepared to handle a function with arguments object. | 7203 // We're not prepared to handle a function with arguments object. |
| 7204 ASSERT(!function->shared()->scope_info()->HasArgumentsShadow()); | 7204 ASSERT(!function->shared()->uses_arguments()); |
| 7205 | 7205 |
| 7206 // We have hit a back edge in an unoptimized frame for a function that was | 7206 // We have hit a back edge in an unoptimized frame for a function that was |
| 7207 // selected for on-stack replacement. Find the unoptimized code object. | 7207 // selected for on-stack replacement. Find the unoptimized code object. |
| 7208 Handle<Code> unoptimized(function->shared()->code()); | 7208 Handle<Code> unoptimized(function->shared()->code()); |
| 7209 // Keep track of whether we've succeeded in optimizing. | 7209 // Keep track of whether we've succeeded in optimizing. |
| 7210 bool succeeded = unoptimized->optimizable(); | 7210 bool succeeded = unoptimized->optimizable(); |
| 7211 if (succeeded) { | 7211 if (succeeded) { |
| 7212 // If we are trying to do OSR when there are already optimized | 7212 // If we are trying to do OSR when there are already optimized |
| 7213 // activations of the function, it means (a) the function is directly or | 7213 // activations of the function, it means (a) the function is directly or |
| 7214 // indirectly recursive and (b) an optimized invocation has been | 7214 // indirectly recursive and (b) an optimized invocation has been |
| (...skipping 2148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9363 ScopeInfo<>& scope_info, | 9363 ScopeInfo<>& scope_info, |
| 9364 Handle<Context> context, | 9364 Handle<Context> context, |
| 9365 Handle<JSObject> scope_object) { | 9365 Handle<JSObject> scope_object) { |
| 9366 // Fill all context locals to the context extension. | 9366 // Fill all context locals to the context extension. |
| 9367 for (int i = Context::MIN_CONTEXT_SLOTS; | 9367 for (int i = Context::MIN_CONTEXT_SLOTS; |
| 9368 i < scope_info.number_of_context_slots(); | 9368 i < scope_info.number_of_context_slots(); |
| 9369 i++) { | 9369 i++) { |
| 9370 int context_index = serialized_scope_info->ContextSlotIndex( | 9370 int context_index = serialized_scope_info->ContextSlotIndex( |
| 9371 *scope_info.context_slot_name(i), NULL); | 9371 *scope_info.context_slot_name(i), NULL); |
| 9372 | 9372 |
| 9373 // Don't include the arguments shadow (.arguments) context variable. | 9373 RETURN_IF_EMPTY_HANDLE_VALUE( |
| 9374 if (*scope_info.context_slot_name(i) != Heap::arguments_shadow_symbol()) { | 9374 SetProperty(scope_object, |
| 9375 RETURN_IF_EMPTY_HANDLE_VALUE( | 9375 scope_info.context_slot_name(i), |
| 9376 SetProperty(scope_object, | 9376 Handle<Object>(context->get(context_index)), |
| 9377 scope_info.context_slot_name(i), | 9377 NONE, |
| 9378 Handle<Object>(context->get(context_index)), | 9378 kNonStrictMode), |
| 9379 NONE, | 9379 false); |
| 9380 kNonStrictMode), | |
| 9381 false); | |
| 9382 } | |
| 9383 } | 9380 } |
| 9384 | 9381 |
| 9385 return true; | 9382 return true; |
| 9386 } | 9383 } |
| 9387 | 9384 |
| 9388 | 9385 |
| 9389 // Create a plain JSObject which materializes the local scope for the specified | 9386 // Create a plain JSObject which materializes the local scope for the specified |
| 9390 // frame. | 9387 // frame. |
| 9391 static Handle<JSObject> MaterializeLocalScope(JavaScriptFrame* frame) { | 9388 static Handle<JSObject> MaterializeLocalScope(JavaScriptFrame* frame) { |
| 9392 Handle<JSFunction> function(JSFunction::cast(frame->function())); | 9389 Handle<JSFunction> function(JSFunction::cast(frame->function())); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9459 ASSERT(context->is_function_context()); | 9456 ASSERT(context->is_function_context()); |
| 9460 | 9457 |
| 9461 Handle<SharedFunctionInfo> shared(context->closure()->shared()); | 9458 Handle<SharedFunctionInfo> shared(context->closure()->shared()); |
| 9462 Handle<SerializedScopeInfo> serialized_scope_info(shared->scope_info()); | 9459 Handle<SerializedScopeInfo> serialized_scope_info(shared->scope_info()); |
| 9463 ScopeInfo<> scope_info(*serialized_scope_info); | 9460 ScopeInfo<> scope_info(*serialized_scope_info); |
| 9464 | 9461 |
| 9465 // Allocate and initialize a JSObject with all the content of theis function | 9462 // Allocate and initialize a JSObject with all the content of theis function |
| 9466 // closure. | 9463 // closure. |
| 9467 Handle<JSObject> closure_scope = Factory::NewJSObject(Top::object_function()); | 9464 Handle<JSObject> closure_scope = Factory::NewJSObject(Top::object_function()); |
| 9468 | 9465 |
| 9469 // Check whether the arguments shadow object exists. | |
| 9470 int arguments_shadow_index = | |
| 9471 shared->scope_info()->ContextSlotIndex(Heap::arguments_shadow_symbol(), | |
| 9472 NULL); | |
| 9473 if (arguments_shadow_index >= 0) { | |
| 9474 // In this case all the arguments are available in the arguments shadow | |
| 9475 // object. | |
| 9476 Handle<JSObject> arguments_shadow( | |
| 9477 JSObject::cast(context->get(arguments_shadow_index))); | |
| 9478 for (int i = 0; i < scope_info.number_of_parameters(); ++i) { | |
| 9479 // We don't expect exception-throwing getters on the arguments shadow. | |
| 9480 Object* element = arguments_shadow->GetElement(i)->ToObjectUnchecked(); | |
| 9481 RETURN_IF_EMPTY_HANDLE_VALUE( | |
| 9482 SetProperty(closure_scope, | |
| 9483 scope_info.parameter_name(i), | |
| 9484 Handle<Object>(element), | |
| 9485 NONE, | |
| 9486 kNonStrictMode), | |
| 9487 Handle<JSObject>()); | |
| 9488 } | |
| 9489 } | |
| 9490 | |
| 9491 // Fill all context locals to the context extension. | 9466 // Fill all context locals to the context extension. |
| 9492 if (!CopyContextLocalsToScopeObject(serialized_scope_info, scope_info, | 9467 if (!CopyContextLocalsToScopeObject(serialized_scope_info, scope_info, |
| 9493 context, closure_scope)) { | 9468 context, closure_scope)) { |
| 9494 return Handle<JSObject>(); | 9469 return Handle<JSObject>(); |
| 9495 } | 9470 } |
| 9496 | 9471 |
| 9497 // Finally copy any properties from the function context extension. This will | 9472 // Finally copy any properties from the function context extension. This will |
| 9498 // be variables introduced by eval. | 9473 // be variables introduced by eval. |
| 9499 if (context->has_extension()) { | 9474 if (context->has_extension()) { |
| 9500 Handle<JSObject> ext(JSObject::cast(context->extension())); | 9475 Handle<JSObject> ext(JSObject::cast(context->extension())); |
| (...skipping 2132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11633 } else { | 11608 } else { |
| 11634 // Handle last resort GC and make sure to allow future allocations | 11609 // Handle last resort GC and make sure to allow future allocations |
| 11635 // to grow the heap without causing GCs (if possible). | 11610 // to grow the heap without causing GCs (if possible). |
| 11636 Counters::gc_last_resort_from_js.Increment(); | 11611 Counters::gc_last_resort_from_js.Increment(); |
| 11637 Heap::CollectAllGarbage(false); | 11612 Heap::CollectAllGarbage(false); |
| 11638 } | 11613 } |
| 11639 } | 11614 } |
| 11640 | 11615 |
| 11641 | 11616 |
| 11642 } } // namespace v8::internal | 11617 } } // namespace v8::internal |
| OLD | NEW |