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
@@ -32,21 +32,21 @@ namespace v8 {
32
32
  namespace internal {
33
33
 
34
34
  #define T(name, string, precedence) #name,
35
- const char* Token::name_[NUM_TOKENS] = {
35
+ const char* const Token::name_[NUM_TOKENS] = {
36
36
  TOKEN_LIST(T, T, IGNORE_TOKEN)
37
37
  };
38
38
  #undef T
39
39
 
40
40
 
41
41
  #define T(name, string, precedence) string,
42
- const char* Token::string_[NUM_TOKENS] = {
42
+ const char* const Token::string_[NUM_TOKENS] = {
43
43
  TOKEN_LIST(T, T, IGNORE_TOKEN)
44
44
  };
45
45
  #undef T
46
46
 
47
47
 
48
48
  #define T(name, string, precedence) precedence,
49
- int8_t Token::precedence_[NUM_TOKENS] = {
49
+ const int8_t Token::precedence_[NUM_TOKENS] = {
50
50
  TOKEN_LIST(T, T, IGNORE_TOKEN)
51
51
  };
52
52
  #undef T
@@ -277,9 +277,9 @@ class Token {
277
277
  }
278
278
 
279
279
  private:
280
- static const char* name_[NUM_TOKENS];
281
- static const char* string_[NUM_TOKENS];
282
- static int8_t precedence_[NUM_TOKENS];
280
+ static const char* const name_[NUM_TOKENS];
281
+ static const char* const string_[NUM_TOKENS];
282
+ static const int8_t precedence_[NUM_TOKENS];
283
283
  static const char token_type[NUM_TOKENS];
284
284
  };
285
285
 
data/vendor/v8/src/top.cc CHANGED
@@ -37,31 +37,12 @@
37
37
  #include "string-stream.h"
38
38
  #include "vm-state-inl.h"
39
39
 
40
+ // TODO(isolates): move to isolate.cc. This stuff is kept here to
41
+ // simplify merging.
42
+
40
43
  namespace v8 {
41
44
  namespace internal {
42
45
 
43
- #ifdef ENABLE_LOGGING_AND_PROFILING
44
- Semaphore* Top::runtime_profiler_semaphore_ = NULL;
45
- #endif
46
- ThreadLocalTop Top::thread_local_;
47
- Mutex* Top::break_access_ = OS::CreateMutex();
48
-
49
- NoAllocationStringAllocator* preallocated_message_space = NULL;
50
-
51
- bool capture_stack_trace_for_uncaught_exceptions = false;
52
- int stack_trace_for_uncaught_exceptions_frame_limit = 0;
53
- StackTrace::StackTraceOptions stack_trace_for_uncaught_exceptions_options =
54
- StackTrace::kOverview;
55
-
56
- Address top_addresses[] = {
57
- #define C(name) reinterpret_cast<Address>(Top::name()),
58
- TOP_ADDRESS_LIST(C)
59
- TOP_ADDRESS_LIST_PROF(C)
60
- #undef C
61
- NULL
62
- };
63
-
64
-
65
46
  v8::TryCatch* ThreadLocalTop::TryCatchHandler() {
66
47
  return TRY_CATCH_FROM_ADDRESS(try_catch_handler_address());
67
48
  }
@@ -72,9 +53,9 @@ void ThreadLocalTop::Initialize() {
72
53
  handler_ = 0;
73
54
  #ifdef USE_SIMULATOR
74
55
  #ifdef V8_TARGET_ARCH_ARM
75
- simulator_ = Simulator::current();
56
+ simulator_ = Simulator::current(Isolate::Current());
76
57
  #elif V8_TARGET_ARCH_MIPS
77
- simulator_ = assembler::mips::Simulator::current();
58
+ simulator_ = Simulator::current(Isolate::Current());
78
59
  #endif
79
60
  #endif
80
61
  #ifdef ENABLE_LOGGING_AND_PROFILING
@@ -83,11 +64,10 @@ void ThreadLocalTop::Initialize() {
83
64
  #endif
84
65
  #ifdef ENABLE_VMSTATE_TRACKING
85
66
  current_vm_state_ = EXTERNAL;
86
- runtime_profiler_state_ = Top::PROF_NOT_IN_JS;
87
67
  #endif
88
68
  try_catch_handler_address_ = NULL;
89
69
  context_ = NULL;
90
- int id = ThreadManager::CurrentId();
70
+ int id = Isolate::Current()->thread_manager()->CurrentId();
91
71
  thread_id_ = (id == 0) ? ThreadManager::kInvalidId : id;
92
72
  external_caught_exception_ = false;
93
73
  failed_access_check_callback_ = NULL;
@@ -96,32 +76,32 @@ void ThreadLocalTop::Initialize() {
96
76
  }
97
77
 
98
78
 
99
- Address Top::get_address_from_id(Top::AddressId id) {
100
- return top_addresses[id];
79
+ Address Isolate::get_address_from_id(Isolate::AddressId id) {
80
+ return isolate_addresses_[id];
101
81
  }
102
82
 
103
83
 
104
- char* Top::Iterate(ObjectVisitor* v, char* thread_storage) {
84
+ char* Isolate::Iterate(ObjectVisitor* v, char* thread_storage) {
105
85
  ThreadLocalTop* thread = reinterpret_cast<ThreadLocalTop*>(thread_storage);
106
86
  Iterate(v, thread);
107
87
  return thread_storage + sizeof(ThreadLocalTop);
108
88
  }
109
89
 
110
90
 
111
- void Top::IterateThread(ThreadVisitor* v) {
112
- v->VisitThread(&thread_local_);
91
+ void Isolate::IterateThread(ThreadVisitor* v) {
92
+ v->VisitThread(thread_local_top());
113
93
  }
114
94
 
115
95
 
116
- void Top::IterateThread(ThreadVisitor* v, char* t) {
96
+ void Isolate::IterateThread(ThreadVisitor* v, char* t) {
117
97
  ThreadLocalTop* thread = reinterpret_cast<ThreadLocalTop*>(t);
118
98
  v->VisitThread(thread);
119
99
  }
120
100
 
121
101
 
122
- void Top::Iterate(ObjectVisitor* v, ThreadLocalTop* thread) {
102
+ void Isolate::Iterate(ObjectVisitor* v, ThreadLocalTop* thread) {
123
103
  // Visit the roots from the top for a given thread.
124
- Object *pending;
104
+ Object* pending;
125
105
  // The pending exception can sometimes be a failure. We can't show
126
106
  // that to the GC, which only understands objects.
127
107
  if (thread->pending_exception_->ToObject(&pending)) {
@@ -151,176 +131,13 @@ void Top::Iterate(ObjectVisitor* v, ThreadLocalTop* thread) {
151
131
  }
152
132
 
153
133
 
154
- void Top::Iterate(ObjectVisitor* v) {
155
- ThreadLocalTop* current_t = &thread_local_;
134
+ void Isolate::Iterate(ObjectVisitor* v) {
135
+ ThreadLocalTop* current_t = thread_local_top();
156
136
  Iterate(v, current_t);
157
137
  }
158
138
 
159
139
 
160
- void Top::InitializeThreadLocal() {
161
- thread_local_.Initialize();
162
- clear_pending_exception();
163
- clear_pending_message();
164
- clear_scheduled_exception();
165
- }
166
-
167
-
168
- // Create a dummy thread that will wait forever on a semaphore. The only
169
- // purpose for this thread is to have some stack area to save essential data
170
- // into for use by a stacks only core dump (aka minidump).
171
- class PreallocatedMemoryThread: public Thread {
172
- public:
173
- PreallocatedMemoryThread()
174
- : Thread("v8:PreallocMem"),
175
- keep_running_(true) {
176
- wait_for_ever_semaphore_ = OS::CreateSemaphore(0);
177
- data_ready_semaphore_ = OS::CreateSemaphore(0);
178
- }
179
-
180
- // When the thread starts running it will allocate a fixed number of bytes
181
- // on the stack and publish the location of this memory for others to use.
182
- void Run() {
183
- EmbeddedVector<char, 15 * 1024> local_buffer;
184
-
185
- // Initialize the buffer with a known good value.
186
- OS::StrNCpy(local_buffer, "Trace data was not generated.\n",
187
- local_buffer.length());
188
-
189
- // Publish the local buffer and signal its availability.
190
- data_ = local_buffer.start();
191
- length_ = local_buffer.length();
192
- data_ready_semaphore_->Signal();
193
-
194
- while (keep_running_) {
195
- // This thread will wait here until the end of time.
196
- wait_for_ever_semaphore_->Wait();
197
- }
198
-
199
- // Make sure we access the buffer after the wait to remove all possibility
200
- // of it being optimized away.
201
- OS::StrNCpy(local_buffer, "PreallocatedMemoryThread shutting down.\n",
202
- local_buffer.length());
203
- }
204
-
205
- static char* data() {
206
- if (data_ready_semaphore_ != NULL) {
207
- // Initial access is guarded until the data has been published.
208
- data_ready_semaphore_->Wait();
209
- delete data_ready_semaphore_;
210
- data_ready_semaphore_ = NULL;
211
- }
212
- return data_;
213
- }
214
-
215
- static unsigned length() {
216
- if (data_ready_semaphore_ != NULL) {
217
- // Initial access is guarded until the data has been published.
218
- data_ready_semaphore_->Wait();
219
- delete data_ready_semaphore_;
220
- data_ready_semaphore_ = NULL;
221
- }
222
- return length_;
223
- }
224
-
225
- static void StartThread() {
226
- if (the_thread_ != NULL) return;
227
-
228
- the_thread_ = new PreallocatedMemoryThread();
229
- the_thread_->Start();
230
- }
231
-
232
- // Stop the PreallocatedMemoryThread and release its resources.
233
- static void StopThread() {
234
- if (the_thread_ == NULL) return;
235
-
236
- the_thread_->keep_running_ = false;
237
- wait_for_ever_semaphore_->Signal();
238
-
239
- // Wait for the thread to terminate.
240
- the_thread_->Join();
241
-
242
- if (data_ready_semaphore_ != NULL) {
243
- delete data_ready_semaphore_;
244
- data_ready_semaphore_ = NULL;
245
- }
246
-
247
- delete wait_for_ever_semaphore_;
248
- wait_for_ever_semaphore_ = NULL;
249
-
250
- // Done with the thread entirely.
251
- delete the_thread_;
252
- the_thread_ = NULL;
253
- }
254
-
255
- private:
256
- // Used to make sure that the thread keeps looping even for spurious wakeups.
257
- bool keep_running_;
258
-
259
- // The preallocated memory thread singleton.
260
- static PreallocatedMemoryThread* the_thread_;
261
- // This semaphore is used by the PreallocatedMemoryThread to wait for ever.
262
- static Semaphore* wait_for_ever_semaphore_;
263
- // Semaphore to signal that the data has been initialized.
264
- static Semaphore* data_ready_semaphore_;
265
-
266
- // Location and size of the preallocated memory block.
267
- static char* data_;
268
- static unsigned length_;
269
-
270
- DISALLOW_COPY_AND_ASSIGN(PreallocatedMemoryThread);
271
- };
272
-
273
- PreallocatedMemoryThread* PreallocatedMemoryThread::the_thread_ = NULL;
274
- Semaphore* PreallocatedMemoryThread::wait_for_ever_semaphore_ = NULL;
275
- Semaphore* PreallocatedMemoryThread::data_ready_semaphore_ = NULL;
276
- char* PreallocatedMemoryThread::data_ = NULL;
277
- unsigned PreallocatedMemoryThread::length_ = 0;
278
-
279
- static bool initialized = false;
280
-
281
- void Top::Initialize() {
282
- CHECK(!initialized);
283
-
284
- #ifdef ENABLE_LOGGING_AND_PROFILING
285
- ASSERT(runtime_profiler_semaphore_ == NULL);
286
- runtime_profiler_semaphore_ = OS::CreateSemaphore(0);
287
- #endif
288
-
289
- InitializeThreadLocal();
290
-
291
- // Only preallocate on the first initialization.
292
- if (FLAG_preallocate_message_memory && (preallocated_message_space == NULL)) {
293
- // Start the thread which will set aside some memory.
294
- PreallocatedMemoryThread::StartThread();
295
- preallocated_message_space =
296
- new NoAllocationStringAllocator(PreallocatedMemoryThread::data(),
297
- PreallocatedMemoryThread::length());
298
- PreallocatedStorage::Init(PreallocatedMemoryThread::length() / 4);
299
- }
300
- initialized = true;
301
- }
302
-
303
-
304
- void Top::TearDown() {
305
- if (initialized) {
306
- #ifdef ENABLE_LOGGING_AND_PROFILING
307
- delete runtime_profiler_semaphore_;
308
- runtime_profiler_semaphore_ = NULL;
309
- #endif
310
-
311
- // Remove the external reference to the preallocated stack memory.
312
- if (preallocated_message_space != NULL) {
313
- delete preallocated_message_space;
314
- preallocated_message_space = NULL;
315
- }
316
-
317
- PreallocatedMemoryThread::StopThread();
318
- initialized = false;
319
- }
320
- }
321
-
322
-
323
- void Top::RegisterTryCatchHandler(v8::TryCatch* that) {
140
+ void Isolate::RegisterTryCatchHandler(v8::TryCatch* that) {
324
141
  // The ARM simulator has a separate JS stack. We therefore register
325
142
  // the C++ try catch handler with the simulator and get back an
326
143
  // address that can be used for comparisons with addresses into the
@@ -328,68 +145,64 @@ void Top::RegisterTryCatchHandler(v8::TryCatch* that) {
328
145
  // returned will be the address of the C++ try catch handler itself.
329
146
  Address address = reinterpret_cast<Address>(
330
147
  SimulatorStack::RegisterCTryCatch(reinterpret_cast<uintptr_t>(that)));
331
- thread_local_.set_try_catch_handler_address(address);
148
+ thread_local_top()->set_try_catch_handler_address(address);
332
149
  }
333
150
 
334
151
 
335
- void Top::UnregisterTryCatchHandler(v8::TryCatch* that) {
336
- ASSERT(try_catch_handler() == that);
337
- thread_local_.set_try_catch_handler_address(
152
+ void Isolate::UnregisterTryCatchHandler(v8::TryCatch* that) {
153
+ ASSERT(thread_local_top()->TryCatchHandler() == that);
154
+ thread_local_top()->set_try_catch_handler_address(
338
155
  reinterpret_cast<Address>(that->next_));
339
- thread_local_.catcher_ = NULL;
156
+ thread_local_top()->catcher_ = NULL;
340
157
  SimulatorStack::UnregisterCTryCatch();
341
158
  }
342
159
 
343
160
 
344
-
345
- static int stack_trace_nesting_level = 0;
346
- static StringStream* incomplete_message = NULL;
347
-
348
-
349
- Handle<String> Top::StackTraceString() {
350
- if (stack_trace_nesting_level == 0) {
351
- stack_trace_nesting_level++;
161
+ Handle<String> Isolate::StackTraceString() {
162
+ if (stack_trace_nesting_level_ == 0) {
163
+ stack_trace_nesting_level_++;
352
164
  HeapStringAllocator allocator;
353
165
  StringStream::ClearMentionedObjectCache();
354
166
  StringStream accumulator(&allocator);
355
- incomplete_message = &accumulator;
167
+ incomplete_message_ = &accumulator;
356
168
  PrintStack(&accumulator);
357
169
  Handle<String> stack_trace = accumulator.ToString();
358
- incomplete_message = NULL;
359
- stack_trace_nesting_level = 0;
170
+ incomplete_message_ = NULL;
171
+ stack_trace_nesting_level_ = 0;
360
172
  return stack_trace;
361
- } else if (stack_trace_nesting_level == 1) {
362
- stack_trace_nesting_level++;
173
+ } else if (stack_trace_nesting_level_ == 1) {
174
+ stack_trace_nesting_level_++;
363
175
  OS::PrintError(
364
176
  "\n\nAttempt to print stack while printing stack (double fault)\n");
365
177
  OS::PrintError(
366
178
  "If you are lucky you may find a partial stack dump on stdout.\n\n");
367
- incomplete_message->OutputToStdOut();
368
- return Factory::empty_symbol();
179
+ incomplete_message_->OutputToStdOut();
180
+ return factory()->empty_symbol();
369
181
  } else {
370
182
  OS::Abort();
371
183
  // Unreachable
372
- return Factory::empty_symbol();
184
+ return factory()->empty_symbol();
373
185
  }
374
186
  }
375
187
 
376
188
 
377
- Handle<JSArray> Top::CaptureCurrentStackTrace(
189
+ Handle<JSArray> Isolate::CaptureCurrentStackTrace(
378
190
  int frame_limit, StackTrace::StackTraceOptions options) {
379
191
  // Ensure no negative values.
380
192
  int limit = Max(frame_limit, 0);
381
- Handle<JSArray> stack_trace = Factory::NewJSArray(frame_limit);
193
+ Handle<JSArray> stack_trace = factory()->NewJSArray(frame_limit);
382
194
 
383
- Handle<String> column_key = Factory::LookupAsciiSymbol("column");
384
- Handle<String> line_key = Factory::LookupAsciiSymbol("lineNumber");
385
- Handle<String> script_key = Factory::LookupAsciiSymbol("scriptName");
195
+ Handle<String> column_key = factory()->LookupAsciiSymbol("column");
196
+ Handle<String> line_key = factory()->LookupAsciiSymbol("lineNumber");
197
+ Handle<String> script_key = factory()->LookupAsciiSymbol("scriptName");
386
198
  Handle<String> name_or_source_url_key =
387
- Factory::LookupAsciiSymbol("nameOrSourceURL");
199
+ factory()->LookupAsciiSymbol("nameOrSourceURL");
388
200
  Handle<String> script_name_or_source_url_key =
389
- Factory::LookupAsciiSymbol("scriptNameOrSourceURL");
390
- Handle<String> function_key = Factory::LookupAsciiSymbol("functionName");
391
- Handle<String> eval_key = Factory::LookupAsciiSymbol("isEval");
392
- Handle<String> constructor_key = Factory::LookupAsciiSymbol("isConstructor");
201
+ factory()->LookupAsciiSymbol("scriptNameOrSourceURL");
202
+ Handle<String> function_key = factory()->LookupAsciiSymbol("functionName");
203
+ Handle<String> eval_key = factory()->LookupAsciiSymbol("isEval");
204
+ Handle<String> constructor_key =
205
+ factory()->LookupAsciiSymbol("isConstructor");
393
206
 
394
207
  StackTraceFrameIterator it;
395
208
  int frames_seen = 0;
@@ -400,7 +213,7 @@ Handle<JSArray> Top::CaptureCurrentStackTrace(
400
213
  frame->Summarize(&frames);
401
214
  for (int i = frames.length() - 1; i >= 0 && frames_seen < limit; i--) {
402
215
  // Create a JSObject to hold the information for the StackFrame.
403
- Handle<JSObject> stackFrame = Factory::NewJSObject(object_function());
216
+ Handle<JSObject> stackFrame = factory()->NewJSObject(object_function());
404
217
 
405
218
  Handle<JSFunction> fun = frames[i].function();
406
219
  Handle<Script> script(Script::cast(fun->shared()->script()));
@@ -429,12 +242,12 @@ Handle<JSArray> Top::CaptureCurrentStackTrace(
429
242
  }
430
243
 
431
244
  if (options & StackTrace::kScriptName) {
432
- Handle<Object> script_name(script->name());
245
+ Handle<Object> script_name(script->name(), this);
433
246
  SetLocalPropertyNoThrow(stackFrame, script_key, script_name);
434
247
  }
435
248
 
436
249
  if (options & StackTrace::kScriptNameOrSourceURL) {
437
- Handle<Object> script_name(script->name());
250
+ Handle<Object> script_name(script->name(), this);
438
251
  Handle<JSValue> script_wrapper = GetScriptWrapper(script);
439
252
  Handle<Object> property = GetProperty(script_wrapper,
440
253
  name_or_source_url_key);
@@ -444,16 +257,16 @@ Handle<JSArray> Top::CaptureCurrentStackTrace(
444
257
  Handle<Object> result = Execution::TryCall(method, script_wrapper, 0,
445
258
  NULL, &caught_exception);
446
259
  if (caught_exception) {
447
- result = Factory::undefined_value();
260
+ result = factory()->undefined_value();
448
261
  }
449
262
  SetLocalPropertyNoThrow(stackFrame, script_name_or_source_url_key,
450
263
  result);
451
264
  }
452
265
 
453
266
  if (options & StackTrace::kFunctionName) {
454
- Handle<Object> fun_name(fun->shared()->name());
267
+ Handle<Object> fun_name(fun->shared()->name(), this);
455
268
  if (fun_name->ToBoolean()->IsFalse()) {
456
- fun_name = Handle<Object>(fun->shared()->inferred_name());
269
+ fun_name = Handle<Object>(fun->shared()->inferred_name(), this);
457
270
  }
458
271
  SetLocalPropertyNoThrow(stackFrame, function_key, fun_name);
459
272
  }
@@ -461,13 +274,13 @@ Handle<JSArray> Top::CaptureCurrentStackTrace(
461
274
  if (options & StackTrace::kIsEval) {
462
275
  int type = Smi::cast(script->compilation_type())->value();
463
276
  Handle<Object> is_eval = (type == Script::COMPILATION_TYPE_EVAL) ?
464
- Factory::true_value() : Factory::false_value();
277
+ factory()->true_value() : factory()->false_value();
465
278
  SetLocalPropertyNoThrow(stackFrame, eval_key, is_eval);
466
279
  }
467
280
 
468
281
  if (options & StackTrace::kIsConstructor) {
469
282
  Handle<Object> is_constructor = (frames[i].is_constructor()) ?
470
- Factory::true_value() : Factory::false_value();
283
+ factory()->true_value() : factory()->false_value();
471
284
  SetLocalPropertyNoThrow(stackFrame, constructor_key, is_constructor);
472
285
  }
473
286
 
@@ -482,41 +295,36 @@ Handle<JSArray> Top::CaptureCurrentStackTrace(
482
295
  }
483
296
 
484
297
 
485
- void Top::PrintStack() {
486
- if (stack_trace_nesting_level == 0) {
487
- stack_trace_nesting_level++;
298
+ void Isolate::PrintStack() {
299
+ if (stack_trace_nesting_level_ == 0) {
300
+ stack_trace_nesting_level_++;
488
301
 
489
302
  StringAllocator* allocator;
490
- if (preallocated_message_space == NULL) {
303
+ if (preallocated_message_space_ == NULL) {
491
304
  allocator = new HeapStringAllocator();
492
305
  } else {
493
- allocator = preallocated_message_space;
306
+ allocator = preallocated_message_space_;
494
307
  }
495
308
 
496
- NativeAllocationChecker allocation_checker(
497
- !FLAG_preallocate_message_memory ?
498
- NativeAllocationChecker::ALLOW :
499
- NativeAllocationChecker::DISALLOW);
500
-
501
309
  StringStream::ClearMentionedObjectCache();
502
310
  StringStream accumulator(allocator);
503
- incomplete_message = &accumulator;
311
+ incomplete_message_ = &accumulator;
504
312
  PrintStack(&accumulator);
505
313
  accumulator.OutputToStdOut();
506
314
  accumulator.Log();
507
- incomplete_message = NULL;
508
- stack_trace_nesting_level = 0;
509
- if (preallocated_message_space == NULL) {
315
+ incomplete_message_ = NULL;
316
+ stack_trace_nesting_level_ = 0;
317
+ if (preallocated_message_space_ == NULL) {
510
318
  // Remove the HeapStringAllocator created above.
511
319
  delete allocator;
512
320
  }
513
- } else if (stack_trace_nesting_level == 1) {
514
- stack_trace_nesting_level++;
321
+ } else if (stack_trace_nesting_level_ == 1) {
322
+ stack_trace_nesting_level_++;
515
323
  OS::PrintError(
516
324
  "\n\nAttempt to print stack while printing stack (double fault)\n");
517
325
  OS::PrintError(
518
326
  "If you are lucky you may find a partial stack dump on stdout.\n\n");
519
- incomplete_message->OutputToStdOut();
327
+ incomplete_message_->OutputToStdOut();
520
328
  }
521
329
  }
522
330
 
@@ -530,13 +338,20 @@ static void PrintFrames(StringStream* accumulator,
530
338
  }
531
339
 
532
340
 
533
- void Top::PrintStack(StringStream* accumulator) {
341
+ void Isolate::PrintStack(StringStream* accumulator) {
342
+ if (!IsInitialized()) {
343
+ accumulator->Add(
344
+ "\n==== Stack trace is not available ==========================\n\n");
345
+ accumulator->Add(
346
+ "\n==== Isolate for the thread is not initialized =============\n\n");
347
+ return;
348
+ }
534
349
  // The MentionedObjectCache is not GC-proof at the moment.
535
350
  AssertNoAllocation nogc;
536
351
  ASSERT(StringStream::IsMentionedObjectCacheClear());
537
352
 
538
353
  // Avoid printing anything if there are no frames.
539
- if (c_entry_fp(GetCurrentThread()) == 0) return;
354
+ if (c_entry_fp(thread_local_top()) == 0) return;
540
355
 
541
356
  accumulator->Add(
542
357
  "\n==== Stack trace ============================================\n\n");
@@ -551,28 +366,29 @@ void Top::PrintStack(StringStream* accumulator) {
551
366
  }
552
367
 
553
368
 
554
- void Top::SetFailedAccessCheckCallback(v8::FailedAccessCheckCallback callback) {
555
- thread_local_.failed_access_check_callback_ = callback;
369
+ void Isolate::SetFailedAccessCheckCallback(
370
+ v8::FailedAccessCheckCallback callback) {
371
+ thread_local_top()->failed_access_check_callback_ = callback;
556
372
  }
557
373
 
558
374
 
559
- void Top::ReportFailedAccessCheck(JSObject* receiver, v8::AccessType type) {
560
- if (!thread_local_.failed_access_check_callback_) return;
375
+ void Isolate::ReportFailedAccessCheck(JSObject* receiver, v8::AccessType type) {
376
+ if (!thread_local_top()->failed_access_check_callback_) return;
561
377
 
562
378
  ASSERT(receiver->IsAccessCheckNeeded());
563
- ASSERT(Top::context());
379
+ ASSERT(context());
564
380
 
565
381
  // Get the data object from access check info.
566
382
  JSFunction* constructor = JSFunction::cast(receiver->map()->constructor());
567
383
  if (!constructor->shared()->IsApiFunction()) return;
568
384
  Object* data_obj =
569
385
  constructor->shared()->get_api_func_data()->access_check_info();
570
- if (data_obj == Heap::undefined_value()) return;
386
+ if (data_obj == heap_.undefined_value()) return;
571
387
 
572
388
  HandleScope scope;
573
389
  Handle<JSObject> receiver_handle(receiver);
574
390
  Handle<Object> data(AccessCheckInfo::cast(data_obj)->data());
575
- thread_local_.failed_access_check_callback_(
391
+ thread_local_top()->failed_access_check_callback_(
576
392
  v8::Utils::ToLocal(receiver_handle),
577
393
  type,
578
394
  v8::Utils::ToLocal(data));
@@ -584,18 +400,19 @@ enum MayAccessDecision {
584
400
  };
585
401
 
586
402
 
587
- static MayAccessDecision MayAccessPreCheck(JSObject* receiver,
403
+ static MayAccessDecision MayAccessPreCheck(Isolate* isolate,
404
+ JSObject* receiver,
588
405
  v8::AccessType type) {
589
406
  // During bootstrapping, callback functions are not enabled yet.
590
- if (Bootstrapper::IsActive()) return YES;
407
+ if (isolate->bootstrapper()->IsActive()) return YES;
591
408
 
592
409
  if (receiver->IsJSGlobalProxy()) {
593
410
  Object* receiver_context = JSGlobalProxy::cast(receiver)->context();
594
411
  if (!receiver_context->IsContext()) return NO;
595
412
 
596
413
  // Get the global context of current top context.
597
- // avoid using Top::global_context() because it uses Handle.
598
- Context* global_context = Top::context()->global()->global_context();
414
+ // avoid using Isolate::global_context() because it uses Handle.
415
+ Context* global_context = isolate->context()->global()->global_context();
599
416
  if (receiver_context == global_context) return YES;
600
417
 
601
418
  if (Context::cast(receiver_context)->security_token() ==
@@ -607,7 +424,8 @@ static MayAccessDecision MayAccessPreCheck(JSObject* receiver,
607
424
  }
608
425
 
609
426
 
610
- bool Top::MayNamedAccess(JSObject* receiver, Object* key, v8::AccessType type) {
427
+ bool Isolate::MayNamedAccess(JSObject* receiver, Object* key,
428
+ v8::AccessType type) {
611
429
  ASSERT(receiver->IsAccessCheckNeeded());
612
430
 
613
431
  // The callers of this method are not expecting a GC.
@@ -615,13 +433,13 @@ bool Top::MayNamedAccess(JSObject* receiver, Object* key, v8::AccessType type) {
615
433
 
616
434
  // Skip checks for hidden properties access. Note, we do not
617
435
  // require existence of a context in this case.
618
- if (key == Heap::hidden_symbol()) return true;
436
+ if (key == heap_.hidden_symbol()) return true;
619
437
 
620
438
  // Check for compatibility between the security tokens in the
621
439
  // current lexical context and the accessed object.
622
- ASSERT(Top::context());
440
+ ASSERT(context());
623
441
 
624
- MayAccessDecision decision = MayAccessPreCheck(receiver, type);
442
+ MayAccessDecision decision = MayAccessPreCheck(this, receiver, type);
625
443
  if (decision != UNKNOWN) return decision == YES;
626
444
 
627
445
  // Get named access check callback
@@ -630,7 +448,7 @@ bool Top::MayNamedAccess(JSObject* receiver, Object* key, v8::AccessType type) {
630
448
 
631
449
  Object* data_obj =
632
450
  constructor->shared()->get_api_func_data()->access_check_info();
633
- if (data_obj == Heap::undefined_value()) return false;
451
+ if (data_obj == heap_.undefined_value()) return false;
634
452
 
635
453
  Object* fun_obj = AccessCheckInfo::cast(data_obj)->named_callback();
636
454
  v8::NamedSecurityCallback callback =
@@ -638,15 +456,15 @@ bool Top::MayNamedAccess(JSObject* receiver, Object* key, v8::AccessType type) {
638
456
 
639
457
  if (!callback) return false;
640
458
 
641
- HandleScope scope;
642
- Handle<JSObject> receiver_handle(receiver);
643
- Handle<Object> key_handle(key);
644
- Handle<Object> data(AccessCheckInfo::cast(data_obj)->data());
645
- LOG(ApiNamedSecurityCheck(key));
459
+ HandleScope scope(this);
460
+ Handle<JSObject> receiver_handle(receiver, this);
461
+ Handle<Object> key_handle(key, this);
462
+ Handle<Object> data(AccessCheckInfo::cast(data_obj)->data(), this);
463
+ LOG(this, ApiNamedSecurityCheck(key));
646
464
  bool result = false;
647
465
  {
648
466
  // Leaving JavaScript.
649
- VMState state(EXTERNAL);
467
+ VMState state(this, EXTERNAL);
650
468
  result = callback(v8::Utils::ToLocal(receiver_handle),
651
469
  v8::Utils::ToLocal(key_handle),
652
470
  type,
@@ -656,17 +474,15 @@ bool Top::MayNamedAccess(JSObject* receiver, Object* key, v8::AccessType type) {
656
474
  }
657
475
 
658
476
 
659
- bool Top::MayIndexedAccess(JSObject* receiver,
660
- uint32_t index,
661
- v8::AccessType type) {
477
+ bool Isolate::MayIndexedAccess(JSObject* receiver,
478
+ uint32_t index,
479
+ v8::AccessType type) {
662
480
  ASSERT(receiver->IsAccessCheckNeeded());
663
481
  // Check for compatibility between the security tokens in the
664
482
  // current lexical context and the accessed object.
665
- ASSERT(Top::context());
666
- // The callers of this method are not expecting a GC.
667
- AssertNoAllocation no_gc;
483
+ ASSERT(context());
668
484
 
669
- MayAccessDecision decision = MayAccessPreCheck(receiver, type);
485
+ MayAccessDecision decision = MayAccessPreCheck(this, receiver, type);
670
486
  if (decision != UNKNOWN) return decision == YES;
671
487
 
672
488
  // Get indexed access check callback
@@ -675,7 +491,7 @@ bool Top::MayIndexedAccess(JSObject* receiver,
675
491
 
676
492
  Object* data_obj =
677
493
  constructor->shared()->get_api_func_data()->access_check_info();
678
- if (data_obj == Heap::undefined_value()) return false;
494
+ if (data_obj == heap_.undefined_value()) return false;
679
495
 
680
496
  Object* fun_obj = AccessCheckInfo::cast(data_obj)->indexed_callback();
681
497
  v8::IndexedSecurityCallback callback =
@@ -683,14 +499,14 @@ bool Top::MayIndexedAccess(JSObject* receiver,
683
499
 
684
500
  if (!callback) return false;
685
501
 
686
- HandleScope scope;
687
- Handle<JSObject> receiver_handle(receiver);
688
- Handle<Object> data(AccessCheckInfo::cast(data_obj)->data());
689
- LOG(ApiIndexedSecurityCheck(index));
502
+ HandleScope scope(this);
503
+ Handle<JSObject> receiver_handle(receiver, this);
504
+ Handle<Object> data(AccessCheckInfo::cast(data_obj)->data(), this);
505
+ LOG(this, ApiIndexedSecurityCheck(index));
690
506
  bool result = false;
691
507
  {
692
508
  // Leaving JavaScript.
693
- VMState state(EXTERNAL);
509
+ VMState state(this, EXTERNAL);
694
510
  result = callback(v8::Utils::ToLocal(receiver_handle),
695
511
  index,
696
512
  type,
@@ -700,15 +516,15 @@ bool Top::MayIndexedAccess(JSObject* receiver,
700
516
  }
701
517
 
702
518
 
703
- const char* Top::kStackOverflowMessage =
519
+ const char* const Isolate::kStackOverflowMessage =
704
520
  "Uncaught RangeError: Maximum call stack size exceeded";
705
521
 
706
522
 
707
- Failure* Top::StackOverflow() {
523
+ Failure* Isolate::StackOverflow() {
708
524
  HandleScope scope;
709
- Handle<String> key = Factory::stack_overflow_symbol();
525
+ Handle<String> key = factory()->stack_overflow_symbol();
710
526
  Handle<JSObject> boilerplate =
711
- Handle<JSObject>::cast(GetProperty(Top::builtins(), key));
527
+ Handle<JSObject>::cast(GetProperty(js_builtins_object(), key));
712
528
  Handle<Object> exception = Copy(boilerplate);
713
529
  // TODO(1240995): To avoid having to call JavaScript code to compute
714
530
  // the message for stack overflow exceptions which is very likely to
@@ -719,23 +535,23 @@ Failure* Top::StackOverflow() {
719
535
  }
720
536
 
721
537
 
722
- Failure* Top::TerminateExecution() {
723
- DoThrow(Heap::termination_exception(), NULL, NULL);
538
+ Failure* Isolate::TerminateExecution() {
539
+ DoThrow(heap_.termination_exception(), NULL, NULL);
724
540
  return Failure::Exception();
725
541
  }
726
542
 
727
543
 
728
- Failure* Top::Throw(Object* exception, MessageLocation* location) {
544
+ Failure* Isolate::Throw(Object* exception, MessageLocation* location) {
729
545
  DoThrow(exception, location, NULL);
730
546
  return Failure::Exception();
731
547
  }
732
548
 
733
549
 
734
- Failure* Top::ReThrow(MaybeObject* exception, MessageLocation* location) {
550
+ Failure* Isolate::ReThrow(MaybeObject* exception, MessageLocation* location) {
735
551
  bool can_be_caught_externally = false;
736
552
  ShouldReportException(&can_be_caught_externally,
737
553
  is_catchable_by_javascript(exception));
738
- thread_local_.catcher_ = can_be_caught_externally ?
554
+ thread_local_top()->catcher_ = can_be_caught_externally ?
739
555
  try_catch_handler() : NULL;
740
556
 
741
557
  // Set the exception being re-thrown.
@@ -744,22 +560,22 @@ Failure* Top::ReThrow(MaybeObject* exception, MessageLocation* location) {
744
560
  }
745
561
 
746
562
 
747
- Failure* Top::ThrowIllegalOperation() {
748
- return Throw(Heap::illegal_access_symbol());
563
+ Failure* Isolate::ThrowIllegalOperation() {
564
+ return Throw(heap_.illegal_access_symbol());
749
565
  }
750
566
 
751
567
 
752
- void Top::ScheduleThrow(Object* exception) {
568
+ void Isolate::ScheduleThrow(Object* exception) {
753
569
  // When scheduling a throw we first throw the exception to get the
754
570
  // error reporting if it is uncaught before rescheduling it.
755
571
  Throw(exception);
756
- thread_local_.scheduled_exception_ = pending_exception();
757
- thread_local_.external_caught_exception_ = false;
572
+ thread_local_top()->scheduled_exception_ = pending_exception();
573
+ thread_local_top()->external_caught_exception_ = false;
758
574
  clear_pending_exception();
759
575
  }
760
576
 
761
577
 
762
- Failure* Top::PromoteScheduledException() {
578
+ Failure* Isolate::PromoteScheduledException() {
763
579
  MaybeObject* thrown = scheduled_exception();
764
580
  clear_scheduled_exception();
765
581
  // Re-throw the exception to avoid getting repeated error reporting.
@@ -767,13 +583,13 @@ Failure* Top::PromoteScheduledException() {
767
583
  }
768
584
 
769
585
 
770
- void Top::PrintCurrentStackTrace(FILE* out) {
586
+ void Isolate::PrintCurrentStackTrace(FILE* out) {
771
587
  StackTraceFrameIterator it;
772
588
  while (!it.done()) {
773
589
  HandleScope scope;
774
590
  // Find code position if recorded in relocation info.
775
591
  JavaScriptFrame* frame = it.frame();
776
- int pos = frame->code()->SourcePosition(frame->pc());
592
+ int pos = frame->LookupCode(this)->SourcePosition(frame->pc());
777
593
  Handle<Object> pos_obj(Smi::FromInt(pos));
778
594
  // Fetch function and receiver.
779
595
  Handle<JSFunction> fun(JSFunction::cast(frame->function()));
@@ -782,8 +598,8 @@ void Top::PrintCurrentStackTrace(FILE* out) {
782
598
  // current frame is the top-level frame.
783
599
  it.Advance();
784
600
  Handle<Object> is_top_level = it.done()
785
- ? Factory::true_value()
786
- : Factory::false_value();
601
+ ? factory()->true_value()
602
+ : factory()->false_value();
787
603
  // Generate and print stack trace line.
788
604
  Handle<String> line =
789
605
  Execution::GetStackTraceLine(recv, fun, pos_obj, is_top_level);
@@ -795,8 +611,8 @@ void Top::PrintCurrentStackTrace(FILE* out) {
795
611
  }
796
612
 
797
613
 
798
- void Top::ComputeLocation(MessageLocation* target) {
799
- *target = MessageLocation(Handle<Script>(Heap::empty_script()), -1, -1);
614
+ void Isolate::ComputeLocation(MessageLocation* target) {
615
+ *target = MessageLocation(Handle<Script>(heap_.empty_script()), -1, -1);
800
616
  StackTraceFrameIterator it;
801
617
  if (!it.done()) {
802
618
  JavaScriptFrame* frame = it.frame();
@@ -804,7 +620,7 @@ void Top::ComputeLocation(MessageLocation* target) {
804
620
  Object* script = fun->shared()->script();
805
621
  if (script->IsScript() &&
806
622
  !(Script::cast(script)->source()->IsUndefined())) {
807
- int pos = frame->code()->SourcePosition(frame->pc());
623
+ int pos = frame->LookupCode(this)->SourcePosition(frame->pc());
808
624
  // Compute the location from the function and the reloc info.
809
625
  Handle<Script> casted_script(Script::cast(script));
810
626
  *target = MessageLocation(casted_script, pos, pos + 1);
@@ -813,18 +629,19 @@ void Top::ComputeLocation(MessageLocation* target) {
813
629
  }
814
630
 
815
631
 
816
- bool Top::ShouldReportException(bool* can_be_caught_externally,
817
- bool catchable_by_javascript) {
632
+ bool Isolate::ShouldReportException(bool* can_be_caught_externally,
633
+ bool catchable_by_javascript) {
818
634
  // Find the top-most try-catch handler.
819
635
  StackHandler* handler =
820
- StackHandler::FromAddress(Top::handler(Top::GetCurrentThread()));
636
+ StackHandler::FromAddress(Isolate::handler(thread_local_top()));
821
637
  while (handler != NULL && !handler->is_try_catch()) {
822
638
  handler = handler->next();
823
639
  }
824
640
 
825
641
  // Get the address of the external handler so we can compare the address to
826
642
  // determine which one is closer to the top of the stack.
827
- Address external_handler_address = thread_local_.try_catch_handler_address();
643
+ Address external_handler_address =
644
+ thread_local_top()->try_catch_handler_address();
828
645
 
829
646
  // The exception has been externally caught if and only if there is
830
647
  // an external handler which is on top of the top-most try-catch
@@ -843,9 +660,9 @@ bool Top::ShouldReportException(bool* can_be_caught_externally,
843
660
  }
844
661
 
845
662
 
846
- void Top::DoThrow(MaybeObject* exception,
847
- MessageLocation* location,
848
- const char* message) {
663
+ void Isolate::DoThrow(MaybeObject* exception,
664
+ MessageLocation* location,
665
+ const char* message) {
849
666
  ASSERT(!has_pending_exception());
850
667
 
851
668
  HandleScope scope;
@@ -865,7 +682,7 @@ void Top::DoThrow(MaybeObject* exception,
865
682
  #ifdef ENABLE_DEBUGGER_SUPPORT
866
683
  // Notify debugger of exception.
867
684
  if (catchable_by_javascript) {
868
- Debugger::OnException(exception_handle, report_exception);
685
+ debugger_->OnException(exception_handle, report_exception);
869
686
  }
870
687
  #endif
871
688
 
@@ -881,17 +698,17 @@ void Top::DoThrow(MaybeObject* exception,
881
698
  ComputeLocation(&potential_computed_location);
882
699
  location = &potential_computed_location;
883
700
  }
884
- if (!Bootstrapper::IsActive()) {
701
+ if (!bootstrapper()->IsActive()) {
885
702
  // It's not safe to try to make message objects or collect stack
886
703
  // traces while the bootstrapper is active since the infrastructure
887
704
  // may not have been properly initialized.
888
705
  Handle<String> stack_trace;
889
706
  if (FLAG_trace_exception) stack_trace = StackTraceString();
890
707
  Handle<JSArray> stack_trace_object;
891
- if (report_exception && capture_stack_trace_for_uncaught_exceptions) {
892
- stack_trace_object = Top::CaptureCurrentStackTrace(
893
- stack_trace_for_uncaught_exceptions_frame_limit,
894
- stack_trace_for_uncaught_exceptions_options);
708
+ if (report_exception && capture_stack_trace_for_uncaught_exceptions_) {
709
+ stack_trace_object = CaptureCurrentStackTrace(
710
+ stack_trace_for_uncaught_exceptions_frame_limit_,
711
+ stack_trace_for_uncaught_exceptions_options_);
895
712
  }
896
713
  ASSERT(is_object); // Can't use the handle unless there's a real object.
897
714
  message_obj = MessageHandler::MakeMessageObject("uncaught_exception",
@@ -901,20 +718,20 @@ void Top::DoThrow(MaybeObject* exception,
901
718
  }
902
719
 
903
720
  // Save the message for reporting if the the exception remains uncaught.
904
- thread_local_.has_pending_message_ = report_exception;
905
- thread_local_.pending_message_ = message;
721
+ thread_local_top()->has_pending_message_ = report_exception;
722
+ thread_local_top()->pending_message_ = message;
906
723
  if (!message_obj.is_null()) {
907
- thread_local_.pending_message_obj_ = *message_obj;
724
+ thread_local_top()->pending_message_obj_ = *message_obj;
908
725
  if (location != NULL) {
909
- thread_local_.pending_message_script_ = *location->script();
910
- thread_local_.pending_message_start_pos_ = location->start_pos();
911
- thread_local_.pending_message_end_pos_ = location->end_pos();
726
+ thread_local_top()->pending_message_script_ = *location->script();
727
+ thread_local_top()->pending_message_start_pos_ = location->start_pos();
728
+ thread_local_top()->pending_message_end_pos_ = location->end_pos();
912
729
  }
913
730
  }
914
731
 
915
732
  // Do not forget to clean catcher_ if currently thrown exception cannot
916
733
  // be caught. If necessary, ReThrow will update the catcher.
917
- thread_local_.catcher_ = can_be_caught_externally ?
734
+ thread_local_top()->catcher_ = can_be_caught_externally ?
918
735
  try_catch_handler() : NULL;
919
736
 
920
737
  // NOTE: Notifying the debugger or generating the message
@@ -930,11 +747,11 @@ void Top::DoThrow(MaybeObject* exception,
930
747
  }
931
748
 
932
749
 
933
- bool Top::IsExternallyCaught() {
750
+ bool Isolate::IsExternallyCaught() {
934
751
  ASSERT(has_pending_exception());
935
752
 
936
- if ((thread_local_.catcher_ == NULL) ||
937
- (try_catch_handler() != thread_local_.catcher_)) {
753
+ if ((thread_local_top()->catcher_ == NULL) ||
754
+ (try_catch_handler() != thread_local_top()->catcher_)) {
938
755
  // When throwing the exception, we found no v8::TryCatch
939
756
  // which should care about this exception.
940
757
  return false;
@@ -946,7 +763,8 @@ bool Top::IsExternallyCaught() {
946
763
 
947
764
  // Get the address of the external handler so we can compare the address to
948
765
  // determine which one is closer to the top of the stack.
949
- Address external_handler_address = thread_local_.try_catch_handler_address();
766
+ Address external_handler_address =
767
+ thread_local_top()->try_catch_handler_address();
950
768
  ASSERT(external_handler_address != NULL);
951
769
 
952
770
  // The exception has been externally caught if and only if there is
@@ -959,7 +777,7 @@ bool Top::IsExternallyCaught() {
959
777
  // aborted by jumps in control flow like return, break, etc. and we'll
960
778
  // have another chances to set proper v8::TryCatch.
961
779
  StackHandler* handler =
962
- StackHandler::FromAddress(Top::handler(Top::GetCurrentThread()));
780
+ StackHandler::FromAddress(Isolate::handler(thread_local_top()));
963
781
  while (handler != NULL && handler->address() < external_handler_address) {
964
782
  ASSERT(!handler->is_try_catch());
965
783
  if (handler->is_try_finally()) return false;
@@ -971,46 +789,48 @@ bool Top::IsExternallyCaught() {
971
789
  }
972
790
 
973
791
 
974
- void Top::ReportPendingMessages() {
792
+ void Isolate::ReportPendingMessages() {
975
793
  ASSERT(has_pending_exception());
976
794
  // If the pending exception is OutOfMemoryException set out_of_memory in
977
795
  // the global context. Note: We have to mark the global context here
978
796
  // since the GenerateThrowOutOfMemory stub cannot make a RuntimeCall to
979
797
  // set it.
980
798
  bool external_caught = IsExternallyCaught();
981
- thread_local_.external_caught_exception_ = external_caught;
982
- HandleScope scope;
983
- if (thread_local_.pending_exception_ == Failure::OutOfMemoryException()) {
799
+ thread_local_top()->external_caught_exception_ = external_caught;
800
+ HandleScope scope(this);
801
+ if (thread_local_top()->pending_exception_ ==
802
+ Failure::OutOfMemoryException()) {
984
803
  context()->mark_out_of_memory();
985
- } else if (thread_local_.pending_exception_ ==
986
- Heap::termination_exception()) {
804
+ } else if (thread_local_top()->pending_exception_ ==
805
+ heap_.termination_exception()) {
987
806
  if (external_caught) {
988
807
  try_catch_handler()->can_continue_ = false;
989
- try_catch_handler()->exception_ = Heap::null_value();
808
+ try_catch_handler()->exception_ = heap_.null_value();
990
809
  }
991
810
  } else {
992
811
  // At this point all non-object (failure) exceptions have
993
812
  // been dealt with so this shouldn't fail.
994
813
  Object* pending_exception_object = pending_exception()->ToObjectUnchecked();
995
814
  Handle<Object> exception(pending_exception_object);
996
- thread_local_.external_caught_exception_ = false;
815
+ thread_local_top()->external_caught_exception_ = false;
997
816
  if (external_caught) {
998
817
  try_catch_handler()->can_continue_ = true;
999
- try_catch_handler()->exception_ = thread_local_.pending_exception_;
1000
- if (!thread_local_.pending_message_obj_->IsTheHole()) {
1001
- try_catch_handler()->message_ = thread_local_.pending_message_obj_;
818
+ try_catch_handler()->exception_ = thread_local_top()->pending_exception_;
819
+ if (!thread_local_top()->pending_message_obj_->IsTheHole()) {
820
+ try_catch_handler()->message_ =
821
+ thread_local_top()->pending_message_obj_;
1002
822
  }
1003
823
  }
1004
- if (thread_local_.has_pending_message_) {
1005
- thread_local_.has_pending_message_ = false;
1006
- if (thread_local_.pending_message_ != NULL) {
1007
- MessageHandler::ReportMessage(thread_local_.pending_message_);
1008
- } else if (!thread_local_.pending_message_obj_->IsTheHole()) {
1009
- Handle<Object> message_obj(thread_local_.pending_message_obj_);
1010
- if (thread_local_.pending_message_script_ != NULL) {
1011
- Handle<Script> script(thread_local_.pending_message_script_);
1012
- int start_pos = thread_local_.pending_message_start_pos_;
1013
- int end_pos = thread_local_.pending_message_end_pos_;
824
+ if (thread_local_top()->has_pending_message_) {
825
+ thread_local_top()->has_pending_message_ = false;
826
+ if (thread_local_top()->pending_message_ != NULL) {
827
+ MessageHandler::ReportMessage(thread_local_top()->pending_message_);
828
+ } else if (!thread_local_top()->pending_message_obj_->IsTheHole()) {
829
+ Handle<Object> message_obj(thread_local_top()->pending_message_obj_);
830
+ if (thread_local_top()->pending_message_script_ != NULL) {
831
+ Handle<Script> script(thread_local_top()->pending_message_script_);
832
+ int start_pos = thread_local_top()->pending_message_start_pos_;
833
+ int end_pos = thread_local_top()->pending_message_end_pos_;
1014
834
  MessageLocation location(script, start_pos, end_pos);
1015
835
  MessageHandler::ReportMessage(&location, message_obj);
1016
836
  } else {
@@ -1018,40 +838,40 @@ void Top::ReportPendingMessages() {
1018
838
  }
1019
839
  }
1020
840
  }
1021
- thread_local_.external_caught_exception_ = external_caught;
841
+ thread_local_top()->external_caught_exception_ = external_caught;
1022
842
  set_pending_exception(*exception);
1023
843
  }
1024
844
  clear_pending_message();
1025
845
  }
1026
846
 
1027
847
 
1028
- void Top::TraceException(bool flag) {
1029
- FLAG_trace_exception = flag;
848
+ void Isolate::TraceException(bool flag) {
849
+ FLAG_trace_exception = flag; // TODO(isolates): This is an unfortunate use.
1030
850
  }
1031
851
 
1032
852
 
1033
- bool Top::OptionalRescheduleException(bool is_bottom_call) {
853
+ bool Isolate::OptionalRescheduleException(bool is_bottom_call) {
1034
854
  // Allways reschedule out of memory exceptions.
1035
855
  if (!is_out_of_memory()) {
1036
856
  bool is_termination_exception =
1037
- pending_exception() == Heap::termination_exception();
857
+ pending_exception() == heap_.termination_exception();
1038
858
 
1039
859
  // Do not reschedule the exception if this is the bottom call.
1040
860
  bool clear_exception = is_bottom_call;
1041
861
 
1042
862
  if (is_termination_exception) {
1043
863
  if (is_bottom_call) {
1044
- thread_local_.external_caught_exception_ = false;
864
+ thread_local_top()->external_caught_exception_ = false;
1045
865
  clear_pending_exception();
1046
866
  return false;
1047
867
  }
1048
- } else if (thread_local_.external_caught_exception_) {
868
+ } else if (thread_local_top()->external_caught_exception_) {
1049
869
  // If the exception is externally caught, clear it if there are no
1050
870
  // JavaScript frames on the way to the C++ frame that has the
1051
871
  // external handler.
1052
- ASSERT(thread_local_.try_catch_handler_address() != NULL);
872
+ ASSERT(thread_local_top()->try_catch_handler_address() != NULL);
1053
873
  Address external_handler_address =
1054
- thread_local_.try_catch_handler_address();
874
+ thread_local_top()->try_catch_handler_address();
1055
875
  JavaScriptFrameIterator it;
1056
876
  if (it.done() || (it.frame()->sp() > external_handler_address)) {
1057
877
  clear_exception = true;
@@ -1060,30 +880,30 @@ bool Top::OptionalRescheduleException(bool is_bottom_call) {
1060
880
 
1061
881
  // Clear the exception if needed.
1062
882
  if (clear_exception) {
1063
- thread_local_.external_caught_exception_ = false;
883
+ thread_local_top()->external_caught_exception_ = false;
1064
884
  clear_pending_exception();
1065
885
  return false;
1066
886
  }
1067
887
  }
1068
888
 
1069
889
  // Reschedule the exception.
1070
- thread_local_.scheduled_exception_ = pending_exception();
890
+ thread_local_top()->scheduled_exception_ = pending_exception();
1071
891
  clear_pending_exception();
1072
892
  return true;
1073
893
  }
1074
894
 
1075
895
 
1076
- void Top::SetCaptureStackTraceForUncaughtExceptions(
896
+ void Isolate::SetCaptureStackTraceForUncaughtExceptions(
1077
897
  bool capture,
1078
898
  int frame_limit,
1079
899
  StackTrace::StackTraceOptions options) {
1080
- capture_stack_trace_for_uncaught_exceptions = capture;
1081
- stack_trace_for_uncaught_exceptions_frame_limit = frame_limit;
1082
- stack_trace_for_uncaught_exceptions_options = options;
900
+ capture_stack_trace_for_uncaught_exceptions_ = capture;
901
+ stack_trace_for_uncaught_exceptions_frame_limit_ = frame_limit;
902
+ stack_trace_for_uncaught_exceptions_options_ = options;
1083
903
  }
1084
904
 
1085
905
 
1086
- bool Top::is_out_of_memory() {
906
+ bool Isolate::is_out_of_memory() {
1087
907
  if (has_pending_exception()) {
1088
908
  MaybeObject* e = pending_exception();
1089
909
  if (e->IsFailure() && Failure::cast(e)->IsOutOfMemoryException()) {
@@ -1100,20 +920,20 @@ bool Top::is_out_of_memory() {
1100
920
  }
1101
921
 
1102
922
 
1103
- Handle<Context> Top::global_context() {
1104
- GlobalObject* global = thread_local_.context_->global();
923
+ Handle<Context> Isolate::global_context() {
924
+ GlobalObject* global = thread_local_top()->context_->global();
1105
925
  return Handle<Context>(global->global_context());
1106
926
  }
1107
927
 
1108
928
 
1109
- Handle<Context> Top::GetCallingGlobalContext() {
929
+ Handle<Context> Isolate::GetCallingGlobalContext() {
1110
930
  JavaScriptFrameIterator it;
1111
931
  #ifdef ENABLE_DEBUGGER_SUPPORT
1112
- if (Debug::InDebugger()) {
932
+ if (debug_->InDebugger()) {
1113
933
  while (!it.done()) {
1114
934
  JavaScriptFrame* frame = it.frame();
1115
935
  Context* context = Context::cast(frame->context());
1116
- if (context->global_context() == *Debug::debug_context()) {
936
+ if (context->global_context() == *debug_->debug_context()) {
1117
937
  it.Advance();
1118
938
  } else {
1119
939
  break;
@@ -1128,25 +948,33 @@ Handle<Context> Top::GetCallingGlobalContext() {
1128
948
  }
1129
949
 
1130
950
 
1131
- char* Top::ArchiveThread(char* to) {
1132
- memcpy(to, reinterpret_cast<char*>(&thread_local_), sizeof(thread_local_));
951
+ char* Isolate::ArchiveThread(char* to) {
952
+ if (RuntimeProfiler::IsEnabled() && current_vm_state() == JS) {
953
+ RuntimeProfiler::IsolateExitedJS(this);
954
+ }
955
+ memcpy(to, reinterpret_cast<char*>(thread_local_top()),
956
+ sizeof(ThreadLocalTop));
1133
957
  InitializeThreadLocal();
1134
- return to + sizeof(thread_local_);
958
+ return to + sizeof(ThreadLocalTop);
1135
959
  }
1136
960
 
1137
961
 
1138
- char* Top::RestoreThread(char* from) {
1139
- memcpy(reinterpret_cast<char*>(&thread_local_), from, sizeof(thread_local_));
962
+ char* Isolate::RestoreThread(char* from) {
963
+ memcpy(reinterpret_cast<char*>(thread_local_top()), from,
964
+ sizeof(ThreadLocalTop));
1140
965
  // This might be just paranoia, but it seems to be needed in case a
1141
966
  // thread_local_ is restored on a separate OS thread.
1142
967
  #ifdef USE_SIMULATOR
1143
968
  #ifdef V8_TARGET_ARCH_ARM
1144
- thread_local_.simulator_ = Simulator::current();
969
+ thread_local_top()->simulator_ = Simulator::current(this);
1145
970
  #elif V8_TARGET_ARCH_MIPS
1146
- thread_local_.simulator_ = assembler::mips::Simulator::current();
971
+ thread_local_top()->simulator_ = Simulator::current(this);
1147
972
  #endif
1148
973
  #endif
1149
- return from + sizeof(thread_local_);
974
+ if (RuntimeProfiler::IsEnabled() && current_vm_state() == JS) {
975
+ RuntimeProfiler::IsolateEnteredJS(this);
976
+ }
977
+ return from + sizeof(ThreadLocalTop);
1150
978
  }
1151
979
 
1152
980
  } } // namespace v8::internal