Changeset 178517 in webkit


Ignore:
Timestamp:
Jan 15, 2015 11:20:03 AM (9 years ago)
Author:
mark.lam@apple.com
Message:

[Part 2] Argument object created by "Function dot arguments" should use a clone of argument values.
<https://webkit.org/b/140093>

Reviewed by Geoffrey Garen.

Source/JavaScriptCore:

  • interpreter/StackVisitor.cpp:

(JSC::StackVisitor::Frame::createArguments):

  • We should not fetching the lexicalEnvironment here. The reason we've introduced the ClonedArgumentsCreationMode is because the lexicalEnvironment may not be available to us at this point. Instead, we'll just pass a nullptr.
  • runtime/Arguments.cpp:

(JSC::Arguments::tearOffForCloning):

  • runtime/Arguments.h:

(JSC::Arguments::finishCreation):

  • Use the new tearOffForCloning() to tear off arguments right out of the values passed on the stack. tearOff() is not appropriate for this purpose because it takes slowArgumentsData into account.

LayoutTests:

  • js/function-dot-arguments-expected.txt:
  • js/script-tests/function-dot-arguments.js:

(arrayify):
(indirectCall):
(.inner):
(tearOffTest3):
(tearOffTest3b):
(tearOffTest3c):
(tearOffTest4External):
(tearOffTest4):
(tearOffTest4aExternal):
(tearOffTest4bExternal):
(tearOffTest4b):
(tearOffTest4cExternal):
(tearOffTest4c):
(tearOffTest5):
(tearOffTest5b):
(tearOffTest5c):
(tearOffTest6External):
(tearOffTest6):
(tearOffTest6aExternal):
(tearOffTest6bExternal):
(tearOffTest6b):
(tearOffTest6cExternal):
(tearOffTest6c):
(tearOffTest7):
(tearOffTest7b):
(tearOffTest7c):
(tearOffTest8External):
(tearOffTest8):
(tearOffTest8aExternal):
(tearOffTest8bExternal):
(tearOffTest8b):
(tearOffTest8cExternal):
(tearOffTest8c):
(tearOffTest9b):
(tearOffTest9c):
(tearOffTest10External):
(tearOffTest10):
(tearOffTest10aExternal):
(tearOffTest10bExternal):
(tearOffTest10b):
(tearOffTest10cExternal):
(tearOffTest10c):

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r178516 r178517  
     12015-01-15  Mark Lam  <mark.lam@apple.com>
     2
     3        [Part 2] Argument object created by "Function dot arguments" should use a clone of argument values.
     4        <https://webkit.org/b/140093>
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        * js/function-dot-arguments-expected.txt:
     9        * js/script-tests/function-dot-arguments.js:
     10        (arrayify):
     11        (indirectCall):
     12        (.inner):
     13        (tearOffTest3):
     14        (tearOffTest3b):
     15        (tearOffTest3c):
     16        (tearOffTest4External):
     17        (tearOffTest4):
     18        (tearOffTest4aExternal):
     19        (tearOffTest4bExternal):
     20        (tearOffTest4b):
     21        (tearOffTest4cExternal):
     22        (tearOffTest4c):
     23        (tearOffTest5):
     24        (tearOffTest5b):
     25        (tearOffTest5c):
     26        (tearOffTest6External):
     27        (tearOffTest6):
     28        (tearOffTest6aExternal):
     29        (tearOffTest6bExternal):
     30        (tearOffTest6b):
     31        (tearOffTest6cExternal):
     32        (tearOffTest6c):
     33        (tearOffTest7):
     34        (tearOffTest7b):
     35        (tearOffTest7c):
     36        (tearOffTest8External):
     37        (tearOffTest8):
     38        (tearOffTest8aExternal):
     39        (tearOffTest8bExternal):
     40        (tearOffTest8b):
     41        (tearOffTest8cExternal):
     42        (tearOffTest8c):
     43        (tearOffTest9b):
     44        (tearOffTest9c):
     45        (tearOffTest10External):
     46        (tearOffTest10):
     47        (tearOffTest10aExternal):
     48        (tearOffTest10bExternal):
     49        (tearOffTest10b):
     50        (tearOffTest10cExternal):
     51        (tearOffTest10c):
     52
    1532015-01-15  Brent Fulgham  <bfulgham@apple.com>
    254
  • trunk/LayoutTests/js/function-dot-arguments-expected.txt

    r128111 r178517  
    2525PASS tearOffTest()[0] is true
    2626PASS tearOffTest2(true)[0] is true
     27PASS tearOffTest3(1, 2, 3, false) is [10, 2, 3, false]
     28PASS tearOffTest3a(1, 2, 3, false) is [10, 2, 3, false]
     29PASS tearOffTest3b(1, 2, 3, false) is [1, 2, 3, false]
     30PASS tearOffTest3c(1, 2, 3, false) is [1, 2, 3, false]
     31PASS tearOffTest4(1, 2, 3, false) is [10, 2, 3, false]
     32PASS tearOffTest4a(1, 2, 3, false) is [10, 2, 3, false]
     33PASS tearOffTest4b(1, 2, 3, false) is [1, 2, 3, false]
     34PASS tearOffTest4c(1, 2, 3, false) is [1, 2, 3, false]
     35PASS tearOffTest5(1, 2, 3, false) is [10, 2, 3, false]
     36PASS tearOffTest5a(1, 2, 3, false) is [10, 2, 3, false]
     37PASS tearOffTest5b(1, 2, 3, false) is [1, 2, 3, false]
     38PASS tearOffTest5c(1, 2, 3, false) is [1, 2, 3, false]
     39PASS tearOffTest6(1, 2, 3, false) is [10, 2, 3, false]
     40PASS tearOffTest6a(1, 2, 3, false) is [10, 2, 3, false]
     41PASS tearOffTest6b(1, 2, 3, false) is [1, 2, 3, false]
     42PASS tearOffTest6c(1, 2, 3, false) is [1, 2, 3, false]
     43PASS tearOffTest7(1, 2, 3, false) is [10, 2, 3, false]
     44PASS tearOffTest7a(1, 2, 3, false) is [10, 2, 3, false]
     45PASS tearOffTest7b(1, 2, 3, false) is [10, 2, 3, false]
     46PASS tearOffTest7c(1, 2, 3, false) is [10, 2, 3, false]
     47PASS tearOffTest8(1, 2, 3, false) is [10, 2, 3, false]
     48PASS tearOffTest8a(1, 2, 3, false) is [10, 2, 3, false]
     49PASS tearOffTest8b(1, 2, 3, false) is [10, 2, 3, false]
     50PASS tearOffTest8c(1, 2, 3, false) is [10, 2, 3, false]
     51PASS tearOffTest9(1, 2, 3, false) is [undefined, 2, 3, false]
     52PASS tearOffTest9a(1, 2, 3, false) is [undefined, 2, 3, false]
     53PASS tearOffTest9b(1, 2, 3, false) is [undefined, 2, 3, false]
     54PASS tearOffTest9c(1, 2, 3, false) is [undefined, 2, 3, false]
     55PASS tearOffTest10(1, 2, 3, false) is [undefined, 2, 3, false]
     56PASS tearOffTest10a(1, 2, 3, false) is [undefined, 2, 3, false]
     57PASS tearOffTest10b(1, 2, 3, false) is [undefined, 2, 3, false]
     58PASS tearOffTest10c(1, 2, 3, false) is [undefined, 2, 3, false]
    2759PASS lexicalArgumentsLiveRead1(0, 2, 3) is 1
    2860PASS lexicalArgumentsLiveRead2(1, 0, 3) is 2
  • trunk/LayoutTests/js/script-tests/function-dot-arguments.js

    r128111 r178517  
    207207shouldBeTrue("tearOffTest2(true)[0]");
    208208
     209
     210// Some utility functions/
     211function arrayify(args) {
     212    if (typeof args != "object")
     213        return args;
     214    if (typeof args.length == "undefined" || typeof args.callee == "undefined")
     215        return args;
     216    return Array.prototype.slice.call(args);
     217}
     218
     219function indirectCall(callee)
     220{
     221    return callee();
     222}
     223
     224// Test reading from caller.arguments from an inner function.
     225function tearOffTest3(a, b, c, d)
     226{
     227    a = 10;
     228    function inner()
     229    {
     230        return tearOffTest3.arguments;
     231    }
     232
     233    return arrayify(inner());
     234}
     235shouldBe("tearOffTest3(1, 2, 3, false)", "[10, 2, 3, false]");
     236
     237
     238function tearOffTest3a(a, b, c, d)
     239{
     240    var x = 42;
     241    a = 10;
     242    function inner()
     243    {
     244        return tearOffTest3a.arguments;
     245    }
     246
     247    if (d) {
     248        // Force a lexicalEnvironment to be created in the outer function.
     249        return function() { return x; }
     250    } else {
     251        return arrayify(inner());
     252    }
     253}
     254shouldBe("tearOffTest3a(1, 2, 3, false)", "[10, 2, 3, false]");
     255
     256
     257function tearOffTest3b(a, b, c, d)
     258{
     259    a = 10;
     260    function inner()
     261    {
     262        var capture = a; // Capture an arg from the outer function.
     263        return tearOffTest3b.arguments;
     264    }
     265
     266    return arrayify(inner());
     267}
     268shouldBe("tearOffTest3b(1, 2, 3, false)", "[1, 2, 3, false]");
     269
     270
     271function tearOffTest3c(a, b, c, d)
     272{
     273    a = 10;
     274    function inner()
     275    {
     276        var capture = a; // Capture an arg from the outer function.
     277        return tearOffTest3c.arguments;
     278    }
     279
     280    return arrayify(indirectCall(inner));
     281}
     282shouldBe("tearOffTest3c(1, 2, 3, false)", "[1, 2, 3, false]");
     283
     284
     285// Test reading from caller.arguments from an external function.
     286function tearOffTest4External()
     287{
     288    return tearOffTest4.arguments;
     289}
     290function tearOffTest4(a, b, c, d)
     291{
     292    a = 10;
     293    return arrayify(tearOffTest4External());
     294}
     295shouldBe("tearOffTest4(1, 2, 3, false)", "[10, 2, 3, false]");
     296
     297
     298function tearOffTest4aExternal()
     299{
     300    return tearOffTest4a.arguments;
     301}
     302function tearOffTest4a(a, b, c, d)
     303{
     304    var x = 42;
     305    a = 10;
     306
     307    if (d) {
     308        // Force a lexicalEnvironment to be created in the outer function.
     309        return function() { return x; }
     310    } else {
     311        return arrayify(tearOffTest4aExternal());
     312    }
     313}
     314shouldBe("tearOffTest4a(1, 2, 3, false)", "[10, 2, 3, false]");
     315
     316
     317function tearOffTest4bExternal()
     318{
     319    return tearOffTest4b.arguments;
     320}
     321function tearOffTest4b(a, b, c, d)
     322{
     323    a = 10;
     324    function inner()
     325    {
     326        var capture = a; // Capture an arg from the outer function.
     327        return capture;
     328    }
     329
     330    return arrayify(tearOffTest4bExternal());
     331}
     332shouldBe("tearOffTest4b(1, 2, 3, false)", "[1, 2, 3, false]");
     333
     334
     335function tearOffTest4cExternal()
     336{
     337    return tearOffTest4c.arguments;
     338}
     339function tearOffTest4c(a, b, c, d)
     340{
     341    a = 10;
     342    function inner()
     343    {
     344        var capture = a; // Capture an arg from the outer function.
     345        return tearOffTest4c.arguments;
     346    }
     347
     348    return arrayify(indirectCall(tearOffTest4cExternal));
     349}
     350shouldBe("tearOffTest4c(1, 2, 3, false)", "[1, 2, 3, false]");
     351
     352
     353// Test reading from caller.arguments which have Deleted slow data from an inner function.
     354function tearOffTest5(a, b, c, d)
     355{
     356    a = 10;
     357    delete arguments[0];
     358    function inner()
     359    {
     360        return tearOffTest5.arguments;
     361    }
     362
     363    return arrayify(inner());
     364}
     365shouldBe("tearOffTest5(1, 2, 3, false)", "[10, 2, 3, false]");
     366
     367
     368function tearOffTest5a(a, b, c, d)
     369{
     370    var x = 42;
     371    a = 10;
     372    delete arguments[0];
     373    function inner()
     374    {
     375        return tearOffTest5a.arguments;
     376    }
     377
     378    if (d) {
     379        // Force a lexicalEnvironment to be created in the outer function.
     380        return function() { return x; }
     381    } else {
     382        return arrayify(inner());
     383    }
     384}
     385shouldBe("tearOffTest5a(1, 2, 3, false)", "[10, 2, 3, false]");
     386
     387
     388function tearOffTest5b(a, b, c, d)
     389{
     390    a = 10;
     391    delete arguments[0];
     392    function inner()
     393    {
     394        var capture = a; // Capture an arg from the outer function.
     395        return tearOffTest5b.arguments;
     396    }
     397
     398    return arrayify(inner());
     399}
     400shouldBe("tearOffTest5b(1, 2, 3, false)", "[1, 2, 3, false]");
     401
     402
     403function tearOffTest5c(a, b, c, d)
     404{
     405    a = 10;
     406    delete arguments[0];
     407    function inner()
     408    {
     409        var capture = a; // Capture an arg from the outer function.
     410        return tearOffTest5c.arguments;
     411    }
     412
     413    return arrayify(indirectCall(inner));
     414}
     415shouldBe("tearOffTest5c(1, 2, 3, false)", "[1, 2, 3, false]");
     416
     417
     418// Test reading from caller.arguments which have Deleted slow data from an external function.
     419function tearOffTest6External()
     420{
     421    return tearOffTest6.arguments;
     422}
     423function tearOffTest6(a, b, c, d)
     424{
     425    a = 10;
     426    delete arguments[0];
     427    return arrayify(tearOffTest6External());
     428}
     429shouldBe("tearOffTest6(1, 2, 3, false)", "[10, 2, 3, false]");
     430
     431
     432function tearOffTest6aExternal()
     433{
     434    return tearOffTest6a.arguments;
     435}
     436function tearOffTest6a(a, b, c, d)
     437{
     438    var x = 42;
     439    a = 10;
     440    delete arguments[0];
     441
     442    if (d) {
     443        // Force a lexicalEnvironment to be created in the outer function.
     444        return function() { return x; }
     445    } else {
     446        return arrayify(tearOffTest6aExternal());
     447    }
     448}
     449shouldBe("tearOffTest6a(1, 2, 3, false)", "[10, 2, 3, false]");
     450
     451
     452function tearOffTest6bExternal()
     453{
     454    return tearOffTest6b.arguments;
     455}
     456function tearOffTest6b(a, b, c, d)
     457{
     458    a = 10;
     459    delete arguments[0];
     460    function inner()
     461    {
     462        var capture = a; // Capture an arg from the outer function.
     463        return capture;
     464    }
     465
     466    return arrayify(tearOffTest6bExternal());
     467}
     468shouldBe("tearOffTest6b(1, 2, 3, false)", "[1, 2, 3, false]");
     469
     470
     471function tearOffTest6cExternal()
     472{
     473    return tearOffTest6c.arguments;
     474}
     475function tearOffTest6c(a, b, c, d)
     476{
     477    a = 10;
     478    delete arguments[0];
     479    function inner()
     480    {
     481        var capture = a; // Capture an arg from the outer function.
     482        return tearOffTest6c.arguments;
     483    }
     484
     485    return arrayify(indirectCall(tearOffTest6cExternal));
     486}
     487shouldBe("tearOffTest6c(1, 2, 3, false)", "[1, 2, 3, false]");
     488
     489
     490// Test writing to caller.arguments from an inner function.
     491function tearOffTest7(a, b, c, d)
     492{
     493    a = 10;
     494    (function inner() {
     495        tearOffTest7.arguments[0] = 100;
     496    })();
     497
     498    return arrayify(arguments);
     499}
     500shouldBe("tearOffTest7(1, 2, 3, false)", "[10, 2, 3, false]");
     501
     502
     503function tearOffTest7a(a, b, c, d)
     504{
     505    var x = 42;
     506    a = 10;
     507
     508    if (d) {
     509        // Force a lexicalEnvironment to be created in the outer function.
     510        return function() { return x; }
     511    } else {
     512        (function inner() {
     513            tearOffTest7a.arguments[0] = 100;
     514        }) ();
     515
     516        return arrayify(arguments);
     517    }
     518}
     519shouldBe("tearOffTest7a(1, 2, 3, false)", "[10, 2, 3, false]");
     520
     521
     522function tearOffTest7b(a, b, c, d)
     523{
     524    a = 10;
     525    (function inner() {
     526        var capture = a; // Capture an arg from the outer function.
     527        tearOffTest7b.arguments[0] = 100;
     528    })();
     529
     530    return arrayify(arguments);
     531}
     532shouldBe("tearOffTest7b(1, 2, 3, false)", "[10, 2, 3, false]");
     533
     534
     535function tearOffTest7c(a, b, c, d)
     536{
     537    a = 10;
     538    function inner() {
     539        var capture = a; // Capture an arg from the outer function.
     540        tearOffTest7c.arguments[0] = 100;
     541    }
     542    indirectCall(inner);
     543    return arrayify(arguments);
     544}
     545shouldBe("tearOffTest7c(1, 2, 3, false)", "[10, 2, 3, false]");
     546
     547
     548// Test writing to caller.arguments from an external function.
     549function tearOffTest8External() {
     550    tearOffTest8.arguments[0] = 100;
     551}
     552function tearOffTest8(a, b, c, d)
     553{
     554    a = 10;
     555    tearOffTest8External();
     556
     557    return arrayify(arguments);
     558}
     559shouldBe("tearOffTest8(1, 2, 3, false)", "[10, 2, 3, false]");
     560
     561
     562function tearOffTest8aExternal() {
     563    tearOffTest8a.arguments[0] = 100;
     564}
     565function tearOffTest8a(a, b, c, d)
     566{
     567    var x = 42;
     568    a = 10;
     569
     570    if (d) {
     571        // Force a lexicalEnvironment to be created in the outer function.
     572        return function() { return x; }
     573    } else {
     574        tearOffTest8aExternal();
     575        return arrayify(arguments);
     576    }
     577}
     578shouldBe("tearOffTest8a(1, 2, 3, false)", "[10, 2, 3, false]");
     579
     580
     581function tearOffTest8bExternal() {
     582    tearOffTest8b.arguments[0] = 100;
     583}
     584function tearOffTest8b(a, b, c, d)
     585{
     586    a = 10;
     587    function inner() {
     588        var capture = a; // Capture an arg from the outer function.
     589    }
     590    tearOffTest8bExternal();
     591
     592    return arrayify(arguments);
     593}
     594shouldBe("tearOffTest8b(1, 2, 3, false)", "[10, 2, 3, false]");
     595
     596
     597function tearOffTest8cExternal() {
     598    tearOffTest8c.arguments[0] = 100;
     599}
     600function tearOffTest8c(a, b, c, d)
     601{
     602    a = 10;
     603    function inner() {
     604        var capture = a; // Capture an arg from the outer function.
     605    }
     606    indirectCall(tearOffTest8cExternal);
     607    return arrayify(arguments);
     608}
     609shouldBe("tearOffTest8c(1, 2, 3, false)", "[10, 2, 3, false]");
     610
     611
     612// Test deleting an arg in caller.arguments from an inner function.
     613function tearOffTest9(a, b, c, d)
     614{
     615    a = 10;
     616    delete arguments[0];
     617    (function inner() {
     618        delete tearOffTest9.arguments[1];
     619    })();
     620
     621    return arrayify(arguments);
     622}
     623shouldBe("tearOffTest9(1, 2, 3, false)", "[undefined, 2, 3, false]");
     624
     625
     626function tearOffTest9a(a, b, c, d)
     627{
     628    var x = 42;
     629    delete arguments[0];
     630
     631    if (d) {
     632        // Force a lexicalEnvironment to be created in the outer function.
     633        return function() { return x; }
     634    } else {
     635        (function inner() {
     636            delete tearOffTest9a.arguments[1];
     637        }) ();
     638
     639        return arrayify(arguments);
     640    }
     641}
     642shouldBe("tearOffTest9a(1, 2, 3, false)", "[undefined, 2, 3, false]");
     643
     644
     645function tearOffTest9b(a, b, c, d)
     646{
     647    delete arguments[0];
     648    (function inner() {
     649        var capture = a; // Capture an arg from the outer function.
     650        delete tearOffTest9b.arguments[1];
     651    })();
     652
     653    return arrayify(arguments);
     654}
     655shouldBe("tearOffTest9b(1, 2, 3, false)", "[undefined, 2, 3, false]");
     656
     657
     658function tearOffTest9c(a, b, c, d)
     659{
     660    delete arguments[0];
     661    function inner() {
     662        var capture = a; // Capture an arg from the outer function.
     663        delete tearOffTest9c.arguments[1];
     664    }
     665    indirectCall(inner);
     666    return arrayify(arguments);
     667}
     668shouldBe("tearOffTest9c(1, 2, 3, false)", "[undefined, 2, 3, false]");
     669
     670
     671// Test deleting a arg in caller.arguments from an external function.
     672
     673function tearOffTest10External() {
     674    delete tearOffTest10.arguments[1];
     675}
     676function tearOffTest10(a, b, c, d)
     677{
     678    delete arguments[0];
     679    tearOffTest10External();
     680
     681    return arrayify(arguments);
     682}
     683shouldBe("tearOffTest10(1, 2, 3, false)", "[undefined, 2, 3, false]");
     684
     685
     686function tearOffTest10aExternal() {
     687    delete tearOffTest10a.arguments[1];
     688}
     689function tearOffTest10a(a, b, c, d)
     690{
     691    var x = 42;
     692    delete arguments[0];
     693
     694    if (d) {
     695        // Force a lexicalEnvironment to be created in the outer function.
     696        return function() { return x; }
     697    } else {
     698        tearOffTest10aExternal();
     699        return arrayify(arguments);
     700    }
     701}
     702shouldBe("tearOffTest10a(1, 2, 3, false)", "[undefined, 2, 3, false]");
     703
     704
     705function tearOffTest10bExternal() {
     706    delete tearOffTest10b.arguments[1];
     707}
     708function tearOffTest10b(a, b, c, d)
     709{
     710    delete arguments[0];
     711    function inner() {
     712        var capture = a; // Capture an arg from the outer function.
     713    }
     714    tearOffTest10bExternal();
     715
     716    return arrayify(arguments);
     717}
     718shouldBe("tearOffTest10b(1, 2, 3, false)", "[undefined, 2, 3, false]");
     719
     720
     721function tearOffTest10cExternal() {
     722    delete tearOffTest10c.arguments[1];
     723}
     724function tearOffTest10c(a, b, c, d)
     725{
     726    delete arguments[0];
     727    function inner() {
     728        var capture = a; // Capture an arg from the outer function.
     729    }
     730    indirectCall(tearOffTest10cExternal);
     731    return arrayify(arguments);
     732}
     733shouldBe("tearOffTest10c(1, 2, 3, false)", "[undefined, 2, 3, false]");
     734
     735
    209736function lexicalArgumentsLiveRead1(a, b, c)
    210737{
  • trunk/Source/JavaScriptCore/ChangeLog

    r178442 r178517  
     12015-01-15  Mark Lam  <mark.lam@apple.com>
     2
     3        [Part 2] Argument object created by "Function dot arguments" should use a clone of argument values.
     4        <https://webkit.org/b/140093>
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        * interpreter/StackVisitor.cpp:
     9        (JSC::StackVisitor::Frame::createArguments):
     10        - We should not fetching the lexicalEnvironment here.  The reason we've
     11          introduced the ClonedArgumentsCreationMode is because the lexicalEnvironment
     12          may not be available to us at this point.  Instead, we'll just pass a nullptr.
     13
     14        * runtime/Arguments.cpp:
     15        (JSC::Arguments::tearOffForCloning):
     16        * runtime/Arguments.h:
     17        (JSC::Arguments::finishCreation):
     18        - Use the new tearOffForCloning() to tear off arguments right out of the values
     19          passed on the stack.  tearOff() is not appropriate for this purpose because
     20          it takes slowArgumentsData into account.
     21
    1222015-01-14  Matthew Mirman  <mmirman@apple.com>
    223
  • trunk/Source/JavaScriptCore/interpreter/StackVisitor.cpp

    r178145 r178517  
    273273#endif
    274274    {
    275         JSLexicalEnvironment* lexicalEnvironment = physicalFrame->lexicalEnvironmentOrNullptr();
     275        JSLexicalEnvironment* lexicalEnvironment = nullptr;
    276276        arguments = Arguments::create(vm, physicalFrame, lexicalEnvironment, mode);
    277277        arguments->tearOff(physicalFrame);
  • trunk/Source/JavaScriptCore/runtime/Arguments.cpp

    r174795 r178517  
    384384}
    385385   
     386void Arguments::tearOffForCloning(CallFrame* callFrame)
     387{
     388    ASSERT(!isTornOff());
     389   
     390    if (!m_numArguments)
     391        return;
     392   
     393    // Must be called for the same call frame from which it was created.
     394    ASSERT(bitwise_cast<WriteBarrier<Unknown>*>(callFrame) == m_registers);
     395   
     396    m_registers = &registerArray() - CallFrame::offsetFor(1) - 1;
     397   
     398    ASSERT(!m_slowArgumentData);
     399    for (size_t i = 0; i < m_numArguments; ++i)
     400        m_registers[CallFrame::argumentOffset(i)].set(callFrame->vm(), this, callFrame->argument(i));
     401}
     402   
     403void Arguments::tearOffForCloning(CallFrame* callFrame, InlineCallFrame* inlineCallFrame)
     404{
     405    RELEASE_ASSERT(!inlineCallFrame->baselineCodeBlock()->needsActivation());
     406    ASSERT(!isTornOff());
     407   
     408    if (!m_numArguments)
     409        return;
     410   
     411    m_registers = &registerArray() - CallFrame::offsetFor(1) - 1;
     412   
     413    ASSERT(!m_slowArgumentData);
     414    for (size_t i = 0; i < m_numArguments; ++i) {
     415        ValueRecovery& recovery = inlineCallFrame->arguments[i + 1];
     416        m_registers[CallFrame::argumentOffset(i)].set(callFrame->vm(), this, recovery.recover(callFrame));
     417    }
     418}
     419
    386420EncodedJSValue JSC_HOST_CALL argumentsFuncIterator(ExecState* exec)
    387421{
  • trunk/Source/JavaScriptCore/runtime/Arguments.h

    r178145 r178517  
    8888    void tearOff(CallFrame*);
    8989    void tearOff(CallFrame*, InlineCallFrame*);
     90    void tearOffForCloning(CallFrame*);
     91    void tearOffForCloning(CallFrame*, InlineCallFrame*);
    9092    bool isTornOff() const { return m_registers == (&registerArray() - CallFrame::offsetFor(1) - 1); }
    9193
     
    311313        break;
    312314    }
    313        
     315
    314316    case ClonedArgumentsCreationMode: {
    315317        m_numArguments = callFrame->argumentCount();
    316318        m_registers = reinterpret_cast<WriteBarrierBase<Unknown>*>(callFrame->registers());
    317         tearOff(callFrame);
    318         break;
    319     }
    320        
     319        tearOffForCloning(callFrame);
     320        break;
     321    }
     322
    321323    case FakeArgumentValuesCreationMode: {
    322324        m_numArguments = 0;
     
    369371        ASSERT(!jsCast<FunctionExecutable*>(inlineCallFrame->executable.get())->symbolTable(inlineCallFrame->specializationKind())->slowArguments());
    370372       
    371         tearOff(callFrame, inlineCallFrame);
     373        tearOffForCloning(callFrame, inlineCallFrame);
    372374        break;
    373375    }
Note: See TracChangeset for help on using the changeset viewer.