Skip to content

Commit

Permalink
Bug 936156 - Mark run once lambdas inner to other run once lambdas, a…
Browse files Browse the repository at this point in the history
…llow inlining foo.call(a) calls, r=jandem.
  • Loading branch information
bhackett1024 committed Dec 6, 2013
1 parent 2082717 commit 4d4b375
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion js/src/frontend/BytecodeEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5510,7 +5510,7 @@ EmitCallOrNew(ExclusiveContext *cx, BytecodeEmitter *bce, ParseNode *pn)
* will just cause the inner scripts to be repeatedly cloned.
*/
JS_ASSERT(!bce->emittingRunOnceLambda);
if (bce->checkSingletonContext()) {
if (bce->checkSingletonContext() || (!bce->isInLoop() && bce->isRunOnceLambda())) {
bce->emittingRunOnceLambda = true;
if (!EmitTree(cx, bce, pn2))
return false;
Expand Down
6 changes: 4 additions & 2 deletions js/src/jit/IonBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4792,9 +4792,11 @@ IonBuilder::jsop_funcall(uint32_t argc)
// Shimmy the slots down to remove the native 'call' function.
current->shimmySlots(funcDepth - 1);

bool zeroArguments = (argc == 0);

// If no |this| argument was provided, explicitly pass Undefined.
// Pushing is safe here, since one stack slot has been removed.
if (argc == 0) {
if (zeroArguments) {
MConstant *undef = MConstant::New(alloc(), UndefinedValue());
current->add(undef);
MPassArg *pass = MPassArg::New(alloc(), undef);
Expand All @@ -4810,7 +4812,7 @@ IonBuilder::jsop_funcall(uint32_t argc)
return false;

// Try to inline the call.
if (argc > 0) {
if (!zeroArguments) {
InliningDecision decision = makeInliningDecision(target, callInfo);
switch (decision) {
case InliningDecision_Error:
Expand Down

0 comments on commit 4d4b375

Please sign in to comment.