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

Side by Side Diff: test/mjsunit/property-load-across-eval.js

Issue 2027002: Implement fast calls of functions in the presence of eval (if the eval... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 7 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
« src/arm/codegen-arm.cc ('K') | « src/x64/codegen-x64.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 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 10 matching lines...) Expand all
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 // Tests loading of properties across eval calls. 28 // Tests loading of properties across eval calls.
29 29
30 var x = 1; 30 var x = 1;
31 function global_function() { return 'global'; }
32 const const_uninitialized;
33 const const_initialized = function() { return "const_global"; }
31 34
32 // Test loading across an eval call that does not shadow variables. 35 // Test loading across an eval call that does not shadow variables.
33 function testNoShadowing() { 36 function testNoShadowing() {
34 var y = 2; 37 var y = 2;
38 function local_function() { return 'local'; }
39 const local_const_uninitialized;
40 const local_const_initialized = function() { return "const_local"; }
35 function f() { 41 function f() {
36 eval('1'); 42 eval('1');
37 assertEquals(1, x); 43 assertEquals(1, x);
38 assertEquals(2, y); 44 assertEquals(2, y);
45 assertEquals('global', global_function());
46 assertEquals('local', local_function());
47 try {
48 const_uninitialized();
49 assertUnreachable();
50 } catch(e) {
51 // Ignore.
52 }
53 assertEquals('const_global', const_initialized());
54 try {
55 local_const_uninitialized();
56 assertUnreachable();
57 } catch(e) {
58 // Ignore.
59 }
60 assertEquals('const_local', local_const_initialized());
39 function g() { 61 function g() {
40 assertEquals(1, x); 62 assertEquals(1, x);
41 assertEquals(2, y); 63 assertEquals(2, y);
64 assertEquals('global', global_function());
65 assertEquals('local', local_function());
66 try {
67 const_uninitialized();
68 assertUnreachable();
69 } catch(e) {
70 // Ignore.
71 }
72 assertEquals('const_global', const_initialized());
73 try {
74 local_const_uninitialized();
75 assertUnreachable();
76 } catch(e) {
77 // Ignore.
78 }
79 assertEquals('const_local', local_const_initialized());
42 } 80 }
43 g(); 81 g();
44 } 82 }
45 f(); 83 f();
46 } 84 }
47 85
48 testNoShadowing(); 86 testNoShadowing();
49 87
50 // Test loading across eval calls that do not shadow variables. 88 // Test loading across eval calls that do not shadow variables.
51 function testNoShadowing2() { 89 function testNoShadowing2() {
52 var y = 2; 90 var y = 2;
91 function local_function() { return 'local'; }
53 eval('1'); 92 eval('1');
54 function f() { 93 function f() {
55 eval('1'); 94 eval('1');
56 assertEquals(1, x); 95 assertEquals(1, x);
57 assertEquals(2, y); 96 assertEquals(2, y);
97 assertEquals('global', global_function());
98 assertEquals('local', local_function());
58 function g() { 99 function g() {
59 assertEquals(1, x); 100 assertEquals(1, x);
60 assertEquals(2, y); 101 assertEquals(2, y);
102 assertEquals('global', global_function());
103 assertEquals('local', local_function());
61 } 104 }
62 g(); 105 g();
63 } 106 }
64 f(); 107 f();
65 } 108 }
66 109
67 testNoShadowing2(); 110 testNoShadowing2();
68 111
69 // Test loading across an eval call that shadows variables. 112 // Test loading across an eval call that shadows variables.
70 function testShadowing() { 113 function testShadowing() {
71 var y = 2; 114 var y = 2;
115 function local_function() { return 'local'; }
72 function f() { 116 function f() {
73 eval('var x = 3; var y = 4;'); 117 eval('var x = 3; var y = 4;');
74 assertEquals(3, x); 118 assertEquals(3, x);
75 assertEquals(4, y); 119 assertEquals(4, y);
120 eval('function local_function() { return "new_local"; }');
121 eval('function global_function() { return "new_nonglobal"; }');
122 assertEquals('new_nonglobal', global_function());
123 assertEquals('new_local', local_function());
76 function g() { 124 function g() {
77 assertEquals(3, x); 125 assertEquals(3, x);
78 assertEquals(4, y); 126 assertEquals(4, y);
127 assertEquals('new_nonglobal', global_function());
128 assertEquals('new_local', local_function());
79 } 129 }
80 g(); 130 g();
81 } 131 }
82 f(); 132 f();
83 } 133 }
84 134
85 testShadowing(); 135 testShadowing();
OLDNEW
« src/arm/codegen-arm.cc ('K') | « src/x64/codegen-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698