Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(196)

Side by Side Diff: src/runtime.cc

Issue 9643001: Inline functions that use arguments object in f.apply(o, arguments) pattern. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: regression test Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 8413 matching lines...) Expand 10 before | Expand all | Expand 10 after
8424 } 8424 }
8425 8425
8426 bool has_activations() { return has_activations_; } 8426 bool has_activations() { return has_activations_; }
8427 8427
8428 private: 8428 private:
8429 JSFunction* function_; 8429 JSFunction* function_;
8430 bool has_activations_; 8430 bool has_activations_;
8431 }; 8431 };
8432 8432
8433 8433
8434 static void MaterializeArgumentsObjectInFrame(Isolate* isolate,
8435 JavaScriptFrame* frame) {
8436 Handle<JSFunction> function(JSFunction::cast(frame->function()), isolate);
8437 Handle<Object> arguments;
8438 for (int i = frame->ComputeExpressionsCount() - 1; i >= 0; --i) {
8439 if (frame->GetExpression(i) == isolate->heap()->arguments_marker()) {
8440 if (arguments.is_null()) {
8441 // FunctionGetArguments can't throw an exception, so cast away the
8442 // doubt with an assert.
8443 arguments = Handle<Object>(
8444 Accessors::FunctionGetArguments(*function,
8445 NULL)->ToObjectUnchecked());
8446 ASSERT(*arguments != isolate->heap()->null_value());
8447 ASSERT(*arguments != isolate->heap()->undefined_value());
8448 }
8449 frame->SetExpression(i, *arguments);
8450 }
8451 }
8452 }
8453
8454
8434 RUNTIME_FUNCTION(MaybeObject*, Runtime_NotifyDeoptimized) { 8455 RUNTIME_FUNCTION(MaybeObject*, Runtime_NotifyDeoptimized) {
8435 HandleScope scope(isolate); 8456 HandleScope scope(isolate);
8436 ASSERT(args.length() == 1); 8457 ASSERT(args.length() == 1);
8437 RUNTIME_ASSERT(args[0]->IsSmi()); 8458 RUNTIME_ASSERT(args[0]->IsSmi());
8438 Deoptimizer::BailoutType type = 8459 Deoptimizer::BailoutType type =
8439 static_cast<Deoptimizer::BailoutType>(args.smi_at(0)); 8460 static_cast<Deoptimizer::BailoutType>(args.smi_at(0));
8440 Deoptimizer* deoptimizer = Deoptimizer::Grab(isolate); 8461 Deoptimizer* deoptimizer = Deoptimizer::Grab(isolate);
8441 ASSERT(isolate->heap()->IsAllocationAllowed()); 8462 ASSERT(isolate->heap()->IsAllocationAllowed());
8442 int jsframes = deoptimizer->jsframe_count(); 8463 int jsframes = deoptimizer->jsframe_count();
8443 8464
8444 deoptimizer->MaterializeHeapNumbers(); 8465 deoptimizer->MaterializeHeapNumbers();
8445 delete deoptimizer; 8466 delete deoptimizer;
8446 8467
8447 JavaScriptFrameIterator it(isolate); 8468 JavaScriptFrameIterator it(isolate);
8448 JavaScriptFrame* frame = NULL; 8469 JavaScriptFrame* frame = NULL;
8449 for (int i = 0; i < jsframes - 1; i++) it.Advance(); 8470 for (int i = 0; i < jsframes - 1; i++) {
8471 MaterializeArgumentsObjectInFrame(isolate, it.frame());
8472 it.Advance();
8473 }
8450 frame = it.frame(); 8474 frame = it.frame();
8451 8475
8452 RUNTIME_ASSERT(frame->function()->IsJSFunction()); 8476 RUNTIME_ASSERT(frame->function()->IsJSFunction());
8453 Handle<JSFunction> function(JSFunction::cast(frame->function()), isolate); 8477 Handle<JSFunction> function(JSFunction::cast(frame->function()), isolate);
8454 Handle<Object> arguments; 8478 MaterializeArgumentsObjectInFrame(isolate, frame);
8455 for (int i = frame->ComputeExpressionsCount() - 1; i >= 0; --i) {
8456 if (frame->GetExpression(i) == isolate->heap()->arguments_marker()) {
8457 if (arguments.is_null()) {
8458 // FunctionGetArguments can't throw an exception, so cast away the
8459 // doubt with an assert.
8460 arguments = Handle<Object>(
8461 Accessors::FunctionGetArguments(*function,
8462 NULL)->ToObjectUnchecked());
8463 ASSERT(*arguments != isolate->heap()->null_value());
8464 ASSERT(*arguments != isolate->heap()->undefined_value());
8465 }
8466 frame->SetExpression(i, *arguments);
8467 }
8468 }
8469 8479
8470 if (type == Deoptimizer::EAGER) { 8480 if (type == Deoptimizer::EAGER) {
8471 RUNTIME_ASSERT(function->IsOptimized()); 8481 RUNTIME_ASSERT(function->IsOptimized());
8472 } 8482 }
8473 8483
8474 // Avoid doing too much work when running with --always-opt and keep 8484 // Avoid doing too much work when running with --always-opt and keep
8475 // the optimized code around. 8485 // the optimized code around.
8476 if (FLAG_always_opt || type == Deoptimizer::LAZY) { 8486 if (FLAG_always_opt || type == Deoptimizer::LAZY) {
8477 return isolate->heap()->undefined_value(); 8487 return isolate->heap()->undefined_value();
8478 } 8488 }
(...skipping 5166 matching lines...) Expand 10 before | Expand all | Expand 10 after
13645 // Handle last resort GC and make sure to allow future allocations 13655 // Handle last resort GC and make sure to allow future allocations
13646 // to grow the heap without causing GCs (if possible). 13656 // to grow the heap without causing GCs (if possible).
13647 isolate->counters()->gc_last_resort_from_js()->Increment(); 13657 isolate->counters()->gc_last_resort_from_js()->Increment();
13648 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, 13658 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags,
13649 "Runtime::PerformGC"); 13659 "Runtime::PerformGC");
13650 } 13660 }
13651 } 13661 }
13652 13662
13653 13663
13654 } } // namespace v8::internal 13664 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698