mustang 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (560) hide show
  1. data/.rspec +1 -0
  2. data/Isolate +9 -0
  3. data/README.md +6 -12
  4. data/Rakefile +30 -4
  5. data/TODO.md +9 -0
  6. data/ext/v8/extconf.rb +56 -0
  7. data/ext/v8/v8.cpp +37 -0
  8. data/ext/v8/v8_array.cpp +161 -0
  9. data/ext/v8/v8_array.h +17 -0
  10. data/ext/v8/v8_base.cpp +147 -0
  11. data/ext/v8/v8_base.h +23 -0
  12. data/ext/v8/v8_cast.cpp +151 -0
  13. data/ext/v8/v8_cast.h +64 -0
  14. data/ext/v8/v8_context.cpp +174 -0
  15. data/ext/v8/v8_context.h +12 -0
  16. data/ext/v8/v8_date.cpp +61 -0
  17. data/ext/v8/v8_date.h +16 -0
  18. data/ext/v8/v8_errors.cpp +147 -0
  19. data/ext/v8/v8_errors.h +19 -0
  20. data/ext/v8/v8_external.cpp +66 -0
  21. data/ext/v8/v8_external.h +16 -0
  22. data/ext/v8/v8_function.cpp +182 -0
  23. data/ext/v8/v8_function.h +14 -0
  24. data/ext/v8/v8_integer.cpp +70 -0
  25. data/ext/v8/v8_integer.h +16 -0
  26. data/ext/v8/v8_macros.h +30 -0
  27. data/ext/v8/v8_main.cpp +53 -0
  28. data/ext/v8/v8_main.h +13 -0
  29. data/ext/v8/v8_number.cpp +62 -0
  30. data/ext/v8/v8_number.h +16 -0
  31. data/ext/v8/v8_object.cpp +172 -0
  32. data/ext/v8/v8_object.h +17 -0
  33. data/ext/v8/v8_ref.cpp +72 -0
  34. data/ext/v8/v8_ref.h +43 -0
  35. data/ext/v8/v8_regexp.cpp +148 -0
  36. data/ext/v8/v8_regexp.h +16 -0
  37. data/ext/v8/v8_string.cpp +78 -0
  38. data/ext/v8/v8_string.h +16 -0
  39. data/ext/v8/v8_value.cpp +370 -0
  40. data/ext/v8/v8_value.h +19 -0
  41. data/gemspec.yml +2 -1
  42. data/lib/core_ext/class.rb +14 -0
  43. data/lib/core_ext/object.rb +12 -0
  44. data/lib/core_ext/symbol.rb +23 -0
  45. data/lib/mustang.rb +44 -0
  46. data/lib/mustang/context.rb +69 -0
  47. data/lib/mustang/errors.rb +36 -0
  48. data/lib/support/delegated.rb +25 -0
  49. data/lib/v8/array.rb +21 -0
  50. data/lib/v8/context.rb +13 -0
  51. data/lib/v8/date.rb +20 -0
  52. data/lib/v8/error.rb +15 -0
  53. data/lib/v8/external.rb +16 -0
  54. data/lib/v8/function.rb +11 -0
  55. data/lib/v8/integer.rb +16 -0
  56. data/lib/v8/number.rb +16 -0
  57. data/lib/v8/object.rb +66 -0
  58. data/lib/v8/regexp.rb +23 -0
  59. data/lib/v8/string.rb +27 -0
  60. data/mustang.gemspec +3 -0
  61. data/spec/core_ext/class_spec.rb +19 -0
  62. data/spec/core_ext/object_spec.rb +19 -0
  63. data/spec/core_ext/symbol_spec.rb +27 -0
  64. data/spec/fixtures/test1.js +2 -0
  65. data/spec/fixtures/test2.js +2 -0
  66. data/spec/spec_helper.rb +20 -0
  67. data/spec/v8/array_spec.rb +88 -0
  68. data/spec/v8/cast_spec.rb +151 -0
  69. data/spec/v8/context_spec.rb +78 -0
  70. data/spec/v8/data_spec.rb +39 -0
  71. data/spec/v8/date_spec.rb +45 -0
  72. data/spec/v8/empty_spec.rb +27 -0
  73. data/spec/v8/errors_spec.rb +142 -0
  74. data/spec/v8/external_spec.rb +44 -0
  75. data/spec/v8/function_spec.rb +170 -0
  76. data/spec/v8/integer_spec.rb +41 -0
  77. data/spec/v8/main_spec.rb +18 -0
  78. data/spec/v8/null_spec.rb +27 -0
  79. data/spec/v8/number_spec.rb +40 -0
  80. data/spec/v8/object_spec.rb +79 -0
  81. data/spec/v8/primitive_spec.rb +9 -0
  82. data/spec/v8/regexp_spec.rb +65 -0
  83. data/spec/v8/string_spec.rb +48 -0
  84. data/spec/v8/undefined_spec.rb +27 -0
  85. data/spec/v8/value_spec.rb +215 -0
  86. data/vendor/v8/.gitignore +2 -0
  87. data/vendor/v8/AUTHORS +3 -1
  88. data/vendor/v8/ChangeLog +117 -0
  89. data/vendor/v8/SConstruct +334 -53
  90. data/vendor/v8/include/v8-debug.h +21 -11
  91. data/vendor/v8/include/v8-preparser.h +1 -1
  92. data/vendor/v8/include/v8-profiler.h +122 -43
  93. data/vendor/v8/include/v8-testing.h +5 -0
  94. data/vendor/v8/include/v8.h +171 -17
  95. data/vendor/v8/preparser/SConscript +38 -0
  96. data/vendor/v8/preparser/preparser-process.cc +77 -114
  97. data/vendor/v8/samples/shell.cc +232 -46
  98. data/vendor/v8/src/SConscript +29 -5
  99. data/vendor/v8/src/accessors.cc +70 -211
  100. data/vendor/v8/{test/cctest/test-mips.cc → src/allocation-inl.h} +15 -18
  101. data/vendor/v8/src/allocation.cc +0 -82
  102. data/vendor/v8/src/allocation.h +9 -42
  103. data/vendor/v8/src/api.cc +1645 -1156
  104. data/vendor/v8/src/api.h +76 -12
  105. data/vendor/v8/src/apiutils.h +0 -7
  106. data/vendor/v8/src/arguments.h +15 -4
  107. data/vendor/v8/src/arm/assembler-arm-inl.h +10 -9
  108. data/vendor/v8/src/arm/assembler-arm.cc +62 -23
  109. data/vendor/v8/src/arm/assembler-arm.h +76 -11
  110. data/vendor/v8/src/arm/builtins-arm.cc +39 -33
  111. data/vendor/v8/src/arm/code-stubs-arm.cc +1182 -402
  112. data/vendor/v8/src/arm/code-stubs-arm.h +20 -54
  113. data/vendor/v8/src/arm/codegen-arm.cc +159 -106
  114. data/vendor/v8/src/arm/codegen-arm.h +6 -6
  115. data/vendor/v8/src/arm/constants-arm.h +16 -1
  116. data/vendor/v8/src/arm/cpu-arm.cc +7 -5
  117. data/vendor/v8/src/arm/debug-arm.cc +6 -4
  118. data/vendor/v8/src/arm/deoptimizer-arm.cc +51 -14
  119. data/vendor/v8/src/arm/disasm-arm.cc +47 -15
  120. data/vendor/v8/src/arm/frames-arm.h +1 -1
  121. data/vendor/v8/src/arm/full-codegen-arm.cc +724 -408
  122. data/vendor/v8/src/arm/ic-arm.cc +90 -85
  123. data/vendor/v8/src/arm/lithium-arm.cc +140 -69
  124. data/vendor/v8/src/arm/lithium-arm.h +161 -46
  125. data/vendor/v8/src/arm/lithium-codegen-arm.cc +567 -297
  126. data/vendor/v8/src/arm/lithium-codegen-arm.h +21 -9
  127. data/vendor/v8/src/arm/lithium-gap-resolver-arm.cc +2 -0
  128. data/vendor/v8/src/arm/macro-assembler-arm.cc +457 -96
  129. data/vendor/v8/src/arm/macro-assembler-arm.h +115 -18
  130. data/vendor/v8/src/arm/regexp-macro-assembler-arm.cc +20 -13
  131. data/vendor/v8/src/arm/regexp-macro-assembler-arm.h +1 -0
  132. data/vendor/v8/src/arm/simulator-arm.cc +184 -101
  133. data/vendor/v8/src/arm/simulator-arm.h +26 -21
  134. data/vendor/v8/src/arm/stub-cache-arm.cc +450 -467
  135. data/vendor/v8/src/arm/virtual-frame-arm.cc +14 -12
  136. data/vendor/v8/src/arm/virtual-frame-arm.h +11 -8
  137. data/vendor/v8/src/array.js +35 -18
  138. data/vendor/v8/src/assembler.cc +186 -92
  139. data/vendor/v8/src/assembler.h +106 -69
  140. data/vendor/v8/src/ast-inl.h +5 -0
  141. data/vendor/v8/src/ast.cc +46 -35
  142. data/vendor/v8/src/ast.h +107 -50
  143. data/vendor/v8/src/atomicops.h +2 -0
  144. data/vendor/v8/src/atomicops_internals_mips_gcc.h +169 -0
  145. data/vendor/v8/src/bootstrapper.cc +649 -399
  146. data/vendor/v8/src/bootstrapper.h +94 -27
  147. data/vendor/v8/src/builtins.cc +359 -227
  148. data/vendor/v8/src/builtins.h +157 -123
  149. data/vendor/v8/src/checks.cc +2 -2
  150. data/vendor/v8/src/checks.h +4 -0
  151. data/vendor/v8/src/code-stubs.cc +27 -17
  152. data/vendor/v8/src/code-stubs.h +38 -17
  153. data/vendor/v8/src/codegen-inl.h +5 -1
  154. data/vendor/v8/src/codegen.cc +27 -17
  155. data/vendor/v8/src/codegen.h +9 -9
  156. data/vendor/v8/src/compilation-cache.cc +92 -206
  157. data/vendor/v8/src/compilation-cache.h +205 -30
  158. data/vendor/v8/src/compiler.cc +107 -120
  159. data/vendor/v8/src/compiler.h +17 -2
  160. data/vendor/v8/src/contexts.cc +22 -15
  161. data/vendor/v8/src/contexts.h +14 -8
  162. data/vendor/v8/src/conversions.cc +86 -30
  163. data/vendor/v8/src/counters.cc +19 -4
  164. data/vendor/v8/src/counters.h +28 -16
  165. data/vendor/v8/src/cpu-profiler-inl.h +4 -3
  166. data/vendor/v8/src/cpu-profiler.cc +123 -72
  167. data/vendor/v8/src/cpu-profiler.h +33 -19
  168. data/vendor/v8/src/cpu.h +2 -0
  169. data/vendor/v8/src/d8-debug.cc +3 -3
  170. data/vendor/v8/src/d8-debug.h +7 -6
  171. data/vendor/v8/src/d8-posix.cc +2 -0
  172. data/vendor/v8/src/d8.cc +22 -12
  173. data/vendor/v8/src/d8.gyp +3 -0
  174. data/vendor/v8/src/d8.js +618 -0
  175. data/vendor/v8/src/data-flow.h +3 -3
  176. data/vendor/v8/src/dateparser.h +4 -2
  177. data/vendor/v8/src/debug-agent.cc +10 -9
  178. data/vendor/v8/src/debug-agent.h +9 -11
  179. data/vendor/v8/src/debug-debugger.js +121 -0
  180. data/vendor/v8/src/debug.cc +331 -227
  181. data/vendor/v8/src/debug.h +248 -219
  182. data/vendor/v8/src/deoptimizer.cc +173 -62
  183. data/vendor/v8/src/deoptimizer.h +119 -19
  184. data/vendor/v8/src/disasm.h +3 -0
  185. data/vendor/v8/src/disassembler.cc +10 -9
  186. data/vendor/v8/src/execution.cc +185 -129
  187. data/vendor/v8/src/execution.h +47 -78
  188. data/vendor/v8/src/extensions/experimental/break-iterator.cc +250 -0
  189. data/vendor/v8/src/extensions/experimental/break-iterator.h +89 -0
  190. data/vendor/v8/src/extensions/experimental/experimental.gyp +2 -0
  191. data/vendor/v8/src/extensions/experimental/i18n-extension.cc +22 -2
  192. data/vendor/v8/src/extensions/externalize-string-extension.cc +2 -2
  193. data/vendor/v8/src/extensions/gc-extension.cc +1 -1
  194. data/vendor/v8/src/factory.cc +261 -154
  195. data/vendor/v8/src/factory.h +162 -158
  196. data/vendor/v8/src/flag-definitions.h +17 -11
  197. data/vendor/v8/src/frame-element.cc +0 -5
  198. data/vendor/v8/src/frame-element.h +9 -13
  199. data/vendor/v8/src/frames-inl.h +7 -0
  200. data/vendor/v8/src/frames.cc +56 -46
  201. data/vendor/v8/src/frames.h +36 -25
  202. data/vendor/v8/src/full-codegen.cc +15 -24
  203. data/vendor/v8/src/full-codegen.h +13 -41
  204. data/vendor/v8/src/func-name-inferrer.cc +7 -6
  205. data/vendor/v8/src/func-name-inferrer.h +1 -1
  206. data/vendor/v8/src/gdb-jit.cc +1 -0
  207. data/vendor/v8/src/global-handles.cc +118 -56
  208. data/vendor/v8/src/global-handles.h +98 -40
  209. data/vendor/v8/src/globals.h +2 -2
  210. data/vendor/v8/src/handles-inl.h +106 -9
  211. data/vendor/v8/src/handles.cc +220 -157
  212. data/vendor/v8/src/handles.h +38 -59
  213. data/vendor/v8/src/hashmap.h +3 -3
  214. data/vendor/v8/src/heap-inl.h +141 -25
  215. data/vendor/v8/src/heap-profiler.cc +117 -63
  216. data/vendor/v8/src/heap-profiler.h +38 -21
  217. data/vendor/v8/src/heap.cc +805 -564
  218. data/vendor/v8/src/heap.h +640 -594
  219. data/vendor/v8/src/hydrogen-instructions.cc +216 -73
  220. data/vendor/v8/src/hydrogen-instructions.h +259 -124
  221. data/vendor/v8/src/hydrogen.cc +996 -1171
  222. data/vendor/v8/src/hydrogen.h +163 -144
  223. data/vendor/v8/src/ia32/assembler-ia32-inl.h +12 -11
  224. data/vendor/v8/src/ia32/assembler-ia32.cc +85 -39
  225. data/vendor/v8/src/ia32/assembler-ia32.h +82 -16
  226. data/vendor/v8/src/ia32/builtins-ia32.cc +64 -58
  227. data/vendor/v8/src/ia32/code-stubs-ia32.cc +248 -324
  228. data/vendor/v8/src/ia32/code-stubs-ia32.h +3 -44
  229. data/vendor/v8/src/ia32/codegen-ia32.cc +217 -165
  230. data/vendor/v8/src/ia32/codegen-ia32.h +3 -0
  231. data/vendor/v8/src/ia32/cpu-ia32.cc +6 -5
  232. data/vendor/v8/src/ia32/debug-ia32.cc +8 -5
  233. data/vendor/v8/src/ia32/deoptimizer-ia32.cc +124 -14
  234. data/vendor/v8/src/ia32/disasm-ia32.cc +85 -62
  235. data/vendor/v8/src/ia32/frames-ia32.h +1 -1
  236. data/vendor/v8/src/ia32/full-codegen-ia32.cc +348 -435
  237. data/vendor/v8/src/ia32/ic-ia32.cc +91 -91
  238. data/vendor/v8/src/ia32/lithium-codegen-ia32.cc +500 -255
  239. data/vendor/v8/src/ia32/lithium-codegen-ia32.h +13 -4
  240. data/vendor/v8/src/ia32/lithium-gap-resolver-ia32.cc +6 -0
  241. data/vendor/v8/src/ia32/lithium-ia32.cc +122 -45
  242. data/vendor/v8/src/ia32/lithium-ia32.h +128 -41
  243. data/vendor/v8/src/ia32/macro-assembler-ia32.cc +109 -84
  244. data/vendor/v8/src/ia32/macro-assembler-ia32.h +18 -9
  245. data/vendor/v8/src/ia32/regexp-macro-assembler-ia32.cc +26 -15
  246. data/vendor/v8/src/ia32/regexp-macro-assembler-ia32.h +1 -0
  247. data/vendor/v8/src/ia32/register-allocator-ia32.cc +30 -30
  248. data/vendor/v8/src/ia32/simulator-ia32.h +4 -4
  249. data/vendor/v8/src/ia32/stub-cache-ia32.cc +383 -400
  250. data/vendor/v8/src/ia32/virtual-frame-ia32.cc +36 -13
  251. data/vendor/v8/src/ia32/virtual-frame-ia32.h +11 -5
  252. data/vendor/v8/src/ic-inl.h +12 -2
  253. data/vendor/v8/src/ic.cc +304 -221
  254. data/vendor/v8/src/ic.h +115 -58
  255. data/vendor/v8/src/interpreter-irregexp.cc +25 -21
  256. data/vendor/v8/src/interpreter-irregexp.h +2 -1
  257. data/vendor/v8/src/isolate.cc +883 -0
  258. data/vendor/v8/src/isolate.h +1304 -0
  259. data/vendor/v8/src/json.js +10 -10
  260. data/vendor/v8/src/jsregexp.cc +111 -80
  261. data/vendor/v8/src/jsregexp.h +6 -7
  262. data/vendor/v8/src/jump-target-heavy.cc +5 -8
  263. data/vendor/v8/src/jump-target-heavy.h +0 -6
  264. data/vendor/v8/src/jump-target-inl.h +1 -1
  265. data/vendor/v8/src/jump-target-light.cc +3 -3
  266. data/vendor/v8/src/lithium-allocator-inl.h +2 -0
  267. data/vendor/v8/src/lithium-allocator.cc +42 -30
  268. data/vendor/v8/src/lithium-allocator.h +8 -22
  269. data/vendor/v8/src/lithium.cc +1 -0
  270. data/vendor/v8/src/liveedit.cc +141 -99
  271. data/vendor/v8/src/liveedit.h +7 -2
  272. data/vendor/v8/src/liveobjectlist-inl.h +90 -0
  273. data/vendor/v8/src/liveobjectlist.cc +2537 -1
  274. data/vendor/v8/src/liveobjectlist.h +245 -35
  275. data/vendor/v8/src/log-utils.cc +122 -35
  276. data/vendor/v8/src/log-utils.h +33 -36
  277. data/vendor/v8/src/log.cc +299 -241
  278. data/vendor/v8/src/log.h +177 -110
  279. data/vendor/v8/src/mark-compact.cc +612 -470
  280. data/vendor/v8/src/mark-compact.h +153 -80
  281. data/vendor/v8/src/messages.cc +16 -14
  282. data/vendor/v8/src/messages.js +30 -7
  283. data/vendor/v8/src/mips/assembler-mips-inl.h +155 -35
  284. data/vendor/v8/src/mips/assembler-mips.cc +1093 -219
  285. data/vendor/v8/src/mips/assembler-mips.h +552 -153
  286. data/vendor/v8/src/mips/builtins-mips.cc +43 -100
  287. data/vendor/v8/src/mips/code-stubs-mips.cc +752 -0
  288. data/vendor/v8/src/mips/code-stubs-mips.h +511 -0
  289. data/vendor/v8/src/mips/codegen-mips-inl.h +8 -14
  290. data/vendor/v8/src/mips/codegen-mips.cc +672 -896
  291. data/vendor/v8/src/mips/codegen-mips.h +271 -69
  292. data/vendor/v8/src/mips/constants-mips.cc +44 -20
  293. data/vendor/v8/src/mips/constants-mips.h +238 -40
  294. data/vendor/v8/src/mips/cpu-mips.cc +20 -3
  295. data/vendor/v8/src/mips/debug-mips.cc +35 -7
  296. data/vendor/v8/src/mips/deoptimizer-mips.cc +91 -0
  297. data/vendor/v8/src/mips/disasm-mips.cc +329 -93
  298. data/vendor/v8/src/mips/frames-mips.cc +2 -50
  299. data/vendor/v8/src/mips/frames-mips.h +24 -9
  300. data/vendor/v8/src/mips/full-codegen-mips.cc +473 -23
  301. data/vendor/v8/src/mips/ic-mips.cc +81 -45
  302. data/vendor/v8/src/mips/jump-target-mips.cc +11 -106
  303. data/vendor/v8/src/mips/lithium-codegen-mips.h +65 -0
  304. data/vendor/v8/src/mips/lithium-mips.h +304 -0
  305. data/vendor/v8/src/mips/macro-assembler-mips.cc +2391 -390
  306. data/vendor/v8/src/mips/macro-assembler-mips.h +718 -121
  307. data/vendor/v8/src/mips/regexp-macro-assembler-mips.cc +478 -0
  308. data/vendor/v8/src/mips/regexp-macro-assembler-mips.h +250 -0
  309. data/vendor/v8/src/mips/register-allocator-mips-inl.h +0 -3
  310. data/vendor/v8/src/mips/register-allocator-mips.h +3 -2
  311. data/vendor/v8/src/mips/simulator-mips.cc +1009 -221
  312. data/vendor/v8/src/mips/simulator-mips.h +119 -36
  313. data/vendor/v8/src/mips/stub-cache-mips.cc +331 -148
  314. data/vendor/v8/src/mips/{fast-codegen-mips.cc → virtual-frame-mips-inl.h} +11 -30
  315. data/vendor/v8/src/mips/virtual-frame-mips.cc +137 -149
  316. data/vendor/v8/src/mips/virtual-frame-mips.h +294 -312
  317. data/vendor/v8/src/mirror-debugger.js +9 -8
  318. data/vendor/v8/src/mksnapshot.cc +2 -2
  319. data/vendor/v8/src/objects-debug.cc +16 -16
  320. data/vendor/v8/src/objects-inl.h +421 -195
  321. data/vendor/v8/src/objects-printer.cc +7 -7
  322. data/vendor/v8/src/objects-visiting.cc +1 -1
  323. data/vendor/v8/src/objects-visiting.h +33 -12
  324. data/vendor/v8/src/objects.cc +935 -658
  325. data/vendor/v8/src/objects.h +234 -139
  326. data/vendor/v8/src/parser.cc +484 -439
  327. data/vendor/v8/src/parser.h +35 -14
  328. data/vendor/v8/src/platform-cygwin.cc +173 -107
  329. data/vendor/v8/src/platform-freebsd.cc +224 -72
  330. data/vendor/v8/src/platform-linux.cc +234 -95
  331. data/vendor/v8/src/platform-macos.cc +215 -82
  332. data/vendor/v8/src/platform-nullos.cc +9 -3
  333. data/vendor/v8/src/platform-openbsd.cc +22 -7
  334. data/vendor/v8/src/platform-posix.cc +30 -5
  335. data/vendor/v8/src/platform-solaris.cc +120 -38
  336. data/vendor/v8/src/platform-tls-mac.h +62 -0
  337. data/vendor/v8/src/platform-tls-win32.h +62 -0
  338. data/vendor/v8/src/platform-tls.h +50 -0
  339. data/vendor/v8/src/platform-win32.cc +195 -97
  340. data/vendor/v8/src/platform.h +72 -15
  341. data/vendor/v8/src/preparse-data.cc +2 -0
  342. data/vendor/v8/src/preparser-api.cc +8 -2
  343. data/vendor/v8/src/preparser.cc +1 -1
  344. data/vendor/v8/src/prettyprinter.cc +43 -52
  345. data/vendor/v8/src/prettyprinter.h +1 -1
  346. data/vendor/v8/src/profile-generator-inl.h +0 -28
  347. data/vendor/v8/src/profile-generator.cc +942 -685
  348. data/vendor/v8/src/profile-generator.h +210 -176
  349. data/vendor/v8/src/property.cc +6 -0
  350. data/vendor/v8/src/property.h +14 -3
  351. data/vendor/v8/src/regexp-macro-assembler-irregexp.cc +1 -1
  352. data/vendor/v8/src/regexp-macro-assembler.cc +28 -19
  353. data/vendor/v8/src/regexp-macro-assembler.h +11 -6
  354. data/vendor/v8/src/regexp-stack.cc +18 -10
  355. data/vendor/v8/src/regexp-stack.h +45 -21
  356. data/vendor/v8/src/regexp.js +3 -3
  357. data/vendor/v8/src/register-allocator-inl.h +3 -3
  358. data/vendor/v8/src/register-allocator.cc +1 -7
  359. data/vendor/v8/src/register-allocator.h +5 -15
  360. data/vendor/v8/src/rewriter.cc +2 -1
  361. data/vendor/v8/src/runtime-profiler.cc +158 -128
  362. data/vendor/v8/src/runtime-profiler.h +131 -15
  363. data/vendor/v8/src/runtime.cc +2409 -1692
  364. data/vendor/v8/src/runtime.h +93 -17
  365. data/vendor/v8/src/safepoint-table.cc +3 -0
  366. data/vendor/v8/src/safepoint-table.h +9 -3
  367. data/vendor/v8/src/scanner-base.cc +21 -28
  368. data/vendor/v8/src/scanner-base.h +22 -11
  369. data/vendor/v8/src/scanner.cc +3 -5
  370. data/vendor/v8/src/scanner.h +4 -2
  371. data/vendor/v8/src/scopeinfo.cc +11 -16
  372. data/vendor/v8/src/scopeinfo.h +26 -15
  373. data/vendor/v8/src/scopes.cc +67 -37
  374. data/vendor/v8/src/scopes.h +26 -12
  375. data/vendor/v8/src/serialize.cc +193 -154
  376. data/vendor/v8/src/serialize.h +41 -36
  377. data/vendor/v8/src/small-pointer-list.h +163 -0
  378. data/vendor/v8/src/snapshot-common.cc +1 -1
  379. data/vendor/v8/src/snapshot.h +3 -1
  380. data/vendor/v8/src/spaces-inl.h +30 -25
  381. data/vendor/v8/src/spaces.cc +263 -370
  382. data/vendor/v8/src/spaces.h +178 -166
  383. data/vendor/v8/src/string-search.cc +4 -3
  384. data/vendor/v8/src/string-search.h +21 -20
  385. data/vendor/v8/src/string-stream.cc +32 -24
  386. data/vendor/v8/src/string.js +7 -7
  387. data/vendor/v8/src/stub-cache.cc +324 -248
  388. data/vendor/v8/src/stub-cache.h +181 -155
  389. data/vendor/v8/src/token.cc +3 -3
  390. data/vendor/v8/src/token.h +3 -3
  391. data/vendor/v8/src/top.cc +218 -390
  392. data/vendor/v8/src/type-info.cc +98 -32
  393. data/vendor/v8/src/type-info.h +10 -3
  394. data/vendor/v8/src/unicode.cc +1 -1
  395. data/vendor/v8/src/unicode.h +1 -1
  396. data/vendor/v8/src/utils.h +3 -0
  397. data/vendor/v8/src/v8-counters.cc +18 -11
  398. data/vendor/v8/src/v8-counters.h +34 -13
  399. data/vendor/v8/src/v8.cc +66 -121
  400. data/vendor/v8/src/v8.h +7 -4
  401. data/vendor/v8/src/v8globals.h +18 -12
  402. data/vendor/v8/src/{memory.h → v8memory.h} +0 -0
  403. data/vendor/v8/src/v8natives.js +59 -18
  404. data/vendor/v8/src/v8threads.cc +127 -114
  405. data/vendor/v8/src/v8threads.h +42 -35
  406. data/vendor/v8/src/v8utils.h +2 -39
  407. data/vendor/v8/src/variables.h +1 -1
  408. data/vendor/v8/src/version.cc +26 -5
  409. data/vendor/v8/src/version.h +4 -0
  410. data/vendor/v8/src/virtual-frame-heavy-inl.h +2 -4
  411. data/vendor/v8/src/virtual-frame-light-inl.h +5 -4
  412. data/vendor/v8/src/vm-state-inl.h +21 -17
  413. data/vendor/v8/src/vm-state.h +7 -5
  414. data/vendor/v8/src/win32-headers.h +1 -0
  415. data/vendor/v8/src/x64/assembler-x64-inl.h +12 -11
  416. data/vendor/v8/src/x64/assembler-x64.cc +80 -40
  417. data/vendor/v8/src/x64/assembler-x64.h +67 -17
  418. data/vendor/v8/src/x64/builtins-x64.cc +34 -33
  419. data/vendor/v8/src/x64/code-stubs-x64.cc +636 -377
  420. data/vendor/v8/src/x64/code-stubs-x64.h +14 -48
  421. data/vendor/v8/src/x64/codegen-x64-inl.h +1 -1
  422. data/vendor/v8/src/x64/codegen-x64.cc +158 -136
  423. data/vendor/v8/src/x64/codegen-x64.h +4 -1
  424. data/vendor/v8/src/x64/cpu-x64.cc +7 -5
  425. data/vendor/v8/src/x64/debug-x64.cc +8 -6
  426. data/vendor/v8/src/x64/deoptimizer-x64.cc +195 -20
  427. data/vendor/v8/src/x64/disasm-x64.cc +42 -23
  428. data/vendor/v8/src/x64/frames-x64.cc +1 -1
  429. data/vendor/v8/src/x64/frames-x64.h +2 -2
  430. data/vendor/v8/src/x64/full-codegen-x64.cc +780 -218
  431. data/vendor/v8/src/x64/ic-x64.cc +77 -79
  432. data/vendor/v8/src/x64/jump-target-x64.cc +1 -1
  433. data/vendor/v8/src/x64/lithium-codegen-x64.cc +698 -181
  434. data/vendor/v8/src/x64/lithium-codegen-x64.h +31 -6
  435. data/vendor/v8/src/x64/lithium-x64.cc +136 -54
  436. data/vendor/v8/src/x64/lithium-x64.h +142 -51
  437. data/vendor/v8/src/x64/macro-assembler-x64.cc +456 -187
  438. data/vendor/v8/src/x64/macro-assembler-x64.h +166 -34
  439. data/vendor/v8/src/x64/regexp-macro-assembler-x64.cc +44 -28
  440. data/vendor/v8/src/x64/regexp-macro-assembler-x64.h +8 -4
  441. data/vendor/v8/src/x64/register-allocator-x64-inl.h +3 -3
  442. data/vendor/v8/src/x64/register-allocator-x64.cc +12 -8
  443. data/vendor/v8/src/x64/simulator-x64.h +5 -5
  444. data/vendor/v8/src/x64/stub-cache-x64.cc +299 -344
  445. data/vendor/v8/src/x64/virtual-frame-x64.cc +37 -13
  446. data/vendor/v8/src/x64/virtual-frame-x64.h +13 -7
  447. data/vendor/v8/src/zone-inl.h +49 -3
  448. data/vendor/v8/src/zone.cc +42 -41
  449. data/vendor/v8/src/zone.h +37 -34
  450. data/vendor/v8/test/benchmarks/testcfg.py +100 -0
  451. data/vendor/v8/test/cctest/SConscript +5 -4
  452. data/vendor/v8/test/cctest/cctest.h +3 -2
  453. data/vendor/v8/test/cctest/cctest.status +6 -11
  454. data/vendor/v8/test/cctest/test-accessors.cc +3 -3
  455. data/vendor/v8/test/cctest/test-alloc.cc +39 -33
  456. data/vendor/v8/test/cctest/test-api.cc +1092 -205
  457. data/vendor/v8/test/cctest/test-assembler-arm.cc +39 -25
  458. data/vendor/v8/test/cctest/test-assembler-ia32.cc +36 -37
  459. data/vendor/v8/test/cctest/test-assembler-mips.cc +1098 -40
  460. data/vendor/v8/test/cctest/test-assembler-x64.cc +32 -25
  461. data/vendor/v8/test/cctest/test-ast.cc +1 -0
  462. data/vendor/v8/test/cctest/test-circular-queue.cc +8 -5
  463. data/vendor/v8/test/cctest/test-compiler.cc +24 -24
  464. data/vendor/v8/test/cctest/test-cpu-profiler.cc +140 -5
  465. data/vendor/v8/test/cctest/test-dataflow.cc +1 -0
  466. data/vendor/v8/test/cctest/test-debug.cc +136 -77
  467. data/vendor/v8/test/cctest/test-decls.cc +1 -1
  468. data/vendor/v8/test/cctest/test-deoptimization.cc +25 -24
  469. data/vendor/v8/test/cctest/test-disasm-arm.cc +9 -4
  470. data/vendor/v8/test/cctest/test-disasm-ia32.cc +10 -8
  471. data/vendor/v8/test/cctest/test-func-name-inference.cc +10 -4
  472. data/vendor/v8/test/cctest/test-heap-profiler.cc +226 -164
  473. data/vendor/v8/test/cctest/test-heap.cc +240 -217
  474. data/vendor/v8/test/cctest/test-liveedit.cc +1 -0
  475. data/vendor/v8/test/cctest/test-log-stack-tracer.cc +18 -20
  476. data/vendor/v8/test/cctest/test-log.cc +114 -108
  477. data/vendor/v8/test/cctest/test-macro-assembler-x64.cc +247 -177
  478. data/vendor/v8/test/cctest/test-mark-compact.cc +129 -90
  479. data/vendor/v8/test/cctest/test-parsing.cc +15 -14
  480. data/vendor/v8/test/cctest/test-platform-linux.cc +1 -0
  481. data/vendor/v8/test/cctest/test-platform-tls.cc +66 -0
  482. data/vendor/v8/test/cctest/test-platform-win32.cc +1 -0
  483. data/vendor/v8/test/cctest/test-profile-generator.cc +1 -1
  484. data/vendor/v8/test/cctest/test-regexp.cc +53 -41
  485. data/vendor/v8/test/cctest/test-reloc-info.cc +18 -11
  486. data/vendor/v8/test/cctest/test-serialize.cc +44 -43
  487. data/vendor/v8/test/cctest/test-sockets.cc +8 -3
  488. data/vendor/v8/test/cctest/test-spaces.cc +47 -29
  489. data/vendor/v8/test/cctest/test-strings.cc +20 -20
  490. data/vendor/v8/test/cctest/test-thread-termination.cc +8 -3
  491. data/vendor/v8/test/cctest/test-threads.cc +5 -3
  492. data/vendor/v8/test/cctest/test-utils.cc +5 -4
  493. data/vendor/v8/test/cctest/testcfg.py +7 -3
  494. data/vendor/v8/test/es5conform/es5conform.status +2 -77
  495. data/vendor/v8/test/es5conform/testcfg.py +1 -1
  496. data/vendor/v8/test/message/testcfg.py +1 -1
  497. data/vendor/v8/test/mjsunit/accessors-on-global-object.js +3 -3
  498. data/vendor/v8/test/mjsunit/array-concat.js +43 -1
  499. data/vendor/v8/test/mjsunit/array-join.js +25 -0
  500. data/vendor/v8/test/mjsunit/bitops-info.js +7 -1
  501. data/vendor/v8/test/mjsunit/compiler/array-length.js +2 -2
  502. data/vendor/v8/test/mjsunit/compiler/global-accessors.js +47 -0
  503. data/vendor/v8/test/mjsunit/compiler/pic.js +1 -1
  504. data/vendor/v8/test/mjsunit/compiler/regress-loadfield.js +65 -0
  505. data/vendor/v8/test/mjsunit/math-sqrt.js +5 -1
  506. data/vendor/v8/test/mjsunit/mjsunit.js +59 -8
  507. data/vendor/v8/test/mjsunit/mjsunit.status +0 -12
  508. data/vendor/v8/test/mjsunit/mul-exhaustive.js +129 -11
  509. data/vendor/v8/test/mjsunit/negate-zero.js +1 -1
  510. data/vendor/v8/test/mjsunit/object-freeze.js +5 -13
  511. data/vendor/v8/test/mjsunit/object-prevent-extensions.js +9 -50
  512. data/vendor/v8/test/mjsunit/object-seal.js +4 -13
  513. data/vendor/v8/test/mjsunit/override-eval-with-non-function.js +36 -0
  514. data/vendor/v8/test/mjsunit/regress/regress-1145.js +54 -0
  515. data/vendor/v8/test/mjsunit/regress/regress-1172-bis.js +37 -0
  516. data/vendor/v8/test/mjsunit/regress/regress-1181.js +54 -0
  517. data/vendor/v8/test/mjsunit/regress/regress-1207.js +35 -0
  518. data/vendor/v8/test/mjsunit/regress/regress-1209.js +34 -0
  519. data/vendor/v8/test/mjsunit/regress/regress-1210.js +48 -0
  520. data/vendor/v8/test/mjsunit/regress/regress-1213.js +43 -0
  521. data/vendor/v8/test/mjsunit/regress/regress-1218.js +29 -0
  522. data/vendor/v8/test/mjsunit/regress/regress-1229.js +79 -0
  523. data/vendor/v8/test/mjsunit/regress/regress-1233.js +47 -0
  524. data/vendor/v8/test/mjsunit/regress/regress-1236.js +34 -0
  525. data/vendor/v8/test/mjsunit/regress/regress-1237.js +36 -0
  526. data/vendor/v8/test/mjsunit/regress/regress-1240.js +39 -0
  527. data/vendor/v8/test/mjsunit/regress/regress-1257.js +58 -0
  528. data/vendor/v8/test/mjsunit/regress/regress-1278.js +69 -0
  529. data/vendor/v8/test/mjsunit/regress/regress-create-exception.js +1 -0
  530. data/vendor/v8/test/mjsunit/regress/regress-lazy-deopt-reloc.js +52 -0
  531. data/vendor/v8/test/mjsunit/sin-cos.js +15 -10
  532. data/vendor/v8/test/mjsunit/smi-negative-zero.js +2 -2
  533. data/vendor/v8/test/mjsunit/str-to-num.js +1 -1
  534. data/vendor/v8/test/mjsunit/strict-mode.js +435 -0
  535. data/vendor/v8/test/mjsunit/testcfg.py +23 -6
  536. data/vendor/v8/test/mozilla/mozilla.status +0 -2
  537. data/vendor/v8/test/mozilla/testcfg.py +1 -1
  538. data/vendor/v8/test/preparser/empty.js +28 -0
  539. data/vendor/v8/test/preparser/functions-only.js +38 -0
  540. data/vendor/v8/test/preparser/non-alphanum.js +34 -0
  541. data/vendor/v8/test/preparser/symbols-only.js +49 -0
  542. data/vendor/v8/test/preparser/testcfg.py +90 -0
  543. data/vendor/v8/test/sputnik/testcfg.py +1 -1
  544. data/vendor/v8/test/test262/README +16 -0
  545. data/vendor/v8/test/test262/harness-adapt.js +80 -0
  546. data/vendor/v8/test/test262/test262.status +1506 -0
  547. data/vendor/v8/test/test262/testcfg.py +123 -0
  548. data/vendor/v8/tools/freebsd-tick-processor +10 -0
  549. data/vendor/v8/tools/gyp/v8.gyp +8 -33
  550. data/vendor/v8/tools/linux-tick-processor +5 -3
  551. data/vendor/v8/tools/test.py +37 -14
  552. data/vendor/v8/tools/tickprocessor.js +22 -8
  553. data/vendor/v8/tools/visual_studio/v8_base.vcproj +13 -1
  554. data/vendor/v8/tools/visual_studio/v8_base_arm.vcproj +5 -1
  555. data/vendor/v8/tools/visual_studio/v8_base_x64.vcproj +5 -1
  556. data/vendor/v8/tools/visual_studio/x64.vsprops +1 -0
  557. metadata +1495 -1341
  558. data/ext/extconf.rb +0 -22
  559. data/ext/mustang.cpp +0 -58
  560. data/vendor/v8/src/top.h +0 -608
@@ -88,12 +88,13 @@ class PositionStack {
88
88
 
89
89
 
90
90
  RegExpBuilder::RegExpBuilder()
91
- : pending_empty_(false),
92
- characters_(NULL),
93
- terms_(),
94
- alternatives_()
91
+ : zone_(Isolate::Current()->zone()),
92
+ pending_empty_(false),
93
+ characters_(NULL),
94
+ terms_(),
95
+ alternatives_()
95
96
  #ifdef DEBUG
96
- , last_added_(ADD_NONE)
97
+ , last_added_(ADD_NONE)
97
98
  #endif
98
99
  {}
99
100
 
@@ -101,7 +102,7 @@ RegExpBuilder::RegExpBuilder()
101
102
  void RegExpBuilder::FlushCharacters() {
102
103
  pending_empty_ = false;
103
104
  if (characters_ != NULL) {
104
- RegExpTree* atom = new RegExpAtom(characters_->ToConstVector());
105
+ RegExpTree* atom = new(zone()) RegExpAtom(characters_->ToConstVector());
105
106
  characters_ = NULL;
106
107
  text_.Add(atom);
107
108
  LAST(ADD_ATOM);
@@ -117,7 +118,7 @@ void RegExpBuilder::FlushText() {
117
118
  } else if (num_text == 1) {
118
119
  terms_.Add(text_.last());
119
120
  } else {
120
- RegExpText* text = new RegExpText();
121
+ RegExpText* text = new(zone()) RegExpText();
121
122
  for (int i = 0; i < num_text; i++)
122
123
  text_.Get(i)->AppendToText(text);
123
124
  terms_.Add(text);
@@ -178,7 +179,7 @@ void RegExpBuilder::FlushTerms() {
178
179
  } else if (num_terms == 1) {
179
180
  alternative = terms_.last();
180
181
  } else {
181
- alternative = new RegExpAlternative(terms_.GetList());
182
+ alternative = new(zone()) RegExpAlternative(terms_.GetList());
182
183
  }
183
184
  alternatives_.Add(alternative);
184
185
  terms_.Clear();
@@ -195,7 +196,7 @@ RegExpTree* RegExpBuilder::ToRegExp() {
195
196
  if (num_alternatives == 1) {
196
197
  return alternatives_.last();
197
198
  }
198
- return new RegExpDisjunction(alternatives_.GetList());
199
+ return new(zone()) RegExpDisjunction(alternatives_.GetList());
199
200
  }
200
201
 
201
202
 
@@ -214,11 +215,11 @@ void RegExpBuilder::AddQuantifierToAtom(int min,
214
215
  int num_chars = char_vector.length();
215
216
  if (num_chars > 1) {
216
217
  Vector<const uc16> prefix = char_vector.SubVector(0, num_chars - 1);
217
- text_.Add(new RegExpAtom(prefix));
218
+ text_.Add(new(zone()) RegExpAtom(prefix));
218
219
  char_vector = char_vector.SubVector(num_chars - 1, num_chars);
219
220
  }
220
221
  characters_ = NULL;
221
- atom = new RegExpAtom(char_vector);
222
+ atom = new(zone()) RegExpAtom(char_vector);
222
223
  FlushText();
223
224
  } else if (text_.length() > 0) {
224
225
  ASSERT(last_added_ == ADD_ATOM);
@@ -241,98 +242,11 @@ void RegExpBuilder::AddQuantifierToAtom(int min,
241
242
  UNREACHABLE();
242
243
  return;
243
244
  }
244
- terms_.Add(new RegExpQuantifier(min, max, type, atom));
245
+ terms_.Add(new(zone()) RegExpQuantifier(min, max, type, atom));
245
246
  LAST(ADD_TERM);
246
247
  }
247
248
 
248
249
 
249
- // A temporary scope stores information during parsing, just like
250
- // a plain scope. However, temporary scopes are not kept around
251
- // after parsing or referenced by syntax trees so they can be stack-
252
- // allocated and hence used by the pre-parser.
253
- class TemporaryScope BASE_EMBEDDED {
254
- public:
255
- explicit TemporaryScope(TemporaryScope** variable);
256
- ~TemporaryScope();
257
-
258
- int NextMaterializedLiteralIndex() {
259
- int next_index =
260
- materialized_literal_count_ + JSFunction::kLiteralsPrefixSize;
261
- materialized_literal_count_++;
262
- return next_index;
263
- }
264
- int materialized_literal_count() { return materialized_literal_count_; }
265
-
266
- void SetThisPropertyAssignmentInfo(
267
- bool only_simple_this_property_assignments,
268
- Handle<FixedArray> this_property_assignments) {
269
- only_simple_this_property_assignments_ =
270
- only_simple_this_property_assignments;
271
- this_property_assignments_ = this_property_assignments;
272
- }
273
- bool only_simple_this_property_assignments() {
274
- return only_simple_this_property_assignments_;
275
- }
276
- Handle<FixedArray> this_property_assignments() {
277
- return this_property_assignments_;
278
- }
279
-
280
- void AddProperty() { expected_property_count_++; }
281
- int expected_property_count() { return expected_property_count_; }
282
-
283
- void AddLoop() { loop_count_++; }
284
- bool ContainsLoops() const { return loop_count_ > 0; }
285
-
286
- bool StrictMode() { return strict_mode_; }
287
- void EnableStrictMode() {
288
- strict_mode_ = FLAG_strict_mode;
289
- }
290
-
291
- private:
292
- // Captures the number of literals that need materialization in the
293
- // function. Includes regexp literals, and boilerplate for object
294
- // and array literals.
295
- int materialized_literal_count_;
296
-
297
- // Properties count estimation.
298
- int expected_property_count_;
299
-
300
- // Keeps track of assignments to properties of this. Used for
301
- // optimizing constructors.
302
- bool only_simple_this_property_assignments_;
303
- Handle<FixedArray> this_property_assignments_;
304
-
305
- // Captures the number of loops inside the scope.
306
- int loop_count_;
307
-
308
- // Parsing strict mode code.
309
- bool strict_mode_;
310
-
311
- // Bookkeeping
312
- TemporaryScope** variable_;
313
- TemporaryScope* parent_;
314
- };
315
-
316
-
317
- TemporaryScope::TemporaryScope(TemporaryScope** variable)
318
- : materialized_literal_count_(0),
319
- expected_property_count_(0),
320
- only_simple_this_property_assignments_(false),
321
- this_property_assignments_(Factory::empty_fixed_array()),
322
- loop_count_(0),
323
- variable_(variable),
324
- parent_(*variable) {
325
- // Inherit the strict mode from the parent scope.
326
- strict_mode_ = (parent_ != NULL) && parent_->strict_mode_;
327
- *variable = this;
328
- }
329
-
330
-
331
- TemporaryScope::~TemporaryScope() {
332
- *variable_ = parent_;
333
- }
334
-
335
-
336
250
  Handle<String> Parser::LookupSymbol(int symbol_id) {
337
251
  // Length of symbol cache is the number of identified symbols.
338
252
  // If we are larger than that, or negative, it's not a cached symbol.
@@ -341,9 +255,11 @@ Handle<String> Parser::LookupSymbol(int symbol_id) {
341
255
  if (static_cast<unsigned>(symbol_id)
342
256
  >= static_cast<unsigned>(symbol_cache_.length())) {
343
257
  if (scanner().is_literal_ascii()) {
344
- return Factory::LookupAsciiSymbol(scanner().literal_ascii_string());
258
+ return isolate()->factory()->LookupAsciiSymbol(
259
+ scanner().literal_ascii_string());
345
260
  } else {
346
- return Factory::LookupTwoByteSymbol(scanner().literal_uc16_string());
261
+ return isolate()->factory()->LookupTwoByteSymbol(
262
+ scanner().literal_uc16_string());
347
263
  }
348
264
  }
349
265
  return LookupCachedSymbol(symbol_id);
@@ -360,14 +276,16 @@ Handle<String> Parser::LookupCachedSymbol(int symbol_id) {
360
276
  Handle<String> result = symbol_cache_.at(symbol_id);
361
277
  if (result.is_null()) {
362
278
  if (scanner().is_literal_ascii()) {
363
- result = Factory::LookupAsciiSymbol(scanner().literal_ascii_string());
279
+ result = isolate()->factory()->LookupAsciiSymbol(
280
+ scanner().literal_ascii_string());
364
281
  } else {
365
- result = Factory::LookupTwoByteSymbol(scanner().literal_uc16_string());
282
+ result = isolate()->factory()->LookupTwoByteSymbol(
283
+ scanner().literal_uc16_string());
366
284
  }
367
285
  symbol_cache_.at(symbol_id) = result;
368
286
  return result;
369
287
  }
370
- Counters::total_preparse_symbols_skipped.Increment();
288
+ isolate()->counters()->total_preparse_symbols_skipped()->Increment();
371
289
  return result;
372
290
  }
373
291
 
@@ -491,7 +409,7 @@ unsigned* ScriptDataImpl::ReadAddress(int position) {
491
409
 
492
410
 
493
411
  Scope* Parser::NewScope(Scope* parent, Scope::Type type, bool inside_with) {
494
- Scope* result = new Scope(parent, type);
412
+ Scope* result = new(zone()) Scope(parent, type);
495
413
  result->Initialize(inside_with);
496
414
  return result;
497
415
  }
@@ -544,33 +462,94 @@ class TargetScope BASE_EMBEDDED {
544
462
  // LexicalScope is a support class to facilitate manipulation of the
545
463
  // Parser's scope stack. The constructor sets the parser's top scope
546
464
  // to the incoming scope, and the destructor resets it.
465
+ //
466
+ // Additionlaly, it stores transient information used during parsing.
467
+ // These scopes are not kept around after parsing or referenced by syntax
468
+ // trees so they can be stack-allocated and hence used by the pre-parser.
547
469
 
548
470
  class LexicalScope BASE_EMBEDDED {
549
471
  public:
550
- LexicalScope(Scope** scope_variable,
551
- int* with_nesting_level_variable,
552
- Scope* scope)
553
- : scope_variable_(scope_variable),
554
- with_nesting_level_variable_(with_nesting_level_variable),
555
- prev_scope_(*scope_variable),
556
- prev_level_(*with_nesting_level_variable) {
557
- *scope_variable = scope;
558
- *with_nesting_level_variable = 0;
472
+ LexicalScope(Parser* parser, Scope* scope, Isolate* isolate);
473
+ ~LexicalScope();
474
+
475
+ int NextMaterializedLiteralIndex() {
476
+ int next_index =
477
+ materialized_literal_count_ + JSFunction::kLiteralsPrefixSize;
478
+ materialized_literal_count_++;
479
+ return next_index;
559
480
  }
481
+ int materialized_literal_count() { return materialized_literal_count_; }
560
482
 
561
- ~LexicalScope() {
562
- (*scope_variable_)->Leave();
563
- *scope_variable_ = prev_scope_;
564
- *with_nesting_level_variable_ = prev_level_;
483
+ void SetThisPropertyAssignmentInfo(
484
+ bool only_simple_this_property_assignments,
485
+ Handle<FixedArray> this_property_assignments) {
486
+ only_simple_this_property_assignments_ =
487
+ only_simple_this_property_assignments;
488
+ this_property_assignments_ = this_property_assignments;
489
+ }
490
+ bool only_simple_this_property_assignments() {
491
+ return only_simple_this_property_assignments_;
565
492
  }
493
+ Handle<FixedArray> this_property_assignments() {
494
+ return this_property_assignments_;
495
+ }
496
+
497
+ void AddProperty() { expected_property_count_++; }
498
+ int expected_property_count() { return expected_property_count_; }
499
+
500
+ void AddLoop() { loop_count_++; }
501
+ bool ContainsLoops() const { return loop_count_ > 0; }
566
502
 
567
503
  private:
568
- Scope** scope_variable_;
569
- int* with_nesting_level_variable_;
570
- Scope* prev_scope_;
571
- int prev_level_;
504
+ // Captures the number of literals that need materialization in the
505
+ // function. Includes regexp literals, and boilerplate for object
506
+ // and array literals.
507
+ int materialized_literal_count_;
508
+
509
+ // Properties count estimation.
510
+ int expected_property_count_;
511
+
512
+ // Keeps track of assignments to properties of this. Used for
513
+ // optimizing constructors.
514
+ bool only_simple_this_property_assignments_;
515
+ Handle<FixedArray> this_property_assignments_;
516
+
517
+ // Captures the number of loops inside the scope.
518
+ int loop_count_;
519
+
520
+ // Bookkeeping
521
+ Parser* parser_;
522
+ // Previous values
523
+ LexicalScope* lexical_scope_parent_;
524
+ Scope* previous_scope_;
525
+ int previous_with_nesting_level_;
572
526
  };
573
527
 
528
+
529
+ LexicalScope::LexicalScope(Parser* parser, Scope* scope, Isolate* isolate)
530
+ : materialized_literal_count_(0),
531
+ expected_property_count_(0),
532
+ only_simple_this_property_assignments_(false),
533
+ this_property_assignments_(isolate->factory()->empty_fixed_array()),
534
+ loop_count_(0),
535
+ parser_(parser),
536
+ lexical_scope_parent_(parser->lexical_scope_),
537
+ previous_scope_(parser->top_scope_),
538
+ previous_with_nesting_level_(parser->with_nesting_level_) {
539
+ parser->top_scope_ = scope;
540
+ parser->lexical_scope_ = this;
541
+ parser->with_nesting_level_ = 0;
542
+ }
543
+
544
+
545
+ LexicalScope::~LexicalScope() {
546
+ parser_->top_scope_->Leave();
547
+ parser_->top_scope_ = previous_scope_;
548
+ parser_->lexical_scope_ = lexical_scope_parent_;
549
+ parser_->with_nesting_level_ = previous_with_nesting_level_;
550
+ }
551
+
552
+
574
553
  // ----------------------------------------------------------------------------
575
554
  // The CHECK_OK macro is a convenient macro to enforce error
576
555
  // handling for functions that may fail (by returning !*ok).
@@ -598,12 +577,13 @@ Parser::Parser(Handle<Script> script,
598
577
  bool allow_natives_syntax,
599
578
  v8::Extension* extension,
600
579
  ScriptDataImpl* pre_data)
601
- : symbol_cache_(pre_data ? pre_data->symbol_count() : 0),
580
+ : isolate_(script->GetIsolate()),
581
+ symbol_cache_(pre_data ? pre_data->symbol_count() : 0),
602
582
  script_(script),
603
- scanner_(),
583
+ scanner_(isolate_->scanner_constants()),
604
584
  top_scope_(NULL),
605
585
  with_nesting_level_(0),
606
- temp_scope_(NULL),
586
+ lexical_scope_(NULL),
607
587
  target_stack_(NULL),
608
588
  allow_natives_syntax_(allow_natives_syntax),
609
589
  extension_(extension),
@@ -620,9 +600,9 @@ FunctionLiteral* Parser::ParseProgram(Handle<String> source,
620
600
  StrictModeFlag strict_mode) {
621
601
  CompilationZoneScope zone_scope(DONT_DELETE_ON_EXIT);
622
602
 
623
- HistogramTimerScope timer(&Counters::parse);
624
- Counters::total_parse_size.Increment(source->length());
625
- fni_ = new FuncNameInferrer();
603
+ HistogramTimerScope timer(isolate()->counters()->parse());
604
+ isolate()->counters()->total_parse_size()->Increment(source->length());
605
+ fni_ = new(zone()) FuncNameInferrer();
626
606
 
627
607
  // Initialize parser state.
628
608
  source->TryFlatten();
@@ -657,40 +637,37 @@ FunctionLiteral* Parser::DoParseProgram(Handle<String> source,
657
637
  in_global_context
658
638
  ? Scope::GLOBAL_SCOPE
659
639
  : Scope::EVAL_SCOPE;
660
- Handle<String> no_name = Factory::empty_symbol();
640
+ Handle<String> no_name = isolate()->factory()->empty_symbol();
661
641
 
662
642
  FunctionLiteral* result = NULL;
663
643
  { Scope* scope = NewScope(top_scope_, type, inside_with());
664
- LexicalScope lexical_scope(&this->top_scope_, &this->with_nesting_level_,
665
- scope);
666
- TemporaryScope temp_scope(&this->temp_scope_);
644
+ LexicalScope lexical_scope(this, scope, isolate());
667
645
  if (strict_mode == kStrictMode) {
668
- temp_scope.EnableStrictMode();
646
+ top_scope_->EnableStrictMode();
669
647
  }
670
648
  ZoneList<Statement*>* body = new ZoneList<Statement*>(16);
671
649
  bool ok = true;
672
650
  int beg_loc = scanner().location().beg_pos;
673
651
  ParseSourceElements(body, Token::EOS, &ok);
674
- if (ok && temp_scope_->StrictMode()) {
652
+ if (ok && top_scope_->is_strict_mode()) {
675
653
  CheckOctalLiteral(beg_loc, scanner().location().end_pos, &ok);
676
654
  }
677
655
  if (ok) {
678
- result = new FunctionLiteral(
656
+ result = new(zone()) FunctionLiteral(
679
657
  no_name,
680
658
  top_scope_,
681
659
  body,
682
- temp_scope.materialized_literal_count(),
683
- temp_scope.expected_property_count(),
684
- temp_scope.only_simple_this_property_assignments(),
685
- temp_scope.this_property_assignments(),
660
+ lexical_scope.materialized_literal_count(),
661
+ lexical_scope.expected_property_count(),
662
+ lexical_scope.only_simple_this_property_assignments(),
663
+ lexical_scope.this_property_assignments(),
686
664
  0,
687
665
  0,
688
666
  source->length(),
689
667
  false,
690
- temp_scope.ContainsLoops(),
691
- temp_scope.StrictMode());
668
+ lexical_scope.ContainsLoops());
692
669
  } else if (stack_overflow_) {
693
- Top::StackOverflow();
670
+ isolate()->StackOverflow();
694
671
  }
695
672
  }
696
673
 
@@ -703,39 +680,41 @@ FunctionLiteral* Parser::DoParseProgram(Handle<String> source,
703
680
  return result;
704
681
  }
705
682
 
706
- FunctionLiteral* Parser::ParseLazy(Handle<SharedFunctionInfo> info) {
683
+ FunctionLiteral* Parser::ParseLazy(CompilationInfo* info) {
707
684
  CompilationZoneScope zone_scope(DONT_DELETE_ON_EXIT);
708
- HistogramTimerScope timer(&Counters::parse_lazy);
685
+ HistogramTimerScope timer(isolate()->counters()->parse_lazy());
709
686
  Handle<String> source(String::cast(script_->source()));
710
- Counters::total_parse_size.Increment(source->length());
687
+ isolate()->counters()->total_parse_size()->Increment(source->length());
711
688
 
689
+ Handle<SharedFunctionInfo> shared_info = info->shared_info();
712
690
  // Initialize parser state.
713
691
  source->TryFlatten();
714
692
  if (source->IsExternalTwoByteString()) {
715
693
  ExternalTwoByteStringUC16CharacterStream stream(
716
694
  Handle<ExternalTwoByteString>::cast(source),
717
- info->start_position(),
718
- info->end_position());
695
+ shared_info->start_position(),
696
+ shared_info->end_position());
719
697
  FunctionLiteral* result = ParseLazy(info, &stream, &zone_scope);
720
698
  return result;
721
699
  } else {
722
700
  GenericStringUC16CharacterStream stream(source,
723
- info->start_position(),
724
- info->end_position());
701
+ shared_info->start_position(),
702
+ shared_info->end_position());
725
703
  FunctionLiteral* result = ParseLazy(info, &stream, &zone_scope);
726
704
  return result;
727
705
  }
728
706
  }
729
707
 
730
708
 
731
- FunctionLiteral* Parser::ParseLazy(Handle<SharedFunctionInfo> info,
709
+ FunctionLiteral* Parser::ParseLazy(CompilationInfo* info,
732
710
  UC16CharacterStream* source,
733
711
  ZoneScope* zone_scope) {
712
+ Handle<SharedFunctionInfo> shared_info = info->shared_info();
734
713
  scanner_.Initialize(source);
735
714
  ASSERT(target_stack_ == NULL);
736
715
 
737
- Handle<String> name(String::cast(info->name()));
738
- fni_ = new FuncNameInferrer();
716
+ Handle<String> name(String::cast(shared_info->name()));
717
+ fni_ = new(zone()) FuncNameInferrer();
739
718
  fni_->PushEnclosingName(name);
740
719
 
741
720
  mode_ = PARSE_EAGERLY;
@@ -745,19 +724,19 @@ FunctionLiteral* Parser::ParseLazy(Handle<SharedFunctionInfo> info,
745
724
 
746
725
  {
747
726
  // Parse the function literal.
748
- Handle<String> no_name = Factory::empty_symbol();
749
- Scope* scope =
750
- NewScope(top_scope_, Scope::GLOBAL_SCOPE, inside_with());
751
- LexicalScope lexical_scope(&this->top_scope_, &this->with_nesting_level_,
752
- scope);
753
- TemporaryScope temp_scope(&this->temp_scope_);
754
-
755
- if (info->strict_mode()) {
756
- temp_scope.EnableStrictMode();
727
+ Handle<String> no_name = isolate()->factory()->empty_symbol();
728
+ Scope* scope = NewScope(top_scope_, Scope::GLOBAL_SCOPE, inside_with());
729
+ if (!info->closure().is_null()) {
730
+ scope = Scope::DeserializeScopeChain(info, scope);
731
+ }
732
+ LexicalScope lexical_scope(this, scope, isolate());
733
+
734
+ if (shared_info->strict_mode()) {
735
+ top_scope_->EnableStrictMode();
757
736
  }
758
737
 
759
738
  FunctionLiteralType type =
760
- info->is_expression() ? EXPRESSION : DECLARATION;
739
+ shared_info->is_expression() ? EXPRESSION : DECLARATION;
761
740
  bool ok = true;
762
741
  result = ParseFunctionLiteral(name,
763
742
  false, // Strict mode name already checked.
@@ -773,9 +752,9 @@ FunctionLiteral* Parser::ParseLazy(Handle<SharedFunctionInfo> info,
773
752
  // not safe to do before scope has been deleted.
774
753
  if (result == NULL) {
775
754
  zone_scope->DeleteOnExit();
776
- if (stack_overflow_) Top::StackOverflow();
755
+ if (stack_overflow_) isolate()->StackOverflow();
777
756
  } else {
778
- Handle<String> inferred_name(info->inferred_name());
757
+ Handle<String> inferred_name(shared_info->inferred_name());
779
758
  result->set_inferred_name(inferred_name);
780
759
  }
781
760
  return result;
@@ -803,12 +782,15 @@ void Parser::ReportMessageAt(Scanner::Location source_location,
803
782
  MessageLocation location(script_,
804
783
  source_location.beg_pos,
805
784
  source_location.end_pos);
806
- Handle<JSArray> array = Factory::NewJSArray(args.length());
785
+ Factory* factory = isolate()->factory();
786
+ Handle<FixedArray> elements = factory->NewFixedArray(args.length());
807
787
  for (int i = 0; i < args.length(); i++) {
808
- SetElement(array, i, Factory::NewStringFromUtf8(CStrVector(args[i])));
788
+ Handle<String> arg_string = factory->NewStringFromUtf8(CStrVector(args[i]));
789
+ elements->set(i, *arg_string);
809
790
  }
810
- Handle<Object> result = Factory::NewSyntaxError(type, array);
811
- Top::Throw(*result, &location);
791
+ Handle<JSArray> array = factory->NewJSArrayWithElements(elements);
792
+ Handle<Object> result = factory->NewSyntaxError(type, array);
793
+ isolate()->Throw(*result, &location);
812
794
  }
813
795
 
814
796
 
@@ -818,12 +800,14 @@ void Parser::ReportMessageAt(Scanner::Location source_location,
818
800
  MessageLocation location(script_,
819
801
  source_location.beg_pos,
820
802
  source_location.end_pos);
821
- Handle<JSArray> array = Factory::NewJSArray(args.length());
803
+ Factory* factory = isolate()->factory();
804
+ Handle<FixedArray> elements = factory->NewFixedArray(args.length());
822
805
  for (int i = 0; i < args.length(); i++) {
823
- SetElement(array, i, args[i]);
806
+ elements->set(i, *args[i]);
824
807
  }
825
- Handle<Object> result = Factory::NewSyntaxError(type, array);
826
- Top::Throw(*result, &location);
808
+ Handle<JSArray> array = factory->NewJSArrayWithElements(elements);
809
+ Handle<Object> result = factory->NewSyntaxError(type, array);
810
+ isolate()->Throw(*result, &location);
827
811
  }
828
812
 
829
813
 
@@ -948,8 +932,9 @@ class InitializationBlockFinder : public ParserFinder {
948
932
  // function contains only assignments of this type.
949
933
  class ThisNamedPropertyAssigmentFinder : public ParserFinder {
950
934
  public:
951
- ThisNamedPropertyAssigmentFinder()
952
- : only_simple_this_property_assignments_(true),
935
+ explicit ThisNamedPropertyAssigmentFinder(Isolate* isolate)
936
+ : isolate_(isolate),
937
+ only_simple_this_property_assignments_(true),
953
938
  names_(NULL),
954
939
  assigned_arguments_(NULL),
955
940
  assigned_constants_(NULL) {}
@@ -980,14 +965,14 @@ class ThisNamedPropertyAssigmentFinder : public ParserFinder {
980
965
  // form this.x = y;
981
966
  Handle<FixedArray> GetThisPropertyAssignments() {
982
967
  if (names_ == NULL) {
983
- return Factory::empty_fixed_array();
968
+ return isolate_->factory()->empty_fixed_array();
984
969
  }
985
970
  ASSERT(names_ != NULL);
986
971
  ASSERT(assigned_arguments_ != NULL);
987
972
  ASSERT_EQ(names_->length(), assigned_arguments_->length());
988
973
  ASSERT_EQ(names_->length(), assigned_constants_->length());
989
974
  Handle<FixedArray> assignments =
990
- Factory::NewFixedArray(names_->length() * 3);
975
+ isolate_->factory()->NewFixedArray(names_->length() * 3);
991
976
  for (int i = 0; i < names_->length(); i++) {
992
977
  assignments->set(i * 3, *names_->at(i));
993
978
  assignments->set(i * 3 + 1, Smi::FromInt(assigned_arguments_->at(i)));
@@ -1017,7 +1002,8 @@ class ThisNamedPropertyAssigmentFinder : public ParserFinder {
1017
1002
  uint32_t dummy;
1018
1003
  if (literal != NULL &&
1019
1004
  literal->handle()->IsString() &&
1020
- !String::cast(*(literal->handle()))->Equals(Heap::Proto_symbol()) &&
1005
+ !String::cast(*(literal->handle()))->Equals(
1006
+ isolate_->heap()->Proto_symbol()) &&
1021
1007
  !String::cast(*(literal->handle()))->AsArrayIndex(&dummy)) {
1022
1008
  Handle<String> key = Handle<String>::cast(literal->handle());
1023
1009
 
@@ -1051,7 +1037,7 @@ class ThisNamedPropertyAssigmentFinder : public ParserFinder {
1051
1037
  EnsureAllocation();
1052
1038
  names_->Add(name);
1053
1039
  assigned_arguments_->Add(index);
1054
- assigned_constants_->Add(Factory::undefined_value());
1040
+ assigned_constants_->Add(isolate_->factory()->undefined_value());
1055
1041
  }
1056
1042
 
1057
1043
  void AssignmentFromConstant(Handle<String> name, Handle<Object> value) {
@@ -1076,6 +1062,7 @@ class ThisNamedPropertyAssigmentFinder : public ParserFinder {
1076
1062
  }
1077
1063
  }
1078
1064
 
1065
+ Isolate* isolate_;
1079
1066
  bool only_simple_this_property_assignments_;
1080
1067
  ZoneStringList* names_;
1081
1068
  ZoneList<int>* assigned_arguments_;
@@ -1097,7 +1084,7 @@ void* Parser::ParseSourceElements(ZoneList<Statement*>* processor,
1097
1084
 
1098
1085
  ASSERT(processor != NULL);
1099
1086
  InitializationBlockFinder block_finder;
1100
- ThisNamedPropertyAssigmentFinder this_property_assignment_finder;
1087
+ ThisNamedPropertyAssigmentFinder this_property_assignment_finder(isolate());
1101
1088
  bool directive_prologue = true; // Parsing directive prologue.
1102
1089
 
1103
1090
  while (peek() != end_token) {
@@ -1106,7 +1093,20 @@ void* Parser::ParseSourceElements(ZoneList<Statement*>* processor,
1106
1093
  }
1107
1094
 
1108
1095
  Scanner::Location token_loc = scanner().peek_location();
1109
- Statement* stat = ParseStatement(NULL, CHECK_OK);
1096
+
1097
+ Statement* stat;
1098
+ if (peek() == Token::FUNCTION) {
1099
+ // FunctionDeclaration is only allowed in the context of SourceElements
1100
+ // (Ecma 262 5th Edition, clause 14):
1101
+ // SourceElement:
1102
+ // Statement
1103
+ // FunctionDeclaration
1104
+ // Common language extension is to allow function declaration in place
1105
+ // of any statement. This language extension is disabled in strict mode.
1106
+ stat = ParseFunctionDeclaration(CHECK_OK);
1107
+ } else {
1108
+ stat = ParseStatement(NULL, CHECK_OK);
1109
+ }
1110
1110
 
1111
1111
  if (stat == NULL || stat->IsEmpty()) {
1112
1112
  directive_prologue = false; // End of directive prologue.
@@ -1124,11 +1124,11 @@ void* Parser::ParseSourceElements(ZoneList<Statement*>* processor,
1124
1124
  Handle<String> directive = Handle<String>::cast(literal->handle());
1125
1125
 
1126
1126
  // Check "use strict" directive (ES5 14.1).
1127
- if (!temp_scope_->StrictMode() &&
1128
- directive->Equals(Heap::use_strict()) &&
1127
+ if (!top_scope_->is_strict_mode() &&
1128
+ directive->Equals(isolate()->heap()->use_strict()) &&
1129
1129
  token_loc.end_pos - token_loc.beg_pos ==
1130
- Heap::use_strict()->length() + 2) {
1131
- temp_scope_->EnableStrictMode();
1130
+ isolate()->heap()->use_strict()->length() + 2) {
1131
+ top_scope_->EnableStrictMode();
1132
1132
  // "use strict" is the only directive for now.
1133
1133
  directive_prologue = false;
1134
1134
  }
@@ -1157,7 +1157,7 @@ void* Parser::ParseSourceElements(ZoneList<Statement*>* processor,
1157
1157
  this_property_assignment_finder.only_simple_this_property_assignments()
1158
1158
  && top_scope_->declarations()->length() == 0;
1159
1159
  if (only_simple_this_property_assignments) {
1160
- temp_scope_->SetThisPropertyAssignmentInfo(
1160
+ lexical_scope_->SetThisPropertyAssignmentInfo(
1161
1161
  only_simple_this_property_assignments,
1162
1162
  this_property_assignment_finder.GetThisPropertyAssignments());
1163
1163
  }
@@ -1253,7 +1253,7 @@ Statement* Parser::ParseStatement(ZoneStringList* labels, bool* ok) {
1253
1253
  // one must take great care not to treat it as a
1254
1254
  // fall-through. It is much easier just to wrap the entire
1255
1255
  // try-statement in a statement block and put the labels there
1256
- Block* result = new Block(labels, 1, false);
1256
+ Block* result = new(zone()) Block(labels, 1, false);
1257
1257
  Target target(&this->target_stack_, result);
1258
1258
  TryStatement* statement = ParseTryStatement(CHECK_OK);
1259
1259
  if (statement) {
@@ -1263,8 +1263,17 @@ Statement* Parser::ParseStatement(ZoneStringList* labels, bool* ok) {
1263
1263
  return result;
1264
1264
  }
1265
1265
 
1266
- case Token::FUNCTION:
1266
+ case Token::FUNCTION: {
1267
+ // In strict mode, FunctionDeclaration is only allowed in the context
1268
+ // of SourceElements.
1269
+ if (top_scope_->is_strict_mode()) {
1270
+ ReportMessageAt(scanner().peek_location(), "strict_function",
1271
+ Vector<const char*>::empty());
1272
+ *ok = false;
1273
+ return NULL;
1274
+ }
1267
1275
  return ParseFunctionDeclaration(ok);
1276
+ }
1268
1277
 
1269
1278
  case Token::NATIVE:
1270
1279
  return ParseNativeDeclaration(ok);
@@ -1316,9 +1325,9 @@ VariableProxy* Parser::Declare(Handle<String> name,
1316
1325
  var->mode() == Variable::CONST);
1317
1326
  const char* type = (var->mode() == Variable::VAR) ? "var" : "const";
1318
1327
  Handle<String> type_string =
1319
- Factory::NewStringFromUtf8(CStrVector(type), TENURED);
1328
+ isolate()->factory()->NewStringFromUtf8(CStrVector(type), TENURED);
1320
1329
  Expression* expression =
1321
- NewThrowTypeError(Factory::redeclaration_symbol(),
1330
+ NewThrowTypeError(isolate()->factory()->redeclaration_symbol(),
1322
1331
  type_string, name);
1323
1332
  top_scope_->SetIllegalRedeclaration(expression);
1324
1333
  }
@@ -1342,13 +1351,13 @@ VariableProxy* Parser::Declare(Handle<String> name,
1342
1351
  // a performance issue since it may lead to repeated
1343
1352
  // Runtime::DeclareContextSlot() calls.
1344
1353
  VariableProxy* proxy = top_scope_->NewUnresolved(name, inside_with());
1345
- top_scope_->AddDeclaration(new Declaration(proxy, mode, fun));
1354
+ top_scope_->AddDeclaration(new(zone()) Declaration(proxy, mode, fun));
1346
1355
 
1347
1356
  // For global const variables we bind the proxy to a variable.
1348
1357
  if (mode == Variable::CONST && top_scope_->is_global_scope()) {
1349
1358
  ASSERT(resolve); // should be set by all callers
1350
1359
  Variable::Kind kind = Variable::NORMAL;
1351
- var = new Variable(top_scope_, name, Variable::CONST, true, kind);
1360
+ var = new(zone()) Variable(top_scope_, name, Variable::CONST, true, kind);
1352
1361
  }
1353
1362
 
1354
1363
  // If requested and we have a local variable, bind the proxy to the variable
@@ -1424,7 +1433,7 @@ Statement* Parser::ParseNativeDeclaration(bool* ok) {
1424
1433
  Handle<Code> code = Handle<Code>(fun->shared()->code());
1425
1434
  Handle<Code> construct_stub = Handle<Code>(fun->shared()->construct_stub());
1426
1435
  Handle<SharedFunctionInfo> shared =
1427
- Factory::NewSharedFunctionInfo(name, literals, code,
1436
+ isolate()->factory()->NewSharedFunctionInfo(name, literals, code,
1428
1437
  Handle<SerializedScopeInfo>(fun->shared()->scope_info()));
1429
1438
  shared->set_construct_stub(*construct_stub);
1430
1439
 
@@ -1436,10 +1445,11 @@ Statement* Parser::ParseNativeDeclaration(bool* ok) {
1436
1445
  // TODO(1240846): It's weird that native function declarations are
1437
1446
  // introduced dynamically when we meet their declarations, whereas
1438
1447
  // other functions are setup when entering the surrounding scope.
1439
- SharedFunctionInfoLiteral* lit = new SharedFunctionInfoLiteral(shared);
1448
+ SharedFunctionInfoLiteral* lit =
1449
+ new(zone()) SharedFunctionInfoLiteral(shared);
1440
1450
  VariableProxy* var = Declare(name, Variable::VAR, NULL, true, CHECK_OK);
1441
- return new ExpressionStatement(
1442
- new Assignment(Token::INIT_VAR, var, lit, RelocInfo::kNoPosition));
1451
+ return new(zone()) ExpressionStatement(new(zone()) Assignment(
1452
+ Token::INIT_VAR, var, lit, RelocInfo::kNoPosition));
1443
1453
  }
1444
1454
 
1445
1455
 
@@ -1471,7 +1481,7 @@ Block* Parser::ParseBlock(ZoneStringList* labels, bool* ok) {
1471
1481
  // (ECMA-262, 3rd, 12.2)
1472
1482
  //
1473
1483
  // Construct block expecting 16 statements.
1474
- Block* result = new Block(labels, 16, false);
1484
+ Block* result = new(zone()) Block(labels, 16, false);
1475
1485
  Target target(&this->target_stack_, result);
1476
1486
  Expect(Token::LBRACE, CHECK_OK);
1477
1487
  while (peek() != Token::RBRACE) {
@@ -1493,11 +1503,13 @@ Block* Parser::ParseVariableStatement(bool* ok) {
1493
1503
  return result;
1494
1504
  }
1495
1505
 
1496
- static bool IsEvalOrArguments(Handle<String> string) {
1497
- return string.is_identical_to(Factory::eval_symbol()) ||
1498
- string.is_identical_to(Factory::arguments_symbol());
1506
+
1507
+ bool Parser::IsEvalOrArguments(Handle<String> string) {
1508
+ return string.is_identical_to(isolate()->factory()->eval_symbol()) ||
1509
+ string.is_identical_to(isolate()->factory()->arguments_symbol());
1499
1510
  }
1500
1511
 
1512
+
1501
1513
  // If the variable declaration declares exactly one non-const
1502
1514
  // variable, then *var is set to that variable. In all other cases,
1503
1515
  // *var is untouched; in particular, it is the caller's responsibility
@@ -1515,6 +1527,11 @@ Block* Parser::ParseVariableDeclarations(bool accept_IN,
1515
1527
  Consume(Token::VAR);
1516
1528
  } else if (peek() == Token::CONST) {
1517
1529
  Consume(Token::CONST);
1530
+ if (top_scope_->is_strict_mode()) {
1531
+ ReportMessage("strict_const", Vector<const char*>::empty());
1532
+ *ok = false;
1533
+ return NULL;
1534
+ }
1518
1535
  mode = Variable::CONST;
1519
1536
  is_const = true;
1520
1537
  } else {
@@ -1534,7 +1551,7 @@ Block* Parser::ParseVariableDeclarations(bool accept_IN,
1534
1551
  // is inside an initializer block, it is ignored.
1535
1552
  //
1536
1553
  // Create new block with one expected declaration.
1537
- Block* block = new Block(NULL, 1, true);
1554
+ Block* block = new(zone()) Block(NULL, 1, true);
1538
1555
  VariableProxy* last_var = NULL; // the last variable declared
1539
1556
  int nvars = 0; // the number of variables declared
1540
1557
  do {
@@ -1546,7 +1563,7 @@ Block* Parser::ParseVariableDeclarations(bool accept_IN,
1546
1563
  if (fni_ != NULL) fni_->PushVariableName(name);
1547
1564
 
1548
1565
  // Strict mode variables may not be named eval or arguments
1549
- if (temp_scope_->StrictMode() && IsEvalOrArguments(name)) {
1566
+ if (top_scope_->is_strict_mode() && IsEvalOrArguments(name)) {
1550
1567
  ReportMessage("strict_var_name", Vector<const char*>::empty());
1551
1568
  *ok = false;
1552
1569
  return NULL;
@@ -1634,35 +1651,51 @@ Block* Parser::ParseVariableDeclarations(bool accept_IN,
1634
1651
 
1635
1652
  if (top_scope_->is_global_scope()) {
1636
1653
  // Compute the arguments for the runtime call.
1637
- ZoneList<Expression*>* arguments = new ZoneList<Expression*>(2);
1638
- // Be careful not to assign a value to the global variable if
1639
- // we're in a with. The initialization value should not
1640
- // necessarily be stored in the global object in that case,
1641
- // which is why we need to generate a separate assignment node.
1642
- arguments->Add(new Literal(name)); // we have at least 1 parameter
1643
- if (is_const || (value != NULL && !inside_with())) {
1644
- arguments->Add(value);
1645
- value = NULL; // zap the value to avoid the unnecessary assignment
1646
- }
1647
- // Construct the call to Runtime::DeclareGlobal{Variable,Const}Locally
1648
- // and add it to the initialization statement block. Note that
1649
- // this function does different things depending on if we have
1650
- // 1 or 2 parameters.
1654
+ ZoneList<Expression*>* arguments = new ZoneList<Expression*>(3);
1655
+ // We have at least 1 parameter.
1656
+ arguments->Add(new(zone()) Literal(name));
1651
1657
  CallRuntime* initialize;
1658
+
1652
1659
  if (is_const) {
1660
+ arguments->Add(value);
1661
+ value = NULL; // zap the value to avoid the unnecessary assignment
1662
+
1663
+ // Construct the call to Runtime_InitializeConstGlobal
1664
+ // and add it to the initialization statement block.
1665
+ // Note that the function does different things depending on
1666
+ // the number of arguments (1 or 2).
1653
1667
  initialize =
1654
- new CallRuntime(
1655
- Factory::InitializeConstGlobal_symbol(),
1656
- Runtime::FunctionForId(Runtime::kInitializeConstGlobal),
1657
- arguments);
1668
+ new(zone()) CallRuntime(
1669
+ isolate()->factory()->InitializeConstGlobal_symbol(),
1670
+ Runtime::FunctionForId(Runtime::kInitializeConstGlobal),
1671
+ arguments);
1658
1672
  } else {
1673
+ // Add strict mode.
1674
+ // We may want to pass singleton to avoid Literal allocations.
1675
+ arguments->Add(NewNumberLiteral(
1676
+ top_scope_->is_strict_mode() ? kStrictMode : kNonStrictMode));
1677
+
1678
+ // Be careful not to assign a value to the global variable if
1679
+ // we're in a with. The initialization value should not
1680
+ // necessarily be stored in the global object in that case,
1681
+ // which is why we need to generate a separate assignment node.
1682
+ if (value != NULL && !inside_with()) {
1683
+ arguments->Add(value);
1684
+ value = NULL; // zap the value to avoid the unnecessary assignment
1685
+ }
1686
+
1687
+ // Construct the call to Runtime_InitializeVarGlobal
1688
+ // and add it to the initialization statement block.
1689
+ // Note that the function does different things depending on
1690
+ // the number of arguments (2 or 3).
1659
1691
  initialize =
1660
- new CallRuntime(
1661
- Factory::InitializeVarGlobal_symbol(),
1662
- Runtime::FunctionForId(Runtime::kInitializeVarGlobal),
1663
- arguments);
1692
+ new(zone()) CallRuntime(
1693
+ isolate()->factory()->InitializeVarGlobal_symbol(),
1694
+ Runtime::FunctionForId(Runtime::kInitializeVarGlobal),
1695
+ arguments);
1664
1696
  }
1665
- block->AddStatement(new ExpressionStatement(initialize));
1697
+
1698
+ block->AddStatement(new(zone()) ExpressionStatement(initialize));
1666
1699
  }
1667
1700
 
1668
1701
  // Add an assignment node to the initialization statement block if
@@ -1677,8 +1710,11 @@ Block* Parser::ParseVariableDeclarations(bool accept_IN,
1677
1710
  // the top context for variables). Sigh...
1678
1711
  if (value != NULL) {
1679
1712
  Token::Value op = (is_const ? Token::INIT_CONST : Token::INIT_VAR);
1680
- Assignment* assignment = new Assignment(op, last_var, value, position);
1681
- if (block) block->AddStatement(new ExpressionStatement(assignment));
1713
+ Assignment* assignment =
1714
+ new(zone()) Assignment(op, last_var, value, position);
1715
+ if (block) {
1716
+ block->AddStatement(new(zone()) ExpressionStatement(assignment));
1717
+ }
1682
1718
  }
1683
1719
 
1684
1720
  if (fni_ != NULL) fni_->Leave();
@@ -1744,7 +1780,7 @@ Statement* Parser::ParseExpressionOrLabelledStatement(ZoneStringList* labels,
1744
1780
 
1745
1781
  // Parsed expression statement.
1746
1782
  ExpectSemicolon(CHECK_OK);
1747
- return new ExpressionStatement(expr);
1783
+ return new(zone()) ExpressionStatement(expr);
1748
1784
  }
1749
1785
 
1750
1786
 
@@ -1764,7 +1800,7 @@ IfStatement* Parser::ParseIfStatement(ZoneStringList* labels, bool* ok) {
1764
1800
  } else {
1765
1801
  else_statement = EmptyStatement();
1766
1802
  }
1767
- return new IfStatement(condition, then_statement, else_statement);
1803
+ return new(zone()) IfStatement(condition, then_statement, else_statement);
1768
1804
  }
1769
1805
 
1770
1806
 
@@ -1794,7 +1830,7 @@ Statement* Parser::ParseContinueStatement(bool* ok) {
1794
1830
  return NULL;
1795
1831
  }
1796
1832
  ExpectSemicolon(CHECK_OK);
1797
- return new ContinueStatement(target);
1833
+ return new(zone()) ContinueStatement(target);
1798
1834
  }
1799
1835
 
1800
1836
 
@@ -1829,7 +1865,7 @@ Statement* Parser::ParseBreakStatement(ZoneStringList* labels, bool* ok) {
1829
1865
  return NULL;
1830
1866
  }
1831
1867
  ExpectSemicolon(CHECK_OK);
1832
- return new BreakStatement(target);
1868
+ return new(zone()) BreakStatement(target);
1833
1869
  }
1834
1870
 
1835
1871
 
@@ -1848,9 +1884,9 @@ Statement* Parser::ParseReturnStatement(bool* ok) {
1848
1884
  //
1849
1885
  // To be consistent with KJS we report the syntax error at runtime.
1850
1886
  if (!top_scope_->is_function_scope()) {
1851
- Handle<String> type = Factory::illegal_return_symbol();
1887
+ Handle<String> type = isolate()->factory()->illegal_return_symbol();
1852
1888
  Expression* throw_error = NewThrowSyntaxError(type, Handle<Object>::null());
1853
- return new ExpressionStatement(throw_error);
1889
+ return new(zone()) ExpressionStatement(throw_error);
1854
1890
  }
1855
1891
 
1856
1892
  Token::Value tok = peek();
@@ -1859,12 +1895,12 @@ Statement* Parser::ParseReturnStatement(bool* ok) {
1859
1895
  tok == Token::RBRACE ||
1860
1896
  tok == Token::EOS) {
1861
1897
  ExpectSemicolon(CHECK_OK);
1862
- return new ReturnStatement(GetLiteralUndefined());
1898
+ return new(zone()) ReturnStatement(GetLiteralUndefined());
1863
1899
  }
1864
1900
 
1865
1901
  Expression* expr = ParseExpression(true, CHECK_OK);
1866
1902
  ExpectSemicolon(CHECK_OK);
1867
- return new ReturnStatement(expr);
1903
+ return new(zone()) ReturnStatement(expr);
1868
1904
  }
1869
1905
 
1870
1906
 
@@ -1885,21 +1921,21 @@ Block* Parser::WithHelper(Expression* obj,
1885
1921
  // Create resulting block with two statements.
1886
1922
  // 1: Evaluate the with expression.
1887
1923
  // 2: The try-finally block evaluating the body.
1888
- Block* result = new Block(NULL, 2, false);
1924
+ Block* result = new(zone()) Block(NULL, 2, false);
1889
1925
 
1890
1926
  if (result != NULL) {
1891
- result->AddStatement(new WithEnterStatement(obj, is_catch_block));
1927
+ result->AddStatement(new(zone()) WithEnterStatement(obj, is_catch_block));
1892
1928
 
1893
1929
  // Create body block.
1894
- Block* body = new Block(NULL, 1, false);
1930
+ Block* body = new(zone()) Block(NULL, 1, false);
1895
1931
  body->AddStatement(stat);
1896
1932
 
1897
1933
  // Create exit block.
1898
- Block* exit = new Block(NULL, 1, false);
1899
- exit->AddStatement(new WithExitStatement());
1934
+ Block* exit = new(zone()) Block(NULL, 1, false);
1935
+ exit->AddStatement(new(zone()) WithExitStatement());
1900
1936
 
1901
1937
  // Return a try-finally statement.
1902
- TryFinallyStatement* wrapper = new TryFinallyStatement(body, exit);
1938
+ TryFinallyStatement* wrapper = new(zone()) TryFinallyStatement(body, exit);
1903
1939
  wrapper->set_escaping_targets(collector.targets());
1904
1940
  result->AddStatement(wrapper);
1905
1941
  }
@@ -1913,7 +1949,7 @@ Statement* Parser::ParseWithStatement(ZoneStringList* labels, bool* ok) {
1913
1949
 
1914
1950
  Expect(Token::WITH, CHECK_OK);
1915
1951
 
1916
- if (temp_scope_->StrictMode()) {
1952
+ if (top_scope_->is_strict_mode()) {
1917
1953
  ReportMessage("strict_mode_with", Vector<const char*>::empty());
1918
1954
  *ok = false;
1919
1955
  return NULL;
@@ -1956,7 +1992,7 @@ CaseClause* Parser::ParseCaseClause(bool* default_seen_ptr, bool* ok) {
1956
1992
  statements->Add(stat);
1957
1993
  }
1958
1994
 
1959
- return new CaseClause(label, statements, pos);
1995
+ return new(zone()) CaseClause(label, statements, pos);
1960
1996
  }
1961
1997
 
1962
1998
 
@@ -1965,7 +2001,7 @@ SwitchStatement* Parser::ParseSwitchStatement(ZoneStringList* labels,
1965
2001
  // SwitchStatement ::
1966
2002
  // 'switch' '(' Expression ')' '{' CaseClause* '}'
1967
2003
 
1968
- SwitchStatement* statement = new SwitchStatement(labels);
2004
+ SwitchStatement* statement = new(zone()) SwitchStatement(labels);
1969
2005
  Target target(&this->target_stack_, statement);
1970
2006
 
1971
2007
  Expect(Token::SWITCH, CHECK_OK);
@@ -2001,7 +2037,7 @@ Statement* Parser::ParseThrowStatement(bool* ok) {
2001
2037
  Expression* exception = ParseExpression(true, CHECK_OK);
2002
2038
  ExpectSemicolon(CHECK_OK);
2003
2039
 
2004
- return new ExpressionStatement(new Throw(exception, pos));
2040
+ return new(zone()) ExpressionStatement(new(zone()) Throw(exception, pos));
2005
2041
  }
2006
2042
 
2007
2043
 
@@ -2052,7 +2088,7 @@ TryStatement* Parser::ParseTryStatement(bool* ok) {
2052
2088
  Expect(Token::LPAREN, CHECK_OK);
2053
2089
  Handle<String> name = ParseIdentifier(CHECK_OK);
2054
2090
 
2055
- if (temp_scope_->StrictMode() && IsEvalOrArguments(name)) {
2091
+ if (top_scope_->is_strict_mode() && IsEvalOrArguments(name)) {
2056
2092
  ReportMessage("strict_catch_variable", Vector<const char*>::empty());
2057
2093
  *ok = false;
2058
2094
  return NULL;
@@ -2063,10 +2099,12 @@ TryStatement* Parser::ParseTryStatement(bool* ok) {
2063
2099
  if (peek() == Token::LBRACE) {
2064
2100
  // Allocate a temporary for holding the finally state while
2065
2101
  // executing the finally block.
2066
- catch_var = top_scope_->NewTemporary(Factory::catch_var_symbol());
2067
- Literal* name_literal = new Literal(name);
2068
- VariableProxy* catch_var_use = new VariableProxy(catch_var);
2069
- Expression* obj = new CatchExtensionObject(name_literal, catch_var_use);
2102
+ catch_var =
2103
+ top_scope_->NewTemporary(isolate()->factory()->catch_var_symbol());
2104
+ Literal* name_literal = new(zone()) Literal(name);
2105
+ VariableProxy* catch_var_use = new(zone()) VariableProxy(catch_var);
2106
+ Expression* obj =
2107
+ new(zone()) CatchExtensionObject(name_literal, catch_var_use);
2070
2108
  { Target target(&this->target_stack_, &catch_collector);
2071
2109
  catch_block = WithHelper(obj, NULL, true, CHECK_OK);
2072
2110
  }
@@ -2090,11 +2128,11 @@ TryStatement* Parser::ParseTryStatement(bool* ok) {
2090
2128
  // 'try { try { } catch { } } finally { }'
2091
2129
 
2092
2130
  if (catch_block != NULL && finally_block != NULL) {
2093
- VariableProxy* catch_var_defn = new VariableProxy(catch_var);
2131
+ VariableProxy* catch_var_defn = new(zone()) VariableProxy(catch_var);
2094
2132
  TryCatchStatement* statement =
2095
- new TryCatchStatement(try_block, catch_var_defn, catch_block);
2133
+ new(zone()) TryCatchStatement(try_block, catch_var_defn, catch_block);
2096
2134
  statement->set_escaping_targets(collector.targets());
2097
- try_block = new Block(NULL, 1, false);
2135
+ try_block = new(zone()) Block(NULL, 1, false);
2098
2136
  try_block->AddStatement(statement);
2099
2137
  catch_block = NULL;
2100
2138
  }
@@ -2102,12 +2140,13 @@ TryStatement* Parser::ParseTryStatement(bool* ok) {
2102
2140
  TryStatement* result = NULL;
2103
2141
  if (catch_block != NULL) {
2104
2142
  ASSERT(finally_block == NULL);
2105
- VariableProxy* catch_var_defn = new VariableProxy(catch_var);
2106
- result = new TryCatchStatement(try_block, catch_var_defn, catch_block);
2143
+ VariableProxy* catch_var_defn = new(zone()) VariableProxy(catch_var);
2144
+ result =
2145
+ new(zone()) TryCatchStatement(try_block, catch_var_defn, catch_block);
2107
2146
  result->set_escaping_targets(collector.targets());
2108
2147
  } else {
2109
2148
  ASSERT(finally_block != NULL);
2110
- result = new TryFinallyStatement(try_block, finally_block);
2149
+ result = new(zone()) TryFinallyStatement(try_block, finally_block);
2111
2150
  // Add the jump targets of the try block and the catch block.
2112
2151
  for (int i = 0; i < collector.targets()->length(); i++) {
2113
2152
  catch_collector.AddTarget(collector.targets()->at(i));
@@ -2124,8 +2163,8 @@ DoWhileStatement* Parser::ParseDoWhileStatement(ZoneStringList* labels,
2124
2163
  // DoStatement ::
2125
2164
  // 'do' Statement 'while' '(' Expression ')' ';'
2126
2165
 
2127
- temp_scope_->AddLoop();
2128
- DoWhileStatement* loop = new DoWhileStatement(labels);
2166
+ lexical_scope_->AddLoop();
2167
+ DoWhileStatement* loop = new(zone()) DoWhileStatement(labels);
2129
2168
  Target target(&this->target_stack_, loop);
2130
2169
 
2131
2170
  Expect(Token::DO, CHECK_OK);
@@ -2157,8 +2196,8 @@ WhileStatement* Parser::ParseWhileStatement(ZoneStringList* labels, bool* ok) {
2157
2196
  // WhileStatement ::
2158
2197
  // 'while' '(' Expression ')' Statement
2159
2198
 
2160
- temp_scope_->AddLoop();
2161
- WhileStatement* loop = new WhileStatement(labels);
2199
+ lexical_scope_->AddLoop();
2200
+ WhileStatement* loop = new(zone()) WhileStatement(labels);
2162
2201
  Target target(&this->target_stack_, loop);
2163
2202
 
2164
2203
  Expect(Token::WHILE, CHECK_OK);
@@ -2177,7 +2216,7 @@ Statement* Parser::ParseForStatement(ZoneStringList* labels, bool* ok) {
2177
2216
  // ForStatement ::
2178
2217
  // 'for' '(' Expression? ';' Expression? ';' Expression? ')' Statement
2179
2218
 
2180
- temp_scope_->AddLoop();
2219
+ lexical_scope_->AddLoop();
2181
2220
  Statement* init = NULL;
2182
2221
 
2183
2222
  Expect(Token::FOR, CHECK_OK);
@@ -2188,7 +2227,7 @@ Statement* Parser::ParseForStatement(ZoneStringList* labels, bool* ok) {
2188
2227
  Block* variable_statement =
2189
2228
  ParseVariableDeclarations(false, &each, CHECK_OK);
2190
2229
  if (peek() == Token::IN && each != NULL) {
2191
- ForInStatement* loop = new ForInStatement(labels);
2230
+ ForInStatement* loop = new(zone()) ForInStatement(labels);
2192
2231
  Target target(&this->target_stack_, loop);
2193
2232
 
2194
2233
  Expect(Token::IN, CHECK_OK);
@@ -2197,7 +2236,7 @@ Statement* Parser::ParseForStatement(ZoneStringList* labels, bool* ok) {
2197
2236
 
2198
2237
  Statement* body = ParseStatement(NULL, CHECK_OK);
2199
2238
  loop->Initialize(each, enumerable, body);
2200
- Block* result = new Block(NULL, 2, false);
2239
+ Block* result = new(zone()) Block(NULL, 2, false);
2201
2240
  result->AddStatement(variable_statement);
2202
2241
  result->AddStatement(loop);
2203
2242
  // Parsed for-in loop w/ variable/const declaration.
@@ -2214,10 +2253,11 @@ Statement* Parser::ParseForStatement(ZoneStringList* labels, bool* ok) {
2214
2253
  // error here but for compatibility with JSC we choose to report
2215
2254
  // the error at runtime.
2216
2255
  if (expression == NULL || !expression->IsValidLeftHandSide()) {
2217
- Handle<String> type = Factory::invalid_lhs_in_for_in_symbol();
2256
+ Handle<String> type =
2257
+ isolate()->factory()->invalid_lhs_in_for_in_symbol();
2218
2258
  expression = NewThrowReferenceError(type);
2219
2259
  }
2220
- ForInStatement* loop = new ForInStatement(labels);
2260
+ ForInStatement* loop = new(zone()) ForInStatement(labels);
2221
2261
  Target target(&this->target_stack_, loop);
2222
2262
 
2223
2263
  Expect(Token::IN, CHECK_OK);
@@ -2230,13 +2270,13 @@ Statement* Parser::ParseForStatement(ZoneStringList* labels, bool* ok) {
2230
2270
  return loop;
2231
2271
 
2232
2272
  } else {
2233
- init = new ExpressionStatement(expression);
2273
+ init = new(zone()) ExpressionStatement(expression);
2234
2274
  }
2235
2275
  }
2236
2276
  }
2237
2277
 
2238
2278
  // Standard 'for' loop
2239
- ForStatement* loop = new ForStatement(labels);
2279
+ ForStatement* loop = new(zone()) ForStatement(labels);
2240
2280
  Target target(&this->target_stack_, loop);
2241
2281
 
2242
2282
  // Parsed initializer at this point.
@@ -2252,7 +2292,7 @@ Statement* Parser::ParseForStatement(ZoneStringList* labels, bool* ok) {
2252
2292
  Statement* next = NULL;
2253
2293
  if (peek() != Token::RPAREN) {
2254
2294
  Expression* exp = ParseExpression(true, CHECK_OK);
2255
- next = new ExpressionStatement(exp);
2295
+ next = new(zone()) ExpressionStatement(exp);
2256
2296
  }
2257
2297
  Expect(Token::RPAREN, CHECK_OK);
2258
2298
 
@@ -2273,7 +2313,7 @@ Expression* Parser::ParseExpression(bool accept_IN, bool* ok) {
2273
2313
  Expect(Token::COMMA, CHECK_OK);
2274
2314
  int position = scanner().location().beg_pos;
2275
2315
  Expression* right = ParseAssignmentExpression(accept_IN, CHECK_OK);
2276
- result = new BinaryOperation(Token::COMMA, result, right, position);
2316
+ result = new(zone()) BinaryOperation(Token::COMMA, result, right, position);
2277
2317
  }
2278
2318
  return result;
2279
2319
  }
@@ -2299,11 +2339,12 @@ Expression* Parser::ParseAssignmentExpression(bool accept_IN, bool* ok) {
2299
2339
  // for compatibility with JSC we choose to report the error at
2300
2340
  // runtime.
2301
2341
  if (expression == NULL || !expression->IsValidLeftHandSide()) {
2302
- Handle<String> type = Factory::invalid_lhs_in_assignment_symbol();
2342
+ Handle<String> type =
2343
+ isolate()->factory()->invalid_lhs_in_assignment_symbol();
2303
2344
  expression = NewThrowReferenceError(type);
2304
2345
  }
2305
2346
 
2306
- if (temp_scope_->StrictMode()) {
2347
+ if (top_scope_->is_strict_mode()) {
2307
2348
  // Assignment to eval or arguments is disallowed in strict mode.
2308
2349
  CheckStrictModeLValue(expression, "strict_lhs_assignment", CHECK_OK);
2309
2350
  }
@@ -2322,7 +2363,7 @@ Expression* Parser::ParseAssignmentExpression(bool accept_IN, bool* ok) {
2322
2363
  property != NULL &&
2323
2364
  property->obj()->AsVariableProxy() != NULL &&
2324
2365
  property->obj()->AsVariableProxy()->is_this()) {
2325
- temp_scope_->AddProperty();
2366
+ lexical_scope_->AddProperty();
2326
2367
  }
2327
2368
 
2328
2369
  // If we assign a function literal to a property we pretenure the
@@ -2344,7 +2385,7 @@ Expression* Parser::ParseAssignmentExpression(bool accept_IN, bool* ok) {
2344
2385
  fni_->Leave();
2345
2386
  }
2346
2387
 
2347
- return new Assignment(op, expression, right, pos);
2388
+ return new(zone()) Assignment(op, expression, right, pos);
2348
2389
  }
2349
2390
 
2350
2391
 
@@ -2366,7 +2407,7 @@ Expression* Parser::ParseConditionalExpression(bool accept_IN, bool* ok) {
2366
2407
  Expect(Token::COLON, CHECK_OK);
2367
2408
  int right_position = scanner().peek_location().beg_pos;
2368
2409
  Expression* right = ParseAssignmentExpression(accept_IN, CHECK_OK);
2369
- return new Conditional(expression, left, right,
2410
+ return new(zone()) Conditional(expression, left, right,
2370
2411
  left_position, right_position);
2371
2412
  }
2372
2413
 
@@ -2454,12 +2495,12 @@ Expression* Parser::ParseBinaryExpression(int prec, bool accept_IN, bool* ok) {
2454
2495
  x = NewCompareNode(cmp, x, y, position);
2455
2496
  if (cmp != op) {
2456
2497
  // The comparison was negated - add a NOT.
2457
- x = new UnaryOperation(Token::NOT, x);
2498
+ x = new(zone()) UnaryOperation(Token::NOT, x);
2458
2499
  }
2459
2500
 
2460
2501
  } else {
2461
2502
  // We have a "normal" binary operation.
2462
- x = new BinaryOperation(op, x, y, position);
2503
+ x = new(zone()) BinaryOperation(op, x, y, position);
2463
2504
  }
2464
2505
  }
2465
2506
  }
@@ -2476,15 +2517,15 @@ Expression* Parser::NewCompareNode(Token::Value op,
2476
2517
  bool is_strict = (op == Token::EQ_STRICT);
2477
2518
  Literal* x_literal = x->AsLiteral();
2478
2519
  if (x_literal != NULL && x_literal->IsNull()) {
2479
- return new CompareToNull(is_strict, y);
2520
+ return new(zone()) CompareToNull(is_strict, y);
2480
2521
  }
2481
2522
 
2482
2523
  Literal* y_literal = y->AsLiteral();
2483
2524
  if (y_literal != NULL && y_literal->IsNull()) {
2484
- return new CompareToNull(is_strict, x);
2525
+ return new(zone()) CompareToNull(is_strict, x);
2485
2526
  }
2486
2527
  }
2487
- return new CompareOperation(op, x, y, position);
2528
+ return new(zone()) CompareOperation(op, x, y, position);
2488
2529
  }
2489
2530
 
2490
2531
 
@@ -2522,7 +2563,7 @@ Expression* Parser::ParseUnaryExpression(bool* ok) {
2522
2563
  }
2523
2564
 
2524
2565
  // "delete identifier" is a syntax error in strict mode.
2525
- if (op == Token::DELETE && temp_scope_->StrictMode()) {
2566
+ if (op == Token::DELETE && top_scope_->is_strict_mode()) {
2526
2567
  VariableProxy* operand = expression->AsVariableProxy();
2527
2568
  if (operand != NULL && !operand->is_this()) {
2528
2569
  ReportMessage("strict_delete", Vector<const char*>::empty());
@@ -2531,7 +2572,7 @@ Expression* Parser::ParseUnaryExpression(bool* ok) {
2531
2572
  }
2532
2573
  }
2533
2574
 
2534
- return new UnaryOperation(op, expression);
2575
+ return new(zone()) UnaryOperation(op, expression);
2535
2576
 
2536
2577
  } else if (Token::IsCountOp(op)) {
2537
2578
  op = Next();
@@ -2541,18 +2582,20 @@ Expression* Parser::ParseUnaryExpression(bool* ok) {
2541
2582
  // error here but for compatibility with JSC we choose to report the
2542
2583
  // error at runtime.
2543
2584
  if (expression == NULL || !expression->IsValidLeftHandSide()) {
2544
- Handle<String> type = Factory::invalid_lhs_in_prefix_op_symbol();
2585
+ Handle<String> type =
2586
+ isolate()->factory()->invalid_lhs_in_prefix_op_symbol();
2545
2587
  expression = NewThrowReferenceError(type);
2546
2588
  }
2547
2589
 
2548
- if (temp_scope_->StrictMode()) {
2590
+ if (top_scope_->is_strict_mode()) {
2549
2591
  // Prefix expression operand in strict mode may not be eval or arguments.
2550
2592
  CheckStrictModeLValue(expression, "strict_lhs_prefix", CHECK_OK);
2551
2593
  }
2552
2594
 
2553
2595
  int position = scanner().location().beg_pos;
2554
- IncrementOperation* increment = new IncrementOperation(op, expression);
2555
- return new CountOperation(true /* prefix */, increment, position);
2596
+ IncrementOperation* increment =
2597
+ new(zone()) IncrementOperation(op, expression);
2598
+ return new(zone()) CountOperation(true /* prefix */, increment, position);
2556
2599
 
2557
2600
  } else {
2558
2601
  return ParsePostfixExpression(ok);
@@ -2572,19 +2615,22 @@ Expression* Parser::ParsePostfixExpression(bool* ok) {
2572
2615
  // error here but for compatibility with JSC we choose to report the
2573
2616
  // error at runtime.
2574
2617
  if (expression == NULL || !expression->IsValidLeftHandSide()) {
2575
- Handle<String> type = Factory::invalid_lhs_in_postfix_op_symbol();
2618
+ Handle<String> type =
2619
+ isolate()->factory()->invalid_lhs_in_postfix_op_symbol();
2576
2620
  expression = NewThrowReferenceError(type);
2577
2621
  }
2578
2622
 
2579
- if (temp_scope_->StrictMode()) {
2623
+ if (top_scope_->is_strict_mode()) {
2580
2624
  // Postfix expression operand in strict mode may not be eval or arguments.
2581
2625
  CheckStrictModeLValue(expression, "strict_lhs_prefix", CHECK_OK);
2582
2626
  }
2583
2627
 
2584
2628
  Token::Value next = Next();
2585
2629
  int position = scanner().location().beg_pos;
2586
- IncrementOperation* increment = new IncrementOperation(next, expression);
2587
- expression = new CountOperation(false /* postfix */, increment, position);
2630
+ IncrementOperation* increment =
2631
+ new(zone()) IncrementOperation(next, expression);
2632
+ expression =
2633
+ new(zone()) CountOperation(false /* postfix */, increment, position);
2588
2634
  }
2589
2635
  return expression;
2590
2636
  }
@@ -2607,7 +2653,7 @@ Expression* Parser::ParseLeftHandSideExpression(bool* ok) {
2607
2653
  Consume(Token::LBRACK);
2608
2654
  int pos = scanner().location().beg_pos;
2609
2655
  Expression* index = ParseExpression(true, CHECK_OK);
2610
- result = new Property(result, index, pos);
2656
+ result = new(zone()) Property(result, index, pos);
2611
2657
  Expect(Token::RBRACK, CHECK_OK);
2612
2658
  break;
2613
2659
  }
@@ -2629,7 +2675,8 @@ Expression* Parser::ParseLeftHandSideExpression(bool* ok) {
2629
2675
  // is called without a receiver and it refers to the original eval
2630
2676
  // function.
2631
2677
  VariableProxy* callee = result->AsVariableProxy();
2632
- if (callee != NULL && callee->IsVariable(Factory::eval_symbol())) {
2678
+ if (callee != NULL &&
2679
+ callee->IsVariable(isolate()->factory()->eval_symbol())) {
2633
2680
  Handle<String> name = callee->name();
2634
2681
  Variable* var = top_scope_->Lookup(name);
2635
2682
  if (var == NULL) {
@@ -2644,7 +2691,7 @@ Expression* Parser::ParseLeftHandSideExpression(bool* ok) {
2644
2691
  Consume(Token::PERIOD);
2645
2692
  int pos = scanner().location().beg_pos;
2646
2693
  Handle<String> name = ParseIdentifierName(CHECK_OK);
2647
- result = new Property(result, new Literal(name), pos);
2694
+ result = new(zone()) Property(result, new(zone()) Literal(name), pos);
2648
2695
  if (fni_ != NULL) fni_->PushLiteralName(name);
2649
2696
  break;
2650
2697
  }
@@ -2680,7 +2727,7 @@ Expression* Parser::ParseNewPrefix(PositionStack* stack, bool* ok) {
2680
2727
 
2681
2728
  if (!stack->is_empty()) {
2682
2729
  int last = stack->pop();
2683
- result = new CallNew(result, new ZoneList<Expression*>(0), last);
2730
+ result = new(zone()) CallNew(result, new ZoneList<Expression*>(0), last);
2684
2731
  }
2685
2732
  return result;
2686
2733
  }
@@ -2725,7 +2772,7 @@ Expression* Parser::ParseMemberWithNewPrefixesExpression(PositionStack* stack,
2725
2772
  Consume(Token::LBRACK);
2726
2773
  int pos = scanner().location().beg_pos;
2727
2774
  Expression* index = ParseExpression(true, CHECK_OK);
2728
- result = new Property(result, index, pos);
2775
+ result = new(zone()) Property(result, index, pos);
2729
2776
  Expect(Token::RBRACK, CHECK_OK);
2730
2777
  break;
2731
2778
  }
@@ -2733,7 +2780,7 @@ Expression* Parser::ParseMemberWithNewPrefixesExpression(PositionStack* stack,
2733
2780
  Consume(Token::PERIOD);
2734
2781
  int pos = scanner().location().beg_pos;
2735
2782
  Handle<String> name = ParseIdentifierName(CHECK_OK);
2736
- result = new Property(result, new Literal(name), pos);
2783
+ result = new(zone()) Property(result, new(zone()) Literal(name), pos);
2737
2784
  if (fni_ != NULL) fni_->PushLiteralName(name);
2738
2785
  break;
2739
2786
  }
@@ -2761,7 +2808,7 @@ DebuggerStatement* Parser::ParseDebuggerStatement(bool* ok) {
2761
2808
 
2762
2809
  Expect(Token::DEBUGGER, CHECK_OK);
2763
2810
  ExpectSemicolon(CHECK_OK);
2764
- return new DebuggerStatement();
2811
+ return new(zone()) DebuggerStatement();
2765
2812
  }
2766
2813
 
2767
2814
 
@@ -2784,7 +2831,7 @@ void Parser::ReportUnexpectedToken(Token::Value token) {
2784
2831
  return ReportMessage("unexpected_token_identifier",
2785
2832
  Vector<const char*>::empty());
2786
2833
  case Token::FUTURE_RESERVED_WORD:
2787
- return ReportMessage(temp_scope_->StrictMode() ?
2834
+ return ReportMessage(top_scope_->is_strict_mode() ?
2788
2835
  "unexpected_strict_reserved" :
2789
2836
  "unexpected_token_identifier",
2790
2837
  Vector<const char*>::empty());
@@ -2830,24 +2877,26 @@ Expression* Parser::ParsePrimaryExpression(bool* ok) {
2830
2877
 
2831
2878
  case Token::NULL_LITERAL:
2832
2879
  Consume(Token::NULL_LITERAL);
2833
- result = new Literal(Factory::null_value());
2880
+ result = new(zone()) Literal(isolate()->factory()->null_value());
2834
2881
  break;
2835
2882
 
2836
2883
  case Token::TRUE_LITERAL:
2837
2884
  Consume(Token::TRUE_LITERAL);
2838
- result = new Literal(Factory::true_value());
2885
+ result = new(zone()) Literal(isolate()->factory()->true_value());
2839
2886
  break;
2840
2887
 
2841
2888
  case Token::FALSE_LITERAL:
2842
2889
  Consume(Token::FALSE_LITERAL);
2843
- result = new Literal(Factory::false_value());
2890
+ result = new(zone()) Literal(isolate()->factory()->false_value());
2844
2891
  break;
2845
2892
 
2846
2893
  case Token::IDENTIFIER:
2847
2894
  case Token::FUTURE_RESERVED_WORD: {
2848
2895
  Handle<String> name = ParseIdentifier(CHECK_OK);
2849
2896
  if (fni_ != NULL) fni_->PushVariableName(name);
2850
- result = top_scope_->NewUnresolved(name, inside_with());
2897
+ result = top_scope_->NewUnresolved(name,
2898
+ inside_with(),
2899
+ scanner().location().beg_pos);
2851
2900
  break;
2852
2901
  }
2853
2902
 
@@ -2863,7 +2912,7 @@ Expression* Parser::ParsePrimaryExpression(bool* ok) {
2863
2912
  case Token::STRING: {
2864
2913
  Consume(Token::STRING);
2865
2914
  Handle<String> symbol = GetSymbol(CHECK_OK);
2866
- result = new Literal(symbol);
2915
+ result = new(zone()) Literal(symbol);
2867
2916
  if (fni_ != NULL) fni_->PushLiteralName(symbol);
2868
2917
  break;
2869
2918
  }
@@ -2961,11 +3010,11 @@ Expression* Parser::ParseArrayLiteral(bool* ok) {
2961
3010
  Expect(Token::RBRACK, CHECK_OK);
2962
3011
 
2963
3012
  // Update the scope information before the pre-parsing bailout.
2964
- int literal_index = temp_scope_->NextMaterializedLiteralIndex();
3013
+ int literal_index = lexical_scope_->NextMaterializedLiteralIndex();
2965
3014
 
2966
3015
  // Allocate a fixed array with all the literals.
2967
3016
  Handle<FixedArray> literals =
2968
- Factory::NewFixedArray(values->length(), TENURED);
3017
+ isolate()->factory()->NewFixedArray(values->length(), TENURED);
2969
3018
 
2970
3019
  // Fill in the literals.
2971
3020
  bool is_simple = true;
@@ -2987,10 +3036,10 @@ Expression* Parser::ParseArrayLiteral(bool* ok) {
2987
3036
  // Simple and shallow arrays can be lazily copied, we transform the
2988
3037
  // elements array to a copy-on-write array.
2989
3038
  if (is_simple && depth == 1 && values->length() > 0) {
2990
- literals->set_map(Heap::fixed_cow_array_map());
3039
+ literals->set_map(isolate()->heap()->fixed_cow_array_map());
2991
3040
  }
2992
3041
 
2993
- return new ArrayLiteral(literals, values,
3042
+ return new(zone()) ArrayLiteral(literals, values,
2994
3043
  literal_index, is_simple, depth);
2995
3044
  }
2996
3045
 
@@ -3022,7 +3071,7 @@ bool CompileTimeValue::ArrayLiteralElementNeedsInitialization(
3022
3071
 
3023
3072
  Handle<FixedArray> CompileTimeValue::GetValue(Expression* expression) {
3024
3073
  ASSERT(IsCompileTimeValue(expression));
3025
- Handle<FixedArray> result = Factory::NewFixedArray(2, TENURED);
3074
+ Handle<FixedArray> result = FACTORY->NewFixedArray(2, TENURED);
3026
3075
  ObjectLiteral* object_literal = expression->AsObjectLiteral();
3027
3076
  if (object_literal != NULL) {
3028
3077
  ASSERT(object_literal->is_simple());
@@ -3060,7 +3109,7 @@ Handle<Object> Parser::GetBoilerplateValue(Expression* expression) {
3060
3109
  if (CompileTimeValue::IsCompileTimeValue(expression)) {
3061
3110
  return CompileTimeValue::GetValue(expression);
3062
3111
  }
3063
- return Factory::undefined_value();
3112
+ return isolate()->factory()->undefined_value();
3064
3113
  }
3065
3114
 
3066
3115
  // Defined in ast.cc
@@ -3126,7 +3175,7 @@ void ObjectLiteralPropertyChecker::CheckProperty(
3126
3175
  if (handle->IsSymbol()) {
3127
3176
  Handle<String> name(String::cast(*handle));
3128
3177
  if (name->AsArrayIndex(&hash)) {
3129
- Handle<Object> key_handle = Factory::NewNumberFromUint(hash);
3178
+ Handle<Object> key_handle = FACTORY->NewNumberFromUint(hash);
3130
3179
  key = key_handle.location();
3131
3180
  map = &elems;
3132
3181
  } else {
@@ -3143,7 +3192,7 @@ void ObjectLiteralPropertyChecker::CheckProperty(
3143
3192
  char arr[100];
3144
3193
  Vector<char> buffer(arr, ARRAY_SIZE(arr));
3145
3194
  const char* str = DoubleToCString(num, buffer);
3146
- Handle<String> name = Factory::NewStringFromAscii(CStrVector(str));
3195
+ Handle<String> name = FACTORY->NewStringFromAscii(CStrVector(str));
3147
3196
  key = name.location();
3148
3197
  hash = name->Hash();
3149
3198
  map = &props;
@@ -3255,7 +3304,7 @@ ObjectLiteral::Property* Parser::ParseObjectLiteralGetSet(bool is_getter,
3255
3304
  next == Token::STRING || is_keyword) {
3256
3305
  Handle<String> name;
3257
3306
  if (is_keyword) {
3258
- name = Factory::LookupAsciiSymbol(Token::String(next));
3307
+ name = isolate_->factory()->LookupAsciiSymbol(Token::String(next));
3259
3308
  } else {
3260
3309
  name = GetSymbol(CHECK_OK);
3261
3310
  }
@@ -3268,7 +3317,7 @@ ObjectLiteral::Property* Parser::ParseObjectLiteralGetSet(bool is_getter,
3268
3317
  // Allow any number of parameters for compatiabilty with JSC.
3269
3318
  // Specification only allows zero parameters for get and one for set.
3270
3319
  ObjectLiteral::Property* property =
3271
- new ObjectLiteral::Property(is_getter, value);
3320
+ new(zone()) ObjectLiteral::Property(is_getter, value);
3272
3321
  return property;
3273
3322
  } else {
3274
3323
  ReportUnexpectedToken(next);
@@ -3288,8 +3337,9 @@ Expression* Parser::ParseObjectLiteral(bool* ok) {
3288
3337
  ZoneList<ObjectLiteral::Property*>* properties =
3289
3338
  new ZoneList<ObjectLiteral::Property*>(4);
3290
3339
  int number_of_boilerplate_properties = 0;
3340
+ bool has_function = false;
3291
3341
 
3292
- ObjectLiteralPropertyChecker checker(this, temp_scope_->StrictMode());
3342
+ ObjectLiteralPropertyChecker checker(this, top_scope_->is_strict_mode());
3293
3343
 
3294
3344
  Expect(Token::LBRACE, CHECK_OK);
3295
3345
  Scanner::Location loc = scanner().location();
@@ -3333,7 +3383,7 @@ Expression* Parser::ParseObjectLiteral(bool* ok) {
3333
3383
  }
3334
3384
  // Failed to parse as get/set property, so it's just a property
3335
3385
  // called "get" or "set".
3336
- key = new Literal(id);
3386
+ key = new(zone()) Literal(id);
3337
3387
  break;
3338
3388
  }
3339
3389
  case Token::STRING: {
@@ -3345,7 +3395,7 @@ Expression* Parser::ParseObjectLiteral(bool* ok) {
3345
3395
  key = NewNumberLiteral(index);
3346
3396
  break;
3347
3397
  }
3348
- key = new Literal(string);
3398
+ key = new(zone()) Literal(string);
3349
3399
  break;
3350
3400
  }
3351
3401
  case Token::NUMBER: {
@@ -3360,7 +3410,7 @@ Expression* Parser::ParseObjectLiteral(bool* ok) {
3360
3410
  if (Token::IsKeyword(next)) {
3361
3411
  Consume(next);
3362
3412
  Handle<String> string = GetSymbol(CHECK_OK);
3363
- key = new Literal(string);
3413
+ key = new(zone()) Literal(string);
3364
3414
  } else {
3365
3415
  // Unexpected token.
3366
3416
  Token::Value next = Next();
@@ -3374,7 +3424,14 @@ Expression* Parser::ParseObjectLiteral(bool* ok) {
3374
3424
  Expression* value = ParseAssignmentExpression(true, CHECK_OK);
3375
3425
 
3376
3426
  ObjectLiteral::Property* property =
3377
- new ObjectLiteral::Property(key, value);
3427
+ new(zone()) ObjectLiteral::Property(key, value);
3428
+
3429
+ // Mark object literals that contain function literals and pretenure the
3430
+ // literal so it can be added as a constant function property.
3431
+ if (value->AsFunctionLiteral() != NULL) {
3432
+ has_function = true;
3433
+ value->AsFunctionLiteral()->set_pretenure(true);
3434
+ }
3378
3435
 
3379
3436
  // Count CONSTANT or COMPUTED properties to maintain the enumeration order.
3380
3437
  if (IsBoilerplateProperty(property)) number_of_boilerplate_properties++;
@@ -3393,10 +3450,10 @@ Expression* Parser::ParseObjectLiteral(bool* ok) {
3393
3450
  Expect(Token::RBRACE, CHECK_OK);
3394
3451
 
3395
3452
  // Computation of literal_index must happen before pre parse bailout.
3396
- int literal_index = temp_scope_->NextMaterializedLiteralIndex();
3453
+ int literal_index = lexical_scope_->NextMaterializedLiteralIndex();
3397
3454
 
3398
- Handle<FixedArray> constant_properties =
3399
- Factory::NewFixedArray(number_of_boilerplate_properties * 2, TENURED);
3455
+ Handle<FixedArray> constant_properties = isolate()->factory()->NewFixedArray(
3456
+ number_of_boilerplate_properties * 2, TENURED);
3400
3457
 
3401
3458
  bool is_simple = true;
3402
3459
  bool fast_elements = true;
@@ -3406,12 +3463,13 @@ Expression* Parser::ParseObjectLiteral(bool* ok) {
3406
3463
  &is_simple,
3407
3464
  &fast_elements,
3408
3465
  &depth);
3409
- return new ObjectLiteral(constant_properties,
3466
+ return new(zone()) ObjectLiteral(constant_properties,
3410
3467
  properties,
3411
3468
  literal_index,
3412
3469
  is_simple,
3413
3470
  fast_elements,
3414
- depth);
3471
+ depth,
3472
+ has_function);
3415
3473
  }
3416
3474
 
3417
3475
 
@@ -3423,14 +3481,14 @@ Expression* Parser::ParseRegExpLiteral(bool seen_equal, bool* ok) {
3423
3481
  return NULL;
3424
3482
  }
3425
3483
 
3426
- int literal_index = temp_scope_->NextMaterializedLiteralIndex();
3484
+ int literal_index = lexical_scope_->NextMaterializedLiteralIndex();
3427
3485
 
3428
3486
  Handle<String> js_pattern = NextLiteralString(TENURED);
3429
3487
  scanner().ScanRegExpFlags();
3430
3488
  Handle<String> js_flags = NextLiteralString(TENURED);
3431
3489
  Next();
3432
3490
 
3433
- return new RegExpLiteral(js_pattern, js_flags, literal_index);
3491
+ return new(zone()) RegExpLiteral(js_pattern, js_flags, literal_index);
3434
3492
  }
3435
3493
 
3436
3494
 
@@ -3465,9 +3523,10 @@ FunctionLiteral* Parser::ParseFunctionLiteral(Handle<String> var_name,
3465
3523
  // this is the actual function name, otherwise this is the name of the
3466
3524
  // variable declared and initialized with the function (expression). In
3467
3525
  // that case, we don't have a function name (it's empty).
3468
- Handle<String> name = is_named ? var_name : Factory::empty_symbol();
3526
+ Handle<String> name =
3527
+ is_named ? var_name : isolate()->factory()->empty_symbol();
3469
3528
  // The function name, if any.
3470
- Handle<String> function_name = Factory::empty_symbol();
3529
+ Handle<String> function_name = isolate()->factory()->empty_symbol();
3471
3530
  if (is_named && (type == EXPRESSION || type == NESTED)) {
3472
3531
  function_name = name;
3473
3532
  }
@@ -3476,9 +3535,7 @@ FunctionLiteral* Parser::ParseFunctionLiteral(Handle<String> var_name,
3476
3535
  // Parse function body.
3477
3536
  { Scope* scope =
3478
3537
  NewScope(top_scope_, Scope::FUNCTION_SCOPE, inside_with());
3479
- LexicalScope lexical_scope(&this->top_scope_, &this->with_nesting_level_,
3480
- scope);
3481
- TemporaryScope temp_scope(&this->temp_scope_);
3538
+ LexicalScope lexical_scope(this, scope, isolate());
3482
3539
  top_scope_->SetScopeName(name);
3483
3540
 
3484
3541
  // FormalParameterList ::
@@ -3534,9 +3591,9 @@ FunctionLiteral* Parser::ParseFunctionLiteral(Handle<String> var_name,
3534
3591
  VariableProxy* fproxy =
3535
3592
  top_scope_->NewUnresolved(function_name, inside_with());
3536
3593
  fproxy->BindTo(fvar);
3537
- body->Add(new ExpressionStatement(
3538
- new Assignment(Token::INIT_CONST, fproxy,
3539
- new ThisFunction(),
3594
+ body->Add(new(zone()) ExpressionStatement(
3595
+ new(zone()) Assignment(Token::INIT_CONST, fproxy,
3596
+ new(zone()) ThisFunction(),
3540
3597
  RelocInfo::kNoPosition)));
3541
3598
  }
3542
3599
 
@@ -3564,29 +3621,30 @@ FunctionLiteral* Parser::ParseFunctionLiteral(Handle<String> var_name,
3564
3621
  // End position greater than end of stream is safe, and hard to check.
3565
3622
  ReportInvalidPreparseData(name, CHECK_OK);
3566
3623
  }
3567
- Counters::total_preparse_skipped.Increment(end_pos - function_block_pos);
3624
+ isolate()->counters()->total_preparse_skipped()->Increment(
3625
+ end_pos - function_block_pos);
3568
3626
  // Seek to position just before terminal '}'.
3569
3627
  scanner().SeekForward(end_pos - 1);
3570
3628
  materialized_literal_count = entry.literal_count();
3571
3629
  expected_property_count = entry.property_count();
3572
3630
  only_simple_this_property_assignments = false;
3573
- this_property_assignments = Factory::empty_fixed_array();
3631
+ this_property_assignments = isolate()->factory()->empty_fixed_array();
3574
3632
  Expect(Token::RBRACE, CHECK_OK);
3575
3633
  } else {
3576
3634
  ParseSourceElements(body, Token::RBRACE, CHECK_OK);
3577
3635
 
3578
- materialized_literal_count = temp_scope.materialized_literal_count();
3579
- expected_property_count = temp_scope.expected_property_count();
3636
+ materialized_literal_count = lexical_scope.materialized_literal_count();
3637
+ expected_property_count = lexical_scope.expected_property_count();
3580
3638
  only_simple_this_property_assignments =
3581
- temp_scope.only_simple_this_property_assignments();
3582
- this_property_assignments = temp_scope.this_property_assignments();
3639
+ lexical_scope.only_simple_this_property_assignments();
3640
+ this_property_assignments = lexical_scope.this_property_assignments();
3583
3641
 
3584
3642
  Expect(Token::RBRACE, CHECK_OK);
3585
3643
  end_pos = scanner().location().end_pos;
3586
3644
  }
3587
3645
 
3588
3646
  // Validate strict mode.
3589
- if (temp_scope_->StrictMode()) {
3647
+ if (top_scope_->is_strict_mode()) {
3590
3648
  if (IsEvalOrArguments(name)) {
3591
3649
  int position = function_token_position != RelocInfo::kNoPosition
3592
3650
  ? function_token_position
@@ -3629,7 +3687,7 @@ FunctionLiteral* Parser::ParseFunctionLiteral(Handle<String> var_name,
3629
3687
  }
3630
3688
 
3631
3689
  FunctionLiteral* function_literal =
3632
- new FunctionLiteral(name,
3690
+ new(zone()) FunctionLiteral(name,
3633
3691
  top_scope_,
3634
3692
  body,
3635
3693
  materialized_literal_count,
@@ -3640,8 +3698,7 @@ FunctionLiteral* Parser::ParseFunctionLiteral(Handle<String> var_name,
3640
3698
  start_pos,
3641
3699
  end_pos,
3642
3700
  function_name->length() > 0,
3643
- temp_scope.ContainsLoops(),
3644
- temp_scope.StrictMode());
3701
+ lexical_scope.ContainsLoops());
3645
3702
  function_literal->set_function_token_position(function_token_position);
3646
3703
 
3647
3704
  if (fni_ != NULL && !is_named) fni_->AddFunction(function_literal);
@@ -3664,7 +3721,7 @@ Expression* Parser::ParseV8Intrinsic(bool* ok) {
3664
3721
  top_scope_->ForceEagerCompilation();
3665
3722
  }
3666
3723
 
3667
- Runtime::Function* function = Runtime::FunctionForSymbol(name);
3724
+ const Runtime::Function* function = Runtime::FunctionForSymbol(name);
3668
3725
 
3669
3726
  // Check for built-in IS_VAR macro.
3670
3727
  if (function != NULL &&
@@ -3692,7 +3749,7 @@ Expression* Parser::ParseV8Intrinsic(bool* ok) {
3692
3749
  }
3693
3750
 
3694
3751
  // We have a valid intrinsics call or a call to a builtin.
3695
- return new CallRuntime(name, function, args);
3752
+ return new(zone()) CallRuntime(name, function, args);
3696
3753
  }
3697
3754
 
3698
3755
 
@@ -3747,12 +3804,12 @@ void Parser::ExpectSemicolon(bool* ok) {
3747
3804
 
3748
3805
 
3749
3806
  Literal* Parser::GetLiteralUndefined() {
3750
- return new Literal(Factory::undefined_value());
3807
+ return new(zone()) Literal(isolate()->factory()->undefined_value());
3751
3808
  }
3752
3809
 
3753
3810
 
3754
3811
  Literal* Parser::GetLiteralTheHole() {
3755
- return new Literal(Factory::the_hole_value());
3812
+ return new(zone()) Literal(isolate()->factory()->the_hole_value());
3756
3813
  }
3757
3814
 
3758
3815
 
@@ -3770,7 +3827,7 @@ Handle<String> Parser::ParseIdentifier(bool* ok) {
3770
3827
  Handle<String> Parser::ParseIdentifierOrReservedWord(bool* is_reserved,
3771
3828
  bool* ok) {
3772
3829
  *is_reserved = false;
3773
- if (temp_scope_->StrictMode()) {
3830
+ if (top_scope_->is_strict_mode()) {
3774
3831
  Expect(Token::IDENTIFIER, ok);
3775
3832
  } else {
3776
3833
  if (!Check(Token::IDENTIFIER)) {
@@ -3801,7 +3858,7 @@ Handle<String> Parser::ParseIdentifierName(bool* ok) {
3801
3858
  void Parser::CheckStrictModeLValue(Expression* expression,
3802
3859
  const char* error,
3803
3860
  bool* ok) {
3804
- ASSERT(temp_scope_->StrictMode());
3861
+ ASSERT(top_scope_->is_strict_mode());
3805
3862
  VariableProxy* lhs = expression != NULL
3806
3863
  ? expression->AsVariableProxy()
3807
3864
  : NULL;
@@ -3900,12 +3957,12 @@ void Parser::RegisterTargetUse(BreakTarget* target, Target* stop) {
3900
3957
 
3901
3958
 
3902
3959
  Literal* Parser::NewNumberLiteral(double number) {
3903
- return new Literal(Factory::NewNumber(number, TENURED));
3960
+ return new(zone()) Literal(isolate()->factory()->NewNumber(number, TENURED));
3904
3961
  }
3905
3962
 
3906
3963
 
3907
3964
  Expression* Parser::NewThrowReferenceError(Handle<String> type) {
3908
- return NewThrowError(Factory::MakeReferenceError_symbol(),
3965
+ return NewThrowError(isolate()->factory()->MakeReferenceError_symbol(),
3909
3966
  type, HandleVector<Object>(NULL, 0));
3910
3967
  }
3911
3968
 
@@ -3914,7 +3971,8 @@ Expression* Parser::NewThrowSyntaxError(Handle<String> type,
3914
3971
  Handle<Object> first) {
3915
3972
  int argc = first.is_null() ? 0 : 1;
3916
3973
  Vector< Handle<Object> > arguments = HandleVector<Object>(&first, argc);
3917
- return NewThrowError(Factory::MakeSyntaxError_symbol(), type, arguments);
3974
+ return NewThrowError(
3975
+ isolate()->factory()->MakeSyntaxError_symbol(), type, arguments);
3918
3976
  }
3919
3977
 
3920
3978
 
@@ -3925,7 +3983,8 @@ Expression* Parser::NewThrowTypeError(Handle<String> type,
3925
3983
  Handle<Object> elements[] = { first, second };
3926
3984
  Vector< Handle<Object> > arguments =
3927
3985
  HandleVector<Object>(elements, ARRAY_SIZE(elements));
3928
- return NewThrowError(Factory::MakeTypeError_symbol(), type, arguments);
3986
+ return NewThrowError(
3987
+ isolate()->factory()->MakeTypeError_symbol(), type, arguments);
3929
3988
  }
3930
3989
 
3931
3990
 
@@ -3933,19 +3992,21 @@ Expression* Parser::NewThrowError(Handle<String> constructor,
3933
3992
  Handle<String> type,
3934
3993
  Vector< Handle<Object> > arguments) {
3935
3994
  int argc = arguments.length();
3936
- Handle<FixedArray> elements = Factory::NewFixedArray(argc, TENURED);
3995
+ Handle<FixedArray> elements = isolate()->factory()->NewFixedArray(argc,
3996
+ TENURED);
3937
3997
  for (int i = 0; i < argc; i++) {
3938
3998
  Handle<Object> element = arguments[i];
3939
3999
  if (!element.is_null()) {
3940
4000
  elements->set(i, *element);
3941
4001
  }
3942
4002
  }
3943
- Handle<JSArray> array = Factory::NewJSArrayWithElements(elements, TENURED);
4003
+ Handle<JSArray> array = isolate()->factory()->NewJSArrayWithElements(elements,
4004
+ TENURED);
3944
4005
 
3945
4006
  ZoneList<Expression*>* args = new ZoneList<Expression*>(2);
3946
- args->Add(new Literal(type));
3947
- args->Add(new Literal(array));
3948
- return new Throw(new CallRuntime(constructor, NULL, args),
4007
+ args->Add(new(zone()) Literal(type));
4008
+ args->Add(new(zone()) Literal(array));
4009
+ return new(zone()) Throw(new(zone()) CallRuntime(constructor, NULL, args),
3949
4010
  scanner().location().beg_pos);
3950
4011
  }
3951
4012
 
@@ -3960,7 +4021,7 @@ Handle<Object> JsonParser::ParseJson(Handle<String> script,
3960
4021
  if (result.is_null() || scanner_.Next() != Token::EOS) {
3961
4022
  if (stack_overflow_) {
3962
4023
  // Scanner failed.
3963
- Top::StackOverflow();
4024
+ isolate()->StackOverflow();
3964
4025
  } else {
3965
4026
  // Parse failed. Scanner's current token is the unexpected token.
3966
4027
  Token::Value token = scanner_.current_token();
@@ -3990,18 +4051,21 @@ Handle<Object> JsonParser::ParseJson(Handle<String> script,
3990
4051
  }
3991
4052
 
3992
4053
  Scanner::Location source_location = scanner_.location();
3993
- MessageLocation location(Factory::NewScript(script),
4054
+ Factory* factory = isolate()->factory();
4055
+ MessageLocation location(factory->NewScript(script),
3994
4056
  source_location.beg_pos,
3995
4057
  source_location.end_pos);
3996
- int argc = (name_opt == NULL) ? 0 : 1;
3997
- Handle<JSArray> array = Factory::NewJSArray(argc);
3998
- if (name_opt != NULL) {
3999
- SetElement(array,
4000
- 0,
4001
- Factory::NewStringFromUtf8(CStrVector(name_opt)));
4058
+ Handle<JSArray> array;
4059
+ if (name_opt == NULL) {
4060
+ array = factory->NewJSArray(0);
4061
+ } else {
4062
+ Handle<String> name = factory->NewStringFromUtf8(CStrVector(name_opt));
4063
+ Handle<FixedArray> element = factory->NewFixedArray(1);
4064
+ element->set(0, *name);
4065
+ array = factory->NewJSArrayWithElements(element);
4002
4066
  }
4003
- Handle<Object> result = Factory::NewSyntaxError(message, array);
4004
- Top::Throw(*result, &location);
4067
+ Handle<Object> result = factory->NewSyntaxError(message, array);
4068
+ isolate()->Throw(*result, &location);
4005
4069
  return Handle<Object>::null();
4006
4070
  }
4007
4071
  }
@@ -4012,12 +4076,14 @@ Handle<Object> JsonParser::ParseJson(Handle<String> script,
4012
4076
  Handle<String> JsonParser::GetString() {
4013
4077
  int literal_length = scanner_.literal_length();
4014
4078
  if (literal_length == 0) {
4015
- return Factory::empty_string();
4079
+ return isolate()->factory()->empty_string();
4016
4080
  }
4017
4081
  if (scanner_.is_literal_ascii()) {
4018
- return Factory::NewStringFromAscii(scanner_.literal_ascii_string());
4082
+ return isolate()->factory()->NewStringFromAscii(
4083
+ scanner_.literal_ascii_string());
4019
4084
  } else {
4020
- return Factory::NewStringFromTwoByte(scanner_.literal_uc16_string());
4085
+ return isolate()->factory()->NewStringFromTwoByte(
4086
+ scanner_.literal_uc16_string());
4021
4087
  }
4022
4088
  }
4023
4089
 
@@ -4029,13 +4095,13 @@ Handle<Object> JsonParser::ParseJsonValue() {
4029
4095
  case Token::STRING:
4030
4096
  return GetString();
4031
4097
  case Token::NUMBER:
4032
- return Factory::NewNumber(scanner_.number());
4098
+ return isolate()->factory()->NewNumber(scanner_.number());
4033
4099
  case Token::FALSE_LITERAL:
4034
- return Factory::false_value();
4100
+ return isolate()->factory()->false_value();
4035
4101
  case Token::TRUE_LITERAL:
4036
- return Factory::true_value();
4102
+ return isolate()->factory()->true_value();
4037
4103
  case Token::NULL_LITERAL:
4038
- return Factory::null_value();
4104
+ return isolate()->factory()->null_value();
4039
4105
  case Token::LBRACE:
4040
4106
  return ParseJsonObject();
4041
4107
  case Token::LBRACK:
@@ -4049,12 +4115,13 @@ Handle<Object> JsonParser::ParseJsonValue() {
4049
4115
  // Parse a JSON object. Scanner must be right after '{' token.
4050
4116
  Handle<Object> JsonParser::ParseJsonObject() {
4051
4117
  Handle<JSFunction> object_constructor(
4052
- Top::global_context()->object_function());
4053
- Handle<JSObject> json_object = Factory::NewJSObject(object_constructor);
4118
+ isolate()->global_context()->object_function());
4119
+ Handle<JSObject> json_object =
4120
+ isolate()->factory()->NewJSObject(object_constructor);
4054
4121
  if (scanner_.peek() == Token::RBRACE) {
4055
4122
  scanner_.Next();
4056
4123
  } else {
4057
- if (StackLimitCheck().HasOverflowed()) {
4124
+ if (StackLimitCheck(isolate()).HasOverflowed()) {
4058
4125
  stack_overflow_ = true;
4059
4126
  return Handle<Object>::null();
4060
4127
  }
@@ -4070,8 +4137,8 @@ Handle<Object> JsonParser::ParseJsonObject() {
4070
4137
  if (value.is_null()) return Handle<Object>::null();
4071
4138
  uint32_t index;
4072
4139
  if (key->AsArrayIndex(&index)) {
4073
- SetOwnElement(json_object, index, value);
4074
- } else if (key->Equals(Heap::Proto_symbol())) {
4140
+ SetOwnElement(json_object, index, value, kNonStrictMode);
4141
+ } else if (key->Equals(isolate()->heap()->Proto_symbol())) {
4075
4142
  // We can't remove the __proto__ accessor since it's hardcoded
4076
4143
  // in several places. Instead go along and add the value as
4077
4144
  // the prototype of the created object if possible.
@@ -4097,7 +4164,7 @@ Handle<Object> JsonParser::ParseJsonArray() {
4097
4164
  if (token == Token::RBRACK) {
4098
4165
  scanner_.Next();
4099
4166
  } else {
4100
- if (StackLimitCheck().HasOverflowed()) {
4167
+ if (StackLimitCheck(isolate()).HasOverflowed()) {
4101
4168
  stack_overflow_ = true;
4102
4169
  return Handle<Object>::null();
4103
4170
  }
@@ -4114,13 +4181,13 @@ Handle<Object> JsonParser::ParseJsonArray() {
4114
4181
 
4115
4182
  // Allocate a fixed array with all the elements.
4116
4183
  Handle<FixedArray> fast_elements =
4117
- Factory::NewFixedArray(elements.length());
4184
+ isolate()->factory()->NewFixedArray(elements.length());
4118
4185
 
4119
4186
  for (int i = 0, n = elements.length(); i < n; i++) {
4120
4187
  fast_elements->set(i, *elements[i]);
4121
4188
  }
4122
4189
 
4123
- return Factory::NewJSArrayWithElements(fast_elements);
4190
+ return isolate()->factory()->NewJSArrayWithElements(fast_elements);
4124
4191
  }
4125
4192
 
4126
4193
  // ----------------------------------------------------------------------------
@@ -4130,18 +4197,19 @@ Handle<Object> JsonParser::ParseJsonArray() {
4130
4197
  RegExpParser::RegExpParser(FlatStringReader* in,
4131
4198
  Handle<String>* error,
4132
4199
  bool multiline)
4133
- : error_(error),
4134
- captures_(NULL),
4135
- in_(in),
4136
- current_(kEndMarker),
4137
- next_pos_(0),
4138
- capture_count_(0),
4139
- has_more_(true),
4140
- multiline_(multiline),
4141
- simple_(false),
4142
- contains_anchor_(false),
4143
- is_scanned_for_captures_(false),
4144
- failed_(false) {
4200
+ : isolate_(Isolate::Current()),
4201
+ error_(error),
4202
+ captures_(NULL),
4203
+ in_(in),
4204
+ current_(kEndMarker),
4205
+ next_pos_(0),
4206
+ capture_count_(0),
4207
+ has_more_(true),
4208
+ multiline_(multiline),
4209
+ simple_(false),
4210
+ contains_anchor_(false),
4211
+ is_scanned_for_captures_(false),
4212
+ failed_(false) {
4145
4213
  Advance();
4146
4214
  }
4147
4215
 
@@ -4157,10 +4225,10 @@ uc32 RegExpParser::Next() {
4157
4225
 
4158
4226
  void RegExpParser::Advance() {
4159
4227
  if (next_pos_ < in()->length()) {
4160
- StackLimitCheck check;
4228
+ StackLimitCheck check(isolate());
4161
4229
  if (check.HasOverflowed()) {
4162
- ReportError(CStrVector(Top::kStackOverflowMessage));
4163
- } else if (Zone::excess_allocation()) {
4230
+ ReportError(CStrVector(Isolate::kStackOverflowMessage));
4231
+ } else if (isolate()->zone()->excess_allocation()) {
4164
4232
  ReportError(CStrVector("Regular expression too large"));
4165
4233
  } else {
4166
4234
  current_ = in()->Get(next_pos_);
@@ -4191,7 +4259,7 @@ bool RegExpParser::simple() {
4191
4259
 
4192
4260
  RegExpTree* RegExpParser::ReportError(Vector<const char> message) {
4193
4261
  failed_ = true;
4194
- *error_ = Factory::NewStringFromAscii(message, NOT_TENURED);
4262
+ *error_ = isolate()->factory()->NewStringFromAscii(message, NOT_TENURED);
4195
4263
  // Zip to the end to make sure the no more input is read.
4196
4264
  current_ = kEndMarker;
4197
4265
  next_pos_ = in()->length();
@@ -4261,13 +4329,13 @@ RegExpTree* RegExpParser::ParseDisjunction() {
4261
4329
 
4262
4330
  // Build result of subexpression.
4263
4331
  if (type == CAPTURE) {
4264
- RegExpCapture* capture = new RegExpCapture(body, capture_index);
4332
+ RegExpCapture* capture = new(zone()) RegExpCapture(body, capture_index);
4265
4333
  captures_->at(capture_index - 1) = capture;
4266
4334
  body = capture;
4267
4335
  } else if (type != GROUPING) {
4268
4336
  ASSERT(type == POSITIVE_LOOKAHEAD || type == NEGATIVE_LOOKAHEAD);
4269
4337
  bool is_positive = (type == POSITIVE_LOOKAHEAD);
4270
- body = new RegExpLookahead(body,
4338
+ body = new(zone()) RegExpLookahead(body,
4271
4339
  is_positive,
4272
4340
  end_capture_index - capture_index,
4273
4341
  capture_index);
@@ -4290,10 +4358,10 @@ RegExpTree* RegExpParser::ParseDisjunction() {
4290
4358
  Advance();
4291
4359
  if (multiline_) {
4292
4360
  builder->AddAssertion(
4293
- new RegExpAssertion(RegExpAssertion::START_OF_LINE));
4361
+ new(zone()) RegExpAssertion(RegExpAssertion::START_OF_LINE));
4294
4362
  } else {
4295
4363
  builder->AddAssertion(
4296
- new RegExpAssertion(RegExpAssertion::START_OF_INPUT));
4364
+ new(zone()) RegExpAssertion(RegExpAssertion::START_OF_INPUT));
4297
4365
  set_contains_anchor();
4298
4366
  }
4299
4367
  continue;
@@ -4303,7 +4371,7 @@ RegExpTree* RegExpParser::ParseDisjunction() {
4303
4371
  RegExpAssertion::Type type =
4304
4372
  multiline_ ? RegExpAssertion::END_OF_LINE :
4305
4373
  RegExpAssertion::END_OF_INPUT;
4306
- builder->AddAssertion(new RegExpAssertion(type));
4374
+ builder->AddAssertion(new(zone()) RegExpAssertion(type));
4307
4375
  continue;
4308
4376
  }
4309
4377
  case '.': {
@@ -4311,7 +4379,7 @@ RegExpTree* RegExpParser::ParseDisjunction() {
4311
4379
  // everything except \x0a, \x0d, \u2028 and \u2029
4312
4380
  ZoneList<CharacterRange>* ranges = new ZoneList<CharacterRange>(2);
4313
4381
  CharacterRange::AddClassEscape('.', ranges);
4314
- RegExpTree* atom = new RegExpCharacterClass(ranges, false);
4382
+ RegExpTree* atom = new(zone()) RegExpCharacterClass(ranges, false);
4315
4383
  builder->AddAtom(atom);
4316
4384
  break;
4317
4385
  }
@@ -4344,7 +4412,7 @@ RegExpTree* RegExpParser::ParseDisjunction() {
4344
4412
  captures_->Add(NULL);
4345
4413
  }
4346
4414
  // Store current state and begin new disjunction parsing.
4347
- stored_state = new RegExpParserState(stored_state,
4415
+ stored_state = new(zone()) RegExpParserState(stored_state,
4348
4416
  type,
4349
4417
  captures_started());
4350
4418
  builder = stored_state->builder();
@@ -4364,12 +4432,12 @@ RegExpTree* RegExpParser::ParseDisjunction() {
4364
4432
  case 'b':
4365
4433
  Advance(2);
4366
4434
  builder->AddAssertion(
4367
- new RegExpAssertion(RegExpAssertion::BOUNDARY));
4435
+ new(zone()) RegExpAssertion(RegExpAssertion::BOUNDARY));
4368
4436
  continue;
4369
4437
  case 'B':
4370
4438
  Advance(2);
4371
4439
  builder->AddAssertion(
4372
- new RegExpAssertion(RegExpAssertion::NON_BOUNDARY));
4440
+ new(zone()) RegExpAssertion(RegExpAssertion::NON_BOUNDARY));
4373
4441
  continue;
4374
4442
  // AtomEscape ::
4375
4443
  // CharacterClassEscape
@@ -4381,7 +4449,7 @@ RegExpTree* RegExpParser::ParseDisjunction() {
4381
4449
  Advance(2);
4382
4450
  ZoneList<CharacterRange>* ranges = new ZoneList<CharacterRange>(2);
4383
4451
  CharacterRange::AddClassEscape(c, ranges);
4384
- RegExpTree* atom = new RegExpCharacterClass(ranges, false);
4452
+ RegExpTree* atom = new(zone()) RegExpCharacterClass(ranges, false);
4385
4453
  builder->AddAtom(atom);
4386
4454
  break;
4387
4455
  }
@@ -4397,7 +4465,7 @@ RegExpTree* RegExpParser::ParseDisjunction() {
4397
4465
  builder->AddEmpty();
4398
4466
  break;
4399
4467
  }
4400
- RegExpTree* atom = new RegExpBackReference(capture);
4468
+ RegExpTree* atom = new(zone()) RegExpBackReference(capture);
4401
4469
  builder->AddAtom(atom);
4402
4470
  break;
4403
4471
  }
@@ -4545,30 +4613,6 @@ RegExpTree* RegExpParser::ParseDisjunction() {
4545
4613
  }
4546
4614
  }
4547
4615
 
4548
- class SourceCharacter {
4549
- public:
4550
- static bool Is(uc32 c) {
4551
- switch (c) {
4552
- // case ']': case '}':
4553
- // In spidermonkey and jsc these are treated as source characters
4554
- // so we do too.
4555
- case '^': case '$': case '\\': case '.': case '*': case '+':
4556
- case '?': case '(': case ')': case '[': case '{': case '|':
4557
- case RegExpParser::kEndMarker:
4558
- return false;
4559
- default:
4560
- return true;
4561
- }
4562
- }
4563
- };
4564
-
4565
-
4566
- static unibrow::Predicate<SourceCharacter> source_character;
4567
-
4568
-
4569
- static inline bool IsSourceCharacter(uc32 c) {
4570
- return source_character.get(c);
4571
- }
4572
4616
 
4573
4617
  #ifdef DEBUG
4574
4618
  // Currently only used in an ASSERT.
@@ -4939,7 +4983,7 @@ RegExpTree* RegExpParser::ParseCharacterClass() {
4939
4983
  ranges->Add(CharacterRange::Everything());
4940
4984
  is_negated = !is_negated;
4941
4985
  }
4942
- return new RegExpCharacterClass(ranges, is_negated);
4986
+ return new(zone()) RegExpCharacterClass(ranges, is_negated);
4943
4987
  }
4944
4988
 
4945
4989
 
@@ -5021,14 +5065,15 @@ int ScriptDataImpl::ReadNumber(byte** source) {
5021
5065
  static ScriptDataImpl* DoPreParse(UC16CharacterStream* source,
5022
5066
  bool allow_lazy,
5023
5067
  ParserRecorder* recorder) {
5024
- V8JavaScriptScanner scanner;
5068
+ Isolate* isolate = Isolate::Current();
5069
+ V8JavaScriptScanner scanner(isolate->scanner_constants());
5025
5070
  scanner.Initialize(source);
5026
- intptr_t stack_limit = StackGuard::real_climit();
5071
+ intptr_t stack_limit = isolate->stack_guard()->real_climit();
5027
5072
  if (!preparser::PreParser::PreParseProgram(&scanner,
5028
5073
  recorder,
5029
5074
  allow_lazy,
5030
5075
  stack_limit)) {
5031
- Top::StackOverflow();
5076
+ isolate->StackOverflow();
5032
5077
  return NULL;
5033
5078
  }
5034
5079
 
@@ -5091,10 +5136,10 @@ bool ParserApi::Parse(CompilationInfo* info) {
5091
5136
  Handle<Script> script = info->script();
5092
5137
  if (info->is_lazy()) {
5093
5138
  Parser parser(script, true, NULL, NULL);
5094
- result = parser.ParseLazy(info->shared_info());
5139
+ result = parser.ParseLazy(info);
5095
5140
  } else {
5096
5141
  bool allow_natives_syntax =
5097
- FLAG_allow_natives_syntax || Bootstrapper::IsActive();
5142
+ info->allows_natives_syntax() || FLAG_allow_natives_syntax;
5098
5143
  ScriptDataImpl* pre_data = info->pre_parse_data();
5099
5144
  Parser parser(script, allow_natives_syntax, info->extension(), pre_data);
5100
5145
  if (pre_data != NULL && pre_data->has_error()) {
@@ -5107,7 +5152,7 @@ bool ParserApi::Parse(CompilationInfo* info) {
5107
5152
  DeleteArray(args[i]);
5108
5153
  }
5109
5154
  DeleteArray(args.start());
5110
- ASSERT(Top::has_pending_exception());
5155
+ ASSERT(info->isolate()->has_pending_exception());
5111
5156
  } else {
5112
5157
  Handle<String> source = Handle<String>(String::cast(script->source()));
5113
5158
  result = parser.ParseProgram(source,