| Index: src/runtime.cc
|
| diff --git a/src/runtime.cc b/src/runtime.cc
|
| index 10de6f9e5ec001c595a0b86632599f9be9a22074..69acb4a55e30354ae70061a7cf9c7ee88d99cb73 100644
|
| --- a/src/runtime.cc
|
| +++ b/src/runtime.cc
|
| @@ -8294,26 +8294,24 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_InstallRecompiledCode) {
|
|
|
| class ActivationsFinder : public ThreadVisitor {
|
| public:
|
| - explicit ActivationsFinder(JSFunction* function)
|
| - : function_(function), has_activations_(false) {}
|
| + Code* code_;
|
| + bool has_code_activations_;
|
| +
|
| + explicit ActivationsFinder(Code* code)
|
| + : code_(code),
|
| + has_code_activations_(false) { }
|
|
|
| void VisitThread(Isolate* isolate, ThreadLocalTop* top) {
|
| - if (has_activations_) return;
|
| + JavaScriptFrameIterator it(isolate, top);
|
| + VisitFrames(&it);
|
| + }
|
|
|
| - for (JavaScriptFrameIterator it(isolate, top); !it.done(); it.Advance()) {
|
| - JavaScriptFrame* frame = it.frame();
|
| - if (frame->is_optimized() && frame->function() == function_) {
|
| - has_activations_ = true;
|
| - return;
|
| - }
|
| + void VisitFrames(JavaScriptFrameIterator* it) {
|
| + for (; !it->done(); it->Advance()) {
|
| + JavaScriptFrame* frame = it->frame();
|
| + if (code_->contains(frame->pc())) has_code_activations_ = true;
|
| }
|
| }
|
| -
|
| - bool has_activations() { return has_activations_; }
|
| -
|
| - private:
|
| - JSFunction* function_;
|
| - bool has_activations_;
|
| };
|
|
|
|
|
| @@ -8336,7 +8334,11 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_NotifyDeoptimized) {
|
| Deoptimizer* deoptimizer = Deoptimizer::Grab(isolate);
|
| ASSERT(AllowHeapAllocation::IsAllowed());
|
|
|
| - ASSERT(deoptimizer->compiled_code_kind() == Code::OPTIMIZED_FUNCTION);
|
| + Handle<JSFunction> function = deoptimizer->function();
|
| + Handle<Code> optimized_code = deoptimizer->compiled_code();
|
| +
|
| + ASSERT(optimized_code->kind() == Code::OPTIMIZED_FUNCTION);
|
| + ASSERT(type == deoptimizer->bailout_type());
|
|
|
| // Make sure to materialize objects before causing any allocation.
|
| JavaScriptFrameIterator it(isolate);
|
| @@ -8345,10 +8347,6 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_NotifyDeoptimized) {
|
|
|
| JavaScriptFrame* frame = it.frame();
|
| RUNTIME_ASSERT(frame->function()->IsJSFunction());
|
| - Handle<JSFunction> function(frame->function(), isolate);
|
| - Handle<Code> optimized_code(function->code());
|
| - RUNTIME_ASSERT((type != Deoptimizer::EAGER &&
|
| - type != Deoptimizer::SOFT) || function->IsOptimized());
|
|
|
| // Avoid doing too much work when running with --always-opt and keep
|
| // the optimized code around.
|
| @@ -8356,33 +8354,24 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_NotifyDeoptimized) {
|
| return isolate->heap()->undefined_value();
|
| }
|
|
|
| - // Find other optimized activations of the function or functions that
|
| - // share the same optimized code.
|
| - bool has_other_activations = false;
|
| - while (!it.done()) {
|
| - JavaScriptFrame* frame = it.frame();
|
| - JSFunction* other_function = frame->function();
|
| - if (frame->is_optimized() && other_function->code() == function->code()) {
|
| - has_other_activations = true;
|
| - break;
|
| - }
|
| - it.Advance();
|
| - }
|
| -
|
| - if (!has_other_activations) {
|
| - ActivationsFinder activations_finder(*function);
|
| - isolate->thread_manager()->IterateArchivedThreads(&activations_finder);
|
| - has_other_activations = activations_finder.has_activations();
|
| - }
|
| + // Search for other activations of the same function and code.
|
| + ActivationsFinder activations_finder(*optimized_code);
|
| + activations_finder.VisitFrames(&it);
|
| + isolate->thread_manager()->IterateArchivedThreads(&activations_finder);
|
|
|
| - if (!has_other_activations) {
|
| - if (FLAG_trace_deopt) {
|
| - PrintF("[removing optimized code for: ");
|
| - function->PrintName();
|
| - PrintF("]\n");
|
| + if (!activations_finder.has_code_activations_) {
|
| + if (function->code() == *optimized_code) {
|
| + if (FLAG_trace_deopt) {
|
| + PrintF("[removing optimized code for: ");
|
| + function->PrintName();
|
| + PrintF("]\n");
|
| + }
|
| + function->ReplaceCode(function->shared()->code());
|
| }
|
| - function->ReplaceCode(function->shared()->code());
|
| } else {
|
| + // TODO(titzer): we should probably do DeoptimizeCodeList(code)
|
| + // unconditionally if the code is not already marked for deoptimization.
|
| + // If there is an index by shared function info, all the better.
|
| Deoptimizer::DeoptimizeFunction(*function);
|
| }
|
| // Evict optimized code for this function from the cache so that it doesn't
|
| @@ -8635,6 +8624,19 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_CompileForOnStackReplacement) {
|
| }
|
|
|
|
|
| +RUNTIME_FUNCTION(MaybeObject*, Runtime_SetAllocationTimeout) {
|
| + SealHandleScope shs(isolate);
|
| + ASSERT(args.length() == 2);
|
| +#ifdef DEBUG
|
| + CONVERT_SMI_ARG_CHECKED(interval, 0);
|
| + CONVERT_SMI_ARG_CHECKED(timeout, 1);
|
| + isolate->heap()->set_allocation_timeout(timeout);
|
| + FLAG_gc_interval = interval;
|
| +#endif
|
| + return isolate->heap()->undefined_value();
|
| +}
|
| +
|
| +
|
| RUNTIME_FUNCTION(MaybeObject*, Runtime_CheckIsBootstrapping) {
|
| SealHandleScope shs(isolate);
|
| RUNTIME_ASSERT(isolate->bootstrapper()->IsActive());
|
| @@ -13639,7 +13641,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_InternalDateFormat) {
|
| CONVERT_ARG_HANDLE_CHECKED(JSDate, date, 1);
|
|
|
| bool has_pending_exception = false;
|
| - double millis = Execution::ToNumber(date, &has_pending_exception)->Number();
|
| + Handle<Object> value = Execution::ToNumber(date, &has_pending_exception);
|
| if (has_pending_exception) {
|
| ASSERT(isolate->has_pending_exception());
|
| return Failure::Exception();
|
| @@ -13650,7 +13652,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_InternalDateFormat) {
|
| if (!date_format) return isolate->ThrowIllegalOperation();
|
|
|
| icu::UnicodeString result;
|
| - date_format->format(millis, result);
|
| + date_format->format(value->Number(), result);
|
|
|
| return *isolate->factory()->NewStringFromTwoByte(
|
| Vector<const uint16_t>(
|
| @@ -13743,7 +13745,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_InternalNumberFormat) {
|
| CONVERT_ARG_HANDLE_CHECKED(Object, number, 1);
|
|
|
| bool has_pending_exception = false;
|
| - double value = Execution::ToNumber(number, &has_pending_exception)->Number();
|
| + Handle<Object> value = Execution::ToNumber(number, &has_pending_exception);
|
| if (has_pending_exception) {
|
| ASSERT(isolate->has_pending_exception());
|
| return Failure::Exception();
|
| @@ -13754,7 +13756,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_InternalNumberFormat) {
|
| if (!number_format) return isolate->ThrowIllegalOperation();
|
|
|
| icu::UnicodeString result;
|
| - number_format->format(value, result);
|
| + number_format->format(value->Number(), result);
|
|
|
| return *isolate->factory()->NewStringFromTwoByte(
|
| Vector<const uint16_t>(
|
| @@ -13993,6 +13995,14 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_FlattenString) {
|
| }
|
|
|
|
|
| +RUNTIME_FUNCTION(MaybeObject*, Runtime_NotifyContextDisposed) {
|
| + HandleScope scope(isolate);
|
| + ASSERT(args.length() == 0);
|
| + isolate->heap()->NotifyContextDisposed();
|
| + return isolate->heap()->undefined_value();
|
| +}
|
| +
|
| +
|
| RUNTIME_FUNCTION(MaybeObject*, Runtime_MigrateInstance) {
|
| HandleScope scope(isolate);
|
| ASSERT(args.length() == 1);
|
|
|