OLD | NEW |
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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 function GlobalParseFloat(string) { | 163 function GlobalParseFloat(string) { |
164 string = TO_STRING_INLINE(string); | 164 string = TO_STRING_INLINE(string); |
165 if (%_HasCachedArrayIndex(string)) return %_GetCachedArrayIndex(string); | 165 if (%_HasCachedArrayIndex(string)) return %_GetCachedArrayIndex(string); |
166 return %StringParseFloat(string); | 166 return %StringParseFloat(string); |
167 } | 167 } |
168 | 168 |
169 | 169 |
170 function GlobalEval(x) { | 170 function GlobalEval(x) { |
171 if (!IS_STRING(x)) return x; | 171 if (!IS_STRING(x)) return x; |
172 | 172 |
173 var global_receiver = %GlobalReceiver(global); | |
174 var global_is_detached = (global === global_receiver); | |
175 | |
176 // For consistency with JSC we require the global object passed to | 173 // For consistency with JSC we require the global object passed to |
177 // eval to be the global object from which 'eval' originated. This | 174 // eval to be the global object from which 'eval' originated. This |
178 // is not mandated by the spec. | 175 // is not mandated by the spec. |
179 // We only throw if the global has been detached, since we need the | 176 // We only throw if the global has been detached, since we need the |
180 // receiver as this-value for the call. | 177 // receiver as this-value for the call. |
181 if (global_is_detached) { | 178 if (!%IsAttachedGlobal(global)) { |
182 throw new $EvalError('The "this" value passed to eval must ' + | 179 throw new $EvalError('The "this" value passed to eval must ' + |
183 'be the global object from which eval originated'); | 180 'be the global object from which eval originated'); |
184 } | 181 } |
185 | 182 |
| 183 var global_receiver = %GlobalReceiver(global); |
| 184 |
186 var f = %CompileString(x, false); | 185 var f = %CompileString(x, false); |
187 if (!IS_FUNCTION(f)) return f; | 186 if (!IS_FUNCTION(f)) return f; |
188 | 187 |
189 return %_CallFunction(global_receiver, f); | 188 return %_CallFunction(global_receiver, f); |
190 } | 189 } |
191 | 190 |
192 | 191 |
193 // ---------------------------------------------------------------------------- | 192 // ---------------------------------------------------------------------------- |
194 | 193 |
195 // Set up global object. | 194 // Set up global object. |
(...skipping 1649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1845 // Eventually, we should move to a real event queue that allows to maintain | 1844 // Eventually, we should move to a real event queue that allows to maintain |
1846 // relative ordering of different kinds of tasks. | 1845 // relative ordering of different kinds of tasks. |
1847 | 1846 |
1848 RunMicrotasks.runners = new InternalArray; | 1847 RunMicrotasks.runners = new InternalArray; |
1849 | 1848 |
1850 function RunMicrotasks() { | 1849 function RunMicrotasks() { |
1851 while (%SetMicrotaskPending(false)) { | 1850 while (%SetMicrotaskPending(false)) { |
1852 for (var i in RunMicrotasks.runners) RunMicrotasks.runners[i](); | 1851 for (var i in RunMicrotasks.runners) RunMicrotasks.runners[i](); |
1853 } | 1852 } |
1854 } | 1853 } |
OLD | NEW |