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
@@ -70,7 +70,7 @@ void Builtins::Generate_Adaptor(MacroAssembler* masm,
70
70
  // JumpToExternalReference expects eax to contain the number of arguments
71
71
  // including the receiver and the extra arguments.
72
72
  __ add(Operand(eax), Immediate(num_extra_args + 1));
73
- __ JumpToExternalReference(ExternalReference(id));
73
+ __ JumpToExternalReference(ExternalReference(id, masm->isolate()));
74
74
  }
75
75
 
76
76
 
@@ -100,8 +100,9 @@ void Builtins::Generate_JSConstructCall(MacroAssembler* masm) {
100
100
  // Set expected number of arguments to zero (not changing eax).
101
101
  __ Set(ebx, Immediate(0));
102
102
  __ GetBuiltinEntry(edx, Builtins::CALL_NON_FUNCTION_AS_CONSTRUCTOR);
103
- __ jmp(Handle<Code>(builtin(ArgumentsAdaptorTrampoline)),
104
- RelocInfo::CODE_TARGET);
103
+ Handle<Code> arguments_adaptor =
104
+ masm->isolate()->builtins()->ArgumentsAdaptorTrampoline();
105
+ __ jmp(arguments_adaptor, RelocInfo::CODE_TARGET);
105
106
  }
106
107
 
107
108
 
@@ -128,7 +129,7 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
128
129
  Label undo_allocation;
129
130
  #ifdef ENABLE_DEBUGGER_SUPPORT
130
131
  ExternalReference debug_step_in_fp =
131
- ExternalReference::debug_step_in_fp_address();
132
+ ExternalReference::debug_step_in_fp_address(masm->isolate());
132
133
  __ cmp(Operand::StaticVariable(debug_step_in_fp), Immediate(0));
133
134
  __ j(not_equal, &rt_call);
134
135
  #endif
@@ -184,7 +185,8 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
184
185
  // ebx: JSObject
185
186
  // edi: start of next object
186
187
  __ mov(Operand(ebx, JSObject::kMapOffset), eax);
187
- __ mov(ecx, Factory::empty_fixed_array());
188
+ Factory* factory = masm->isolate()->factory();
189
+ __ mov(ecx, factory->empty_fixed_array());
188
190
  __ mov(Operand(ebx, JSObject::kPropertiesOffset), ecx);
189
191
  __ mov(Operand(ebx, JSObject::kElementsOffset), ecx);
190
192
  // Set extra fields in the newly allocated object.
@@ -194,9 +196,9 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
194
196
  { Label loop, entry;
195
197
  // To allow for truncation.
196
198
  if (count_constructions) {
197
- __ mov(edx, Factory::one_pointer_filler_map());
199
+ __ mov(edx, factory->one_pointer_filler_map());
198
200
  } else {
199
- __ mov(edx, Factory::undefined_value());
201
+ __ mov(edx, factory->undefined_value());
200
202
  }
201
203
  __ lea(ecx, Operand(ebx, JSObject::kHeaderSize));
202
204
  __ jmp(&entry);
@@ -252,7 +254,7 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
252
254
  // edi: FixedArray
253
255
  // edx: number of elements
254
256
  // ecx: start of next object
255
- __ mov(eax, Factory::fixed_array_map());
257
+ __ mov(eax, factory->fixed_array_map());
256
258
  __ mov(Operand(edi, FixedArray::kMapOffset), eax); // setup the map
257
259
  __ SmiTag(edx);
258
260
  __ mov(Operand(edi, FixedArray::kLengthOffset), edx); // and length
@@ -262,7 +264,7 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
262
264
  // edi: FixedArray
263
265
  // ecx: start of next object
264
266
  { Label loop, entry;
265
- __ mov(edx, Factory::undefined_value());
267
+ __ mov(edx, factory->undefined_value());
266
268
  __ lea(eax, Operand(edi, FixedArray::kHeaderSize));
267
269
  __ jmp(&entry);
268
270
  __ bind(&loop);
@@ -334,8 +336,8 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
334
336
  // Call the function.
335
337
  if (is_api_function) {
336
338
  __ mov(esi, FieldOperand(edi, JSFunction::kContextOffset));
337
- Handle<Code> code = Handle<Code>(
338
- Builtins::builtin(Builtins::HandleApiCallConstruct));
339
+ Handle<Code> code =
340
+ masm->isolate()->builtins()->HandleApiCallConstruct();
339
341
  ParameterCount expected(0);
340
342
  __ InvokeCode(code, expected, expected,
341
343
  RelocInfo::CODE_TARGET, CALL_FUNCTION);
@@ -376,7 +378,7 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
376
378
  __ pop(ecx);
377
379
  __ lea(esp, Operand(esp, ebx, times_2, 1 * kPointerSize)); // 1 ~ receiver
378
380
  __ push(ecx);
379
- __ IncrementCounter(&Counters::constructed_objects, 1);
381
+ __ IncrementCounter(masm->isolate()->counters()->constructed_objects(), 1);
380
382
  __ ret(0);
381
383
  }
382
384
 
@@ -436,7 +438,7 @@ static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm,
436
438
 
437
439
  // Invoke the code.
438
440
  if (is_construct) {
439
- __ call(Handle<Code>(Builtins::builtin(Builtins::JSConstructCall)),
441
+ __ call(masm->isolate()->builtins()->JSConstructCall(),
440
442
  RelocInfo::CODE_TARGET);
441
443
  } else {
442
444
  ParameterCount actual(eax);
@@ -561,12 +563,14 @@ void Builtins::Generate_NotifyOSR(MacroAssembler* masm) {
561
563
 
562
564
 
563
565
  void Builtins::Generate_FunctionCall(MacroAssembler* masm) {
566
+ Factory* factory = masm->isolate()->factory();
567
+
564
568
  // 1. Make sure we have at least one argument.
565
569
  { Label done;
566
570
  __ test(eax, Operand(eax));
567
571
  __ j(not_zero, &done, taken);
568
572
  __ pop(ebx);
569
- __ push(Immediate(Factory::undefined_value()));
573
+ __ push(Immediate(factory->undefined_value()));
570
574
  __ push(ebx);
571
575
  __ inc(eax);
572
576
  __ bind(&done);
@@ -600,9 +604,9 @@ void Builtins::Generate_FunctionCall(MacroAssembler* masm) {
600
604
  __ test(ebx, Immediate(kSmiTagMask));
601
605
  __ j(zero, &convert_to_object);
602
606
 
603
- __ cmp(ebx, Factory::null_value());
607
+ __ cmp(ebx, factory->null_value());
604
608
  __ j(equal, &use_global_receiver);
605
- __ cmp(ebx, Factory::undefined_value());
609
+ __ cmp(ebx, factory->undefined_value());
606
610
  __ j(equal, &use_global_receiver);
607
611
 
608
612
  // We don't use IsObjectJSObjectType here because we jump on success.
@@ -674,7 +678,7 @@ void Builtins::Generate_FunctionCall(MacroAssembler* masm) {
674
678
  __ j(not_zero, &function, taken);
675
679
  __ Set(ebx, Immediate(0));
676
680
  __ GetBuiltinEntry(edx, Builtins::CALL_NON_FUNCTION);
677
- __ jmp(Handle<Code>(builtin(ArgumentsAdaptorTrampoline)),
681
+ __ jmp(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(),
678
682
  RelocInfo::CODE_TARGET);
679
683
  __ bind(&function);
680
684
  }
@@ -688,7 +692,8 @@ void Builtins::Generate_FunctionCall(MacroAssembler* masm) {
688
692
  __ mov(edx, FieldOperand(edi, JSFunction::kCodeEntryOffset));
689
693
  __ SmiUntag(ebx);
690
694
  __ cmp(eax, Operand(ebx));
691
- __ j(not_equal, Handle<Code>(builtin(ArgumentsAdaptorTrampoline)));
695
+ __ j(not_equal,
696
+ masm->isolate()->builtins()->ArgumentsAdaptorTrampoline());
692
697
 
693
698
  ParameterCount expected(0);
694
699
  __ InvokeCode(Operand(edx), expected, expected, JUMP_FUNCTION);
@@ -707,7 +712,7 @@ void Builtins::Generate_FunctionApply(MacroAssembler* masm) {
707
712
  // limit" is checked.
708
713
  Label okay;
709
714
  ExternalReference real_stack_limit =
710
- ExternalReference::address_of_real_stack_limit();
715
+ ExternalReference::address_of_real_stack_limit(masm->isolate());
711
716
  __ mov(edi, Operand::StaticVariable(real_stack_limit));
712
717
  // Make ecx the space we have left. The stack might already be overflowed
713
718
  // here which will cause ecx to become negative.
@@ -753,9 +758,10 @@ void Builtins::Generate_FunctionApply(MacroAssembler* masm) {
753
758
  // Compute the receiver in non-strict mode.
754
759
  __ test(ebx, Immediate(kSmiTagMask));
755
760
  __ j(zero, &call_to_object);
756
- __ cmp(ebx, Factory::null_value());
761
+ Factory* factory = masm->isolate()->factory();
762
+ __ cmp(ebx, factory->null_value());
757
763
  __ j(equal, &use_global_receiver);
758
- __ cmp(ebx, Factory::undefined_value());
764
+ __ cmp(ebx, factory->undefined_value());
759
765
  __ j(equal, &use_global_receiver);
760
766
 
761
767
  // If given receiver is already a JavaScript object then there's no
@@ -795,7 +801,7 @@ void Builtins::Generate_FunctionApply(MacroAssembler* masm) {
795
801
  __ mov(edx, Operand(ebp, 2 * kPointerSize)); // load arguments
796
802
 
797
803
  // Use inline caching to speed up access to arguments.
798
- Handle<Code> ic(Builtins::builtin(Builtins::KeyedLoadIC_Initialize));
804
+ Handle<Code> ic = masm->isolate()->builtins()->KeyedLoadIC_Initialize();
799
805
  __ call(ic, RelocInfo::CODE_TARGET);
800
806
  // It is important that we do not have a test instruction after the
801
807
  // call. A test instruction after the call is used to indicate that
@@ -866,8 +872,9 @@ static void AllocateEmptyJSArray(MacroAssembler* masm,
866
872
  // scratch1: initial map
867
873
  // scratch2: start of next object
868
874
  __ mov(FieldOperand(result, JSObject::kMapOffset), scratch1);
875
+ Factory* factory = masm->isolate()->factory();
869
876
  __ mov(FieldOperand(result, JSArray::kPropertiesOffset),
870
- Factory::empty_fixed_array());
877
+ factory->empty_fixed_array());
871
878
  // Field JSArray::kElementsOffset is initialized later.
872
879
  __ mov(FieldOperand(result, JSArray::kLengthOffset), Immediate(0));
873
880
 
@@ -875,7 +882,7 @@ static void AllocateEmptyJSArray(MacroAssembler* masm,
875
882
  // fixed array.
876
883
  if (initial_capacity == 0) {
877
884
  __ mov(FieldOperand(result, JSArray::kElementsOffset),
878
- Factory::empty_fixed_array());
885
+ factory->empty_fixed_array());
879
886
  return;
880
887
  }
881
888
 
@@ -892,7 +899,7 @@ static void AllocateEmptyJSArray(MacroAssembler* masm,
892
899
  // scratch1: elements array
893
900
  // scratch2: start of next object
894
901
  __ mov(FieldOperand(scratch1, FixedArray::kMapOffset),
895
- Factory::fixed_array_map());
902
+ factory->fixed_array_map());
896
903
  __ mov(FieldOperand(scratch1, FixedArray::kLengthOffset),
897
904
  Immediate(Smi::FromInt(initial_capacity)));
898
905
 
@@ -903,7 +910,7 @@ static void AllocateEmptyJSArray(MacroAssembler* masm,
903
910
  if (initial_capacity <= kLoopUnfoldLimit) {
904
911
  // Use a scratch register here to have only one reloc info when unfolding
905
912
  // the loop.
906
- __ mov(scratch3, Factory::the_hole_value());
913
+ __ mov(scratch3, factory->the_hole_value());
907
914
  for (int i = 0; i < initial_capacity; i++) {
908
915
  __ mov(FieldOperand(scratch1,
909
916
  FixedArray::kHeaderSize + i * kPointerSize),
@@ -913,7 +920,7 @@ static void AllocateEmptyJSArray(MacroAssembler* masm,
913
920
  Label loop, entry;
914
921
  __ jmp(&entry);
915
922
  __ bind(&loop);
916
- __ mov(Operand(scratch1, 0), Factory::the_hole_value());
923
+ __ mov(Operand(scratch1, 0), factory->the_hole_value());
917
924
  __ add(Operand(scratch1), Immediate(kPointerSize));
918
925
  __ bind(&entry);
919
926
  __ cmp(scratch1, Operand(scratch2));
@@ -968,7 +975,8 @@ static void AllocateJSArray(MacroAssembler* masm,
968
975
  // elements_array_end: start of next object
969
976
  // array_size: size of array (smi)
970
977
  __ mov(FieldOperand(result, JSObject::kMapOffset), elements_array);
971
- __ mov(elements_array, Factory::empty_fixed_array());
978
+ Factory* factory = masm->isolate()->factory();
979
+ __ mov(elements_array, factory->empty_fixed_array());
972
980
  __ mov(FieldOperand(result, JSArray::kPropertiesOffset), elements_array);
973
981
  // Field JSArray::kElementsOffset is initialized later.
974
982
  __ mov(FieldOperand(result, JSArray::kLengthOffset), array_size);
@@ -987,7 +995,7 @@ static void AllocateJSArray(MacroAssembler* masm,
987
995
  // elements_array_end: start of next object
988
996
  // array_size: size of array (smi)
989
997
  __ mov(FieldOperand(elements_array, FixedArray::kMapOffset),
990
- Factory::fixed_array_map());
998
+ factory->fixed_array_map());
991
999
  // For non-empty JSArrays the length of the FixedArray and the JSArray is the
992
1000
  // same.
993
1001
  __ mov(FieldOperand(elements_array, FixedArray::kLengthOffset), array_size);
@@ -999,7 +1007,7 @@ static void AllocateJSArray(MacroAssembler* masm,
999
1007
  __ SmiUntag(array_size);
1000
1008
  __ lea(edi, Operand(elements_array,
1001
1009
  FixedArray::kHeaderSize - kHeapObjectTag));
1002
- __ mov(eax, Factory::the_hole_value());
1010
+ __ mov(eax, factory->the_hole_value());
1003
1011
  __ cld();
1004
1012
  // Do not use rep stos when filling less than kRepStosThreshold
1005
1013
  // words.
@@ -1063,7 +1071,7 @@ static void ArrayNativeCode(MacroAssembler* masm,
1063
1071
  edi,
1064
1072
  kPreallocatedArrayElements,
1065
1073
  &prepare_generic_code_call);
1066
- __ IncrementCounter(&Counters::array_function_native, 1);
1074
+ __ IncrementCounter(masm->isolate()->counters()->array_function_native(), 1);
1067
1075
  __ pop(ebx);
1068
1076
  if (construct_call) {
1069
1077
  __ pop(edi);
@@ -1119,7 +1127,8 @@ static void ArrayNativeCode(MacroAssembler* masm,
1119
1127
  edi,
1120
1128
  true,
1121
1129
  &prepare_generic_code_call);
1122
- __ IncrementCounter(&Counters::array_function_native, 1);
1130
+ Counters* counters = masm->isolate()->counters();
1131
+ __ IncrementCounter(counters->array_function_native(), 1);
1123
1132
  __ mov(eax, ebx);
1124
1133
  __ pop(ebx);
1125
1134
  if (construct_call) {
@@ -1146,7 +1155,7 @@ static void ArrayNativeCode(MacroAssembler* masm,
1146
1155
  edi,
1147
1156
  false,
1148
1157
  &prepare_generic_code_call);
1149
- __ IncrementCounter(&Counters::array_function_native, 1);
1158
+ __ IncrementCounter(counters->array_function_native(), 1);
1150
1159
  __ mov(eax, ebx);
1151
1160
  __ pop(ebx);
1152
1161
  if (construct_call) {
@@ -1232,8 +1241,8 @@ void Builtins::Generate_ArrayCode(MacroAssembler* masm) {
1232
1241
  // Jump to the generic array code in case the specialized code cannot handle
1233
1242
  // the construction.
1234
1243
  __ bind(&generic_array_code);
1235
- Code* code = Builtins::builtin(Builtins::ArrayCodeGeneric);
1236
- Handle<Code> array_code(code);
1244
+ Handle<Code> array_code =
1245
+ masm->isolate()->builtins()->ArrayCodeGeneric();
1237
1246
  __ jmp(array_code, RelocInfo::CODE_TARGET);
1238
1247
  }
1239
1248
 
@@ -1248,11 +1257,9 @@ void Builtins::Generate_ArrayConstructCode(MacroAssembler* masm) {
1248
1257
  Label generic_constructor;
1249
1258
 
1250
1259
  if (FLAG_debug_code) {
1251
- // The array construct code is only set for the builtin Array function which
1252
- // does always have a map.
1253
- __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, ebx);
1254
- __ cmp(edi, Operand(ebx));
1255
- __ Assert(equal, "Unexpected Array function");
1260
+ // The array construct code is only set for the global and natives
1261
+ // builtin Array functions which always have maps.
1262
+
1256
1263
  // Initial map for the builtin Array function should be a map.
1257
1264
  __ mov(ebx, FieldOperand(edi, JSFunction::kPrototypeOrInitialMapOffset));
1258
1265
  // Will both indicate a NULL and a Smi.
@@ -1268,8 +1275,8 @@ void Builtins::Generate_ArrayConstructCode(MacroAssembler* masm) {
1268
1275
  // Jump to the generic construct code in case the specialized code cannot
1269
1276
  // handle the construction.
1270
1277
  __ bind(&generic_constructor);
1271
- Code* code = Builtins::builtin(Builtins::JSConstructStubGeneric);
1272
- Handle<Code> generic_construct_stub(code);
1278
+ Handle<Code> generic_construct_stub =
1279
+ masm->isolate()->builtins()->JSConstructStubGeneric();
1273
1280
  __ jmp(generic_construct_stub, RelocInfo::CODE_TARGET);
1274
1281
  }
1275
1282
 
@@ -1282,7 +1289,8 @@ void Builtins::Generate_StringConstructCode(MacroAssembler* masm) {
1282
1289
  // -- esp[(argc - n) * 4] : arg[n] (zero-based)
1283
1290
  // -- esp[(argc + 1) * 4] : receiver
1284
1291
  // -----------------------------------
1285
- __ IncrementCounter(&Counters::string_ctor_calls, 1);
1292
+ Counters* counters = masm->isolate()->counters();
1293
+ __ IncrementCounter(counters->string_ctor_calls(), 1);
1286
1294
 
1287
1295
  if (FLAG_debug_code) {
1288
1296
  __ LoadGlobalFunction(Context::STRING_FUNCTION_INDEX, ecx);
@@ -1311,7 +1319,7 @@ void Builtins::Generate_StringConstructCode(MacroAssembler* masm) {
1311
1319
  edx, // Scratch 2.
1312
1320
  false, // Input is known to be smi?
1313
1321
  &not_cached);
1314
- __ IncrementCounter(&Counters::string_ctor_cached_number, 1);
1322
+ __ IncrementCounter(counters->string_ctor_cached_number(), 1);
1315
1323
  __ bind(&argument_is_string);
1316
1324
  // ----------- S t a t e -------------
1317
1325
  // -- ebx : argument converted to string
@@ -1340,7 +1348,8 @@ void Builtins::Generate_StringConstructCode(MacroAssembler* masm) {
1340
1348
  __ mov(FieldOperand(eax, HeapObject::kMapOffset), ecx);
1341
1349
 
1342
1350
  // Set properties and elements.
1343
- __ Set(ecx, Immediate(Factory::empty_fixed_array()));
1351
+ Factory* factory = masm->isolate()->factory();
1352
+ __ Set(ecx, Immediate(factory->empty_fixed_array()));
1344
1353
  __ mov(FieldOperand(eax, JSObject::kPropertiesOffset), ecx);
1345
1354
  __ mov(FieldOperand(eax, JSObject::kElementsOffset), ecx);
1346
1355
 
@@ -1363,12 +1372,12 @@ void Builtins::Generate_StringConstructCode(MacroAssembler* masm) {
1363
1372
  Condition is_string = masm->IsObjectStringType(eax, ebx, ecx);
1364
1373
  __ j(NegateCondition(is_string), &convert_argument);
1365
1374
  __ mov(ebx, eax);
1366
- __ IncrementCounter(&Counters::string_ctor_string_value, 1);
1375
+ __ IncrementCounter(counters->string_ctor_string_value(), 1);
1367
1376
  __ jmp(&argument_is_string);
1368
1377
 
1369
1378
  // Invoke the conversion builtin and put the result into ebx.
1370
1379
  __ bind(&convert_argument);
1371
- __ IncrementCounter(&Counters::string_ctor_conversions, 1);
1380
+ __ IncrementCounter(counters->string_ctor_conversions(), 1);
1372
1381
  __ EnterInternalFrame();
1373
1382
  __ push(edi); // Preserve the function.
1374
1383
  __ push(eax);
@@ -1381,7 +1390,7 @@ void Builtins::Generate_StringConstructCode(MacroAssembler* masm) {
1381
1390
  // Load the empty string into ebx, remove the receiver from the
1382
1391
  // stack, and jump back to the case where the argument is a string.
1383
1392
  __ bind(&no_arguments);
1384
- __ Set(ebx, Immediate(Factory::empty_string()));
1393
+ __ Set(ebx, Immediate(factory->empty_string()));
1385
1394
  __ pop(ecx);
1386
1395
  __ lea(esp, Operand(esp, kPointerSize));
1387
1396
  __ push(ecx);
@@ -1390,7 +1399,7 @@ void Builtins::Generate_StringConstructCode(MacroAssembler* masm) {
1390
1399
  // At this point the argument is already a string. Call runtime to
1391
1400
  // create a string wrapper.
1392
1401
  __ bind(&gc_required);
1393
- __ IncrementCounter(&Counters::string_ctor_gc_required, 1);
1402
+ __ IncrementCounter(counters->string_ctor_gc_required(), 1);
1394
1403
  __ EnterInternalFrame();
1395
1404
  __ push(ebx);
1396
1405
  __ CallRuntime(Runtime::kNewStringWrapper, 1);
@@ -1441,7 +1450,7 @@ void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) {
1441
1450
  // -----------------------------------
1442
1451
 
1443
1452
  Label invoke, dont_adapt_arguments;
1444
- __ IncrementCounter(&Counters::arguments_adaptors, 1);
1453
+ __ IncrementCounter(masm->isolate()->counters()->arguments_adaptors(), 1);
1445
1454
 
1446
1455
  Label enough, too_few;
1447
1456
  __ cmp(eax, Operand(ebx));
@@ -1489,7 +1498,7 @@ void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) {
1489
1498
  Label fill;
1490
1499
  __ bind(&fill);
1491
1500
  __ inc(ecx);
1492
- __ push(Immediate(Factory::undefined_value()));
1501
+ __ push(Immediate(masm->isolate()->factory()->undefined_value()));
1493
1502
  __ cmp(ecx, Operand(ebx));
1494
1503
  __ j(less, &fill);
1495
1504
 
@@ -1514,10 +1523,7 @@ void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) {
1514
1523
 
1515
1524
 
1516
1525
  void Builtins::Generate_OnStackReplacement(MacroAssembler* masm) {
1517
- // We shouldn't be performing on-stack replacement in the first
1518
- // place if the CPU features we need for the optimized Crankshaft
1519
- // code aren't supported.
1520
- CpuFeatures::Probe(false);
1526
+ CpuFeatures::TryForceFeatureScope scope(SSE2);
1521
1527
  if (!CpuFeatures::IsSupported(SSE2)) {
1522
1528
  __ Abort("Unreachable code: Cannot optimize without SSE2 support.");
1523
1529
  return;
@@ -1562,7 +1568,7 @@ void Builtins::Generate_OnStackReplacement(MacroAssembler* masm) {
1562
1568
  __ bind(&stack_check);
1563
1569
  NearLabel ok;
1564
1570
  ExternalReference stack_limit =
1565
- ExternalReference::address_of_stack_limit();
1571
+ ExternalReference::address_of_stack_limit(masm->isolate());
1566
1572
  __ cmp(esp, Operand::StaticVariable(stack_limit));
1567
1573
  __ j(above_equal, &ok, taken);
1568
1574
  StackCheckStub stub;
@@ -1584,7 +1590,7 @@ void Builtins::Generate_OnStackReplacement(MacroAssembler* masm) {
1584
1590
 
1585
1591
 
1586
1592
  #undef __
1587
-
1588
- } } // namespace v8::internal
1593
+ }
1594
+ } // namespace v8::internal
1589
1595
 
1590
1596
  #endif // V8_TARGET_ARCH_IA32
@@ -32,6 +32,7 @@
32
32
  #include "code-stubs.h"
33
33
  #include "bootstrapper.h"
34
34
  #include "jsregexp.h"
35
+ #include "isolate.h"
35
36
  #include "regexp-macro-assembler.h"
36
37
 
37
38
  namespace v8 {
@@ -48,7 +49,8 @@ void ToNumberStub::Generate(MacroAssembler* masm) {
48
49
 
49
50
  __ bind(&check_heap_number);
50
51
  __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset));
51
- __ cmp(Operand(ebx), Immediate(Factory::heap_number_map()));
52
+ Factory* factory = masm->isolate()->factory();
53
+ __ cmp(Operand(ebx), Immediate(factory->heap_number_map()));
52
54
  __ j(not_equal, &call_builtin);
53
55
  __ ret(0);
54
56
 
@@ -69,25 +71,30 @@ void FastNewClosureStub::Generate(MacroAssembler* masm) {
69
71
  // Get the function info from the stack.
70
72
  __ mov(edx, Operand(esp, 1 * kPointerSize));
71
73
 
74
+ int map_index = strict_mode_ == kStrictMode
75
+ ? Context::STRICT_MODE_FUNCTION_MAP_INDEX
76
+ : Context::FUNCTION_MAP_INDEX;
77
+
72
78
  // Compute the function map in the current global context and set that
73
79
  // as the map of the allocated object.
74
80
  __ mov(ecx, Operand(esi, Context::SlotOffset(Context::GLOBAL_INDEX)));
75
81
  __ mov(ecx, FieldOperand(ecx, GlobalObject::kGlobalContextOffset));
76
- __ mov(ecx, Operand(ecx, Context::SlotOffset(Context::FUNCTION_MAP_INDEX)));
82
+ __ mov(ecx, Operand(ecx, Context::SlotOffset(map_index)));
77
83
  __ mov(FieldOperand(eax, JSObject::kMapOffset), ecx);
78
84
 
79
85
  // Initialize the rest of the function. We don't have to update the
80
86
  // write barrier because the allocated object is in new space.
81
- __ mov(ebx, Immediate(Factory::empty_fixed_array()));
87
+ Factory* factory = masm->isolate()->factory();
88
+ __ mov(ebx, Immediate(factory->empty_fixed_array()));
82
89
  __ mov(FieldOperand(eax, JSObject::kPropertiesOffset), ebx);
83
90
  __ mov(FieldOperand(eax, JSObject::kElementsOffset), ebx);
84
91
  __ mov(FieldOperand(eax, JSFunction::kPrototypeOrInitialMapOffset),
85
- Immediate(Factory::the_hole_value()));
92
+ Immediate(factory->the_hole_value()));
86
93
  __ mov(FieldOperand(eax, JSFunction::kSharedFunctionInfoOffset), edx);
87
94
  __ mov(FieldOperand(eax, JSFunction::kContextOffset), esi);
88
95
  __ mov(FieldOperand(eax, JSFunction::kLiteralsOffset), ebx);
89
96
  __ mov(FieldOperand(eax, JSFunction::kNextFunctionLinkOffset),
90
- Immediate(Factory::undefined_value()));
97
+ Immediate(factory->undefined_value()));
91
98
 
92
99
  // Initialize the code pointer in the function to be the one
93
100
  // found in the shared function info object.
@@ -104,7 +111,7 @@ void FastNewClosureStub::Generate(MacroAssembler* masm) {
104
111
  __ pop(edx);
105
112
  __ push(esi);
106
113
  __ push(edx);
107
- __ push(Immediate(Factory::false_value()));
114
+ __ push(Immediate(factory->false_value()));
108
115
  __ push(ecx); // Restore return address.
109
116
  __ TailCallRuntime(Runtime::kNewClosure, 3, 1);
110
117
  }
@@ -121,7 +128,8 @@ void FastNewContextStub::Generate(MacroAssembler* masm) {
121
128
  __ mov(ecx, Operand(esp, 1 * kPointerSize));
122
129
 
123
130
  // Setup the object header.
124
- __ mov(FieldOperand(eax, HeapObject::kMapOffset), Factory::context_map());
131
+ Factory* factory = masm->isolate()->factory();
132
+ __ mov(FieldOperand(eax, HeapObject::kMapOffset), factory->context_map());
125
133
  __ mov(FieldOperand(eax, Context::kLengthOffset),
126
134
  Immediate(Smi::FromInt(length)));
127
135
 
@@ -140,7 +148,7 @@ void FastNewContextStub::Generate(MacroAssembler* masm) {
140
148
  __ mov(Operand(eax, Context::SlotOffset(Context::GLOBAL_INDEX)), ebx);
141
149
 
142
150
  // Initialize the rest of the slots to undefined.
143
- __ mov(ebx, Factory::undefined_value());
151
+ __ mov(ebx, factory->undefined_value());
144
152
  for (int i = Context::MIN_CONTEXT_SLOTS; i < length; i++) {
145
153
  __ mov(Operand(eax, Context::SlotOffset(i)), ebx);
146
154
  }
@@ -176,7 +184,8 @@ void FastCloneShallowArrayStub::Generate(MacroAssembler* masm) {
176
184
  STATIC_ASSERT(kSmiTag == 0);
177
185
  __ mov(ecx, FieldOperand(ecx, eax, times_half_pointer_size,
178
186
  FixedArray::kHeaderSize));
179
- __ cmp(ecx, Factory::undefined_value());
187
+ Factory* factory = masm->isolate()->factory();
188
+ __ cmp(ecx, factory->undefined_value());
180
189
  __ j(equal, &slow_case);
181
190
 
182
191
  if (FLAG_debug_code) {
@@ -184,11 +193,11 @@ void FastCloneShallowArrayStub::Generate(MacroAssembler* masm) {
184
193
  Handle<Map> expected_map;
185
194
  if (mode_ == CLONE_ELEMENTS) {
186
195
  message = "Expected (writable) fixed array";
187
- expected_map = Factory::fixed_array_map();
196
+ expected_map = factory->fixed_array_map();
188
197
  } else {
189
198
  ASSERT(mode_ == COPY_ON_WRITE_ELEMENTS);
190
199
  message = "Expected copy-on-write fixed array";
191
- expected_map = Factory::fixed_cow_array_map();
200
+ expected_map = factory->fixed_cow_array_map();
192
201
  }
193
202
  __ push(ecx);
194
203
  __ mov(ecx, FieldOperand(ecx, JSArray::kElementsOffset));
@@ -237,7 +246,8 @@ void ToBooleanStub::Generate(MacroAssembler* masm) {
237
246
  __ mov(eax, Operand(esp, 1 * kPointerSize));
238
247
 
239
248
  // 'null' => false.
240
- __ cmp(eax, Factory::null_value());
249
+ Factory* factory = masm->isolate()->factory();
250
+ __ cmp(eax, factory->null_value());
241
251
  __ j(equal, &false_result);
242
252
 
243
253
  // Get the map and type of the heap object.
@@ -263,7 +273,7 @@ void ToBooleanStub::Generate(MacroAssembler* masm) {
263
273
 
264
274
  __ bind(&not_string);
265
275
  // HeapNumber => false iff +0, -0, or NaN.
266
- __ cmp(edx, Factory::heap_number_map());
276
+ __ cmp(edx, factory->heap_number_map());
267
277
  __ j(not_equal, &true_result);
268
278
  __ fldz();
269
279
  __ fld_d(FieldOperand(eax, HeapNumber::kValueOffset));
@@ -284,7 +294,8 @@ void ToBooleanStub::Generate(MacroAssembler* masm) {
284
294
  const char* GenericBinaryOpStub::GetName() {
285
295
  if (name_ != NULL) return name_;
286
296
  const int kMaxNameLength = 100;
287
- name_ = Bootstrapper::AllocateAutoDeletedArray(kMaxNameLength);
297
+ name_ = Isolate::Current()->bootstrapper()->AllocateAutoDeletedArray(
298
+ kMaxNameLength);
288
299
  if (name_ == NULL) return "OOM";
289
300
  const char* op_name = Token::Name(op_);
290
301
  const char* overwrite_name;
@@ -358,7 +369,8 @@ void GenericBinaryOpStub::GenerateCall(
358
369
 
359
370
  // Update flags to indicate that arguments are in registers.
360
371
  SetArgsInRegisters();
361
- __ IncrementCounter(&Counters::generic_binary_stub_calls_regs, 1);
372
+ __ IncrementCounter(
373
+ masm->isolate()->counters()->generic_binary_stub_calls_regs(), 1);
362
374
  }
363
375
 
364
376
  // Call the stub.
@@ -394,7 +406,8 @@ void GenericBinaryOpStub::GenerateCall(
394
406
 
395
407
  // Update flags to indicate that arguments are in registers.
396
408
  SetArgsInRegisters();
397
- __ IncrementCounter(&Counters::generic_binary_stub_calls_regs, 1);
409
+ __ IncrementCounter(
410
+ masm->isolate()->counters()->generic_binary_stub_calls_regs(), 1);
398
411
  }
399
412
 
400
413
  // Call the stub.
@@ -429,7 +442,8 @@ void GenericBinaryOpStub::GenerateCall(
429
442
  }
430
443
  // Update flags to indicate that arguments are in registers.
431
444
  SetArgsInRegisters();
432
- __ IncrementCounter(&Counters::generic_binary_stub_calls_regs, 1);
445
+ Counters* counters = masm->isolate()->counters();
446
+ __ IncrementCounter(counters->generic_binary_stub_calls_regs(), 1);
433
447
  }
434
448
 
435
449
  // Call the stub.
@@ -872,7 +886,8 @@ void GenericBinaryOpStub::GenerateSmiCode(MacroAssembler* masm, Label* slow) {
872
886
  void GenericBinaryOpStub::Generate(MacroAssembler* masm) {
873
887
  Label call_runtime;
874
888
 
875
- __ IncrementCounter(&Counters::generic_binary_stub_calls, 1);
889
+ Counters* counters = masm->isolate()->counters();
890
+ __ IncrementCounter(counters->generic_binary_stub_calls(), 1);
876
891
 
877
892
  if (runtime_operands_type_ == BinaryOpIC::UNINIT_OR_SMI) {
878
893
  Label slow;
@@ -1263,7 +1278,7 @@ void GenericBinaryOpStub::GenerateTypeTransition(MacroAssembler* masm) {
1263
1278
  // Patch the caller to an appropriate specialized stub and return the
1264
1279
  // operation result to the caller of the stub.
1265
1280
  __ TailCallExternalReference(
1266
- ExternalReference(IC_Utility(IC::kBinaryOp_Patch)),
1281
+ ExternalReference(IC_Utility(IC::kBinaryOp_Patch), masm->isolate()),
1267
1282
  5,
1268
1283
  1);
1269
1284
  }
@@ -1299,7 +1314,8 @@ void TypeRecordingBinaryOpStub::GenerateTypeTransition(MacroAssembler* masm) {
1299
1314
  // Patch the caller to an appropriate specialized stub and return the
1300
1315
  // operation result to the caller of the stub.
1301
1316
  __ TailCallExternalReference(
1302
- ExternalReference(IC_Utility(IC::kTypeRecordingBinaryOp_Patch)),
1317
+ ExternalReference(IC_Utility(IC::kTypeRecordingBinaryOp_Patch),
1318
+ masm->isolate()),
1303
1319
  5,
1304
1320
  1);
1305
1321
  }
@@ -1322,7 +1338,8 @@ void TypeRecordingBinaryOpStub::GenerateTypeTransitionWithSavedArgs(
1322
1338
  // Patch the caller to an appropriate specialized stub and return the
1323
1339
  // operation result to the caller of the stub.
1324
1340
  __ TailCallExternalReference(
1325
- ExternalReference(IC_Utility(IC::kTypeRecordingBinaryOp_Patch)),
1341
+ ExternalReference(IC_Utility(IC::kTypeRecordingBinaryOp_Patch),
1342
+ masm->isolate()),
1326
1343
  5,
1327
1344
  1);
1328
1345
  }
@@ -1342,6 +1359,9 @@ void TypeRecordingBinaryOpStub::Generate(MacroAssembler* masm) {
1342
1359
  case TRBinaryOpIC::HEAP_NUMBER:
1343
1360
  GenerateHeapNumberStub(masm);
1344
1361
  break;
1362
+ case TRBinaryOpIC::ODDBALL:
1363
+ GenerateOddballStub(masm);
1364
+ break;
1345
1365
  case TRBinaryOpIC::STRING:
1346
1366
  GenerateStringStub(masm);
1347
1367
  break;
@@ -1357,7 +1377,8 @@ void TypeRecordingBinaryOpStub::Generate(MacroAssembler* masm) {
1357
1377
  const char* TypeRecordingBinaryOpStub::GetName() {
1358
1378
  if (name_ != NULL) return name_;
1359
1379
  const int kMaxNameLength = 100;
1360
- name_ = Bootstrapper::AllocateAutoDeletedArray(kMaxNameLength);
1380
+ name_ = Isolate::Current()->bootstrapper()->AllocateAutoDeletedArray(
1381
+ kMaxNameLength);
1361
1382
  if (name_ == NULL) return "OOM";
1362
1383
  const char* op_name = Token::Name(op_);
1363
1384
  const char* overwrite_name;
@@ -2006,9 +2027,41 @@ void TypeRecordingBinaryOpStub::GenerateInt32Stub(MacroAssembler* masm) {
2006
2027
  }
2007
2028
 
2008
2029
 
2030
+ void TypeRecordingBinaryOpStub::GenerateOddballStub(MacroAssembler* masm) {
2031
+ Label call_runtime;
2032
+
2033
+ if (op_ == Token::ADD) {
2034
+ // Handle string addition here, because it is the only operation
2035
+ // that does not do a ToNumber conversion on the operands.
2036
+ GenerateAddStrings(masm);
2037
+ }
2038
+
2039
+ // Convert odd ball arguments to numbers.
2040
+ NearLabel check, done;
2041
+ __ cmp(edx, FACTORY->undefined_value());
2042
+ __ j(not_equal, &check);
2043
+ if (Token::IsBitOp(op_)) {
2044
+ __ xor_(edx, Operand(edx));
2045
+ } else {
2046
+ __ mov(edx, Immediate(FACTORY->nan_value()));
2047
+ }
2048
+ __ jmp(&done);
2049
+ __ bind(&check);
2050
+ __ cmp(eax, FACTORY->undefined_value());
2051
+ __ j(not_equal, &done);
2052
+ if (Token::IsBitOp(op_)) {
2053
+ __ xor_(eax, Operand(eax));
2054
+ } else {
2055
+ __ mov(eax, Immediate(FACTORY->nan_value()));
2056
+ }
2057
+ __ bind(&done);
2058
+
2059
+ GenerateHeapNumberStub(masm);
2060
+ }
2061
+
2062
+
2009
2063
  void TypeRecordingBinaryOpStub::GenerateHeapNumberStub(MacroAssembler* masm) {
2010
2064
  Label call_runtime;
2011
- ASSERT(operands_type_ == TRBinaryOpIC::HEAP_NUMBER);
2012
2065
 
2013
2066
  // Floating point case.
2014
2067
  switch (op_) {
@@ -2191,7 +2244,8 @@ void TypeRecordingBinaryOpStub::GenerateHeapNumberStub(MacroAssembler* masm) {
2191
2244
  void TypeRecordingBinaryOpStub::GenerateGeneric(MacroAssembler* masm) {
2192
2245
  Label call_runtime;
2193
2246
 
2194
- __ IncrementCounter(&Counters::generic_binary_stub_calls, 1);
2247
+ Counters* counters = masm->isolate()->counters();
2248
+ __ IncrementCounter(counters->generic_binary_stub_calls(), 1);
2195
2249
 
2196
2250
  switch (op_) {
2197
2251
  case Token::ADD:
@@ -2507,7 +2561,8 @@ void TranscendentalCacheStub::Generate(MacroAssembler* masm) {
2507
2561
  __ bind(&input_not_smi);
2508
2562
  // Check if input is a HeapNumber.
2509
2563
  __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset));
2510
- __ cmp(Operand(ebx), Immediate(Factory::heap_number_map()));
2564
+ Factory* factory = masm->isolate()->factory();
2565
+ __ cmp(Operand(ebx), Immediate(factory->heap_number_map()));
2511
2566
  __ j(not_equal, &runtime_call);
2512
2567
  // Input is a HeapNumber. Push it on the FPU stack and load its
2513
2568
  // low and high words into ebx, edx.
@@ -2540,24 +2595,27 @@ void TranscendentalCacheStub::Generate(MacroAssembler* masm) {
2540
2595
  __ mov(eax, ecx);
2541
2596
  __ sar(eax, 8);
2542
2597
  __ xor_(ecx, Operand(eax));
2543
- ASSERT(IsPowerOf2(TranscendentalCache::kCacheSize));
2544
- __ and_(Operand(ecx), Immediate(TranscendentalCache::kCacheSize - 1));
2598
+ ASSERT(IsPowerOf2(TranscendentalCache::SubCache::kCacheSize));
2599
+ __ and_(Operand(ecx),
2600
+ Immediate(TranscendentalCache::SubCache::kCacheSize - 1));
2545
2601
 
2546
2602
  // ST[0] or xmm1 == double value.
2547
2603
  // ebx = low 32 bits of double value.
2548
2604
  // edx = high 32 bits of double value.
2549
2605
  // ecx = TranscendentalCache::hash(double value).
2550
- __ mov(eax,
2551
- Immediate(ExternalReference::transcendental_cache_array_address()));
2552
- // Eax points to cache array.
2553
- __ mov(eax, Operand(eax, type_ * sizeof(TranscendentalCache::caches_[0])));
2606
+ ExternalReference cache_array =
2607
+ ExternalReference::transcendental_cache_array_address(masm->isolate());
2608
+ __ mov(eax, Immediate(cache_array));
2609
+ int cache_array_index =
2610
+ type_ * sizeof(masm->isolate()->transcendental_cache()->caches_[0]);
2611
+ __ mov(eax, Operand(eax, cache_array_index));
2554
2612
  // Eax points to the cache for the type type_.
2555
2613
  // If NULL, the cache hasn't been initialized yet, so go through runtime.
2556
2614
  __ test(eax, Operand(eax));
2557
2615
  __ j(zero, &runtime_call_clear_stack);
2558
2616
  #ifdef DEBUG
2559
2617
  // Check that the layout of cache elements match expectations.
2560
- { TranscendentalCache::Element test_elem[2];
2618
+ { TranscendentalCache::SubCache::Element test_elem[2];
2561
2619
  char* elem_start = reinterpret_cast<char*>(&test_elem[0]);
2562
2620
  char* elem2_start = reinterpret_cast<char*>(&test_elem[1]);
2563
2621
  char* elem_in0 = reinterpret_cast<char*>(&(test_elem[0].in[0]));
@@ -2636,7 +2694,9 @@ void TranscendentalCacheStub::Generate(MacroAssembler* masm) {
2636
2694
  __ bind(&runtime_call_clear_stack);
2637
2695
  __ fstp(0);
2638
2696
  __ bind(&runtime_call);
2639
- __ TailCallExternalReference(ExternalReference(RuntimeFunction()), 1, 1);
2697
+ ExternalReference runtime =
2698
+ ExternalReference(RuntimeFunction(), masm->isolate());
2699
+ __ TailCallExternalReference(runtime, 1, 1);
2640
2700
  } else { // UNTAGGED.
2641
2701
  __ bind(&runtime_call_clear_stack);
2642
2702
  __ bind(&runtime_call);
@@ -2766,7 +2826,7 @@ void IntegerConvert(MacroAssembler* masm,
2766
2826
  Label done, right_exponent, normal_exponent;
2767
2827
  Register scratch = ebx;
2768
2828
  Register scratch2 = edi;
2769
- if (type_info.IsInteger32() && CpuFeatures::IsEnabled(SSE2)) {
2829
+ if (type_info.IsInteger32() && CpuFeatures::IsSupported(SSE2)) {
2770
2830
  CpuFeatures::Scope scope(SSE2);
2771
2831
  __ cvttsd2si(ecx, FieldOperand(source, HeapNumber::kValueOffset));
2772
2832
  return;
@@ -2969,14 +3029,15 @@ void FloatingPointHelper::LoadUnknownsAsIntegers(MacroAssembler* masm,
2969
3029
 
2970
3030
  // If the argument is undefined it converts to zero (ECMA-262, section 9.5).
2971
3031
  __ bind(&check_undefined_arg1);
2972
- __ cmp(edx, Factory::undefined_value());
3032
+ Factory* factory = masm->isolate()->factory();
3033
+ __ cmp(edx, factory->undefined_value());
2973
3034
  __ j(not_equal, conversion_failure);
2974
3035
  __ mov(edx, Immediate(0));
2975
3036
  __ jmp(&load_arg2);
2976
3037
 
2977
3038
  __ bind(&arg1_is_object);
2978
3039
  __ mov(ebx, FieldOperand(edx, HeapObject::kMapOffset));
2979
- __ cmp(ebx, Factory::heap_number_map());
3040
+ __ cmp(ebx, factory->heap_number_map());
2980
3041
  __ j(not_equal, &check_undefined_arg1);
2981
3042
 
2982
3043
  // Get the untagged integer version of the edx heap number in ecx.
@@ -3000,14 +3061,14 @@ void FloatingPointHelper::LoadUnknownsAsIntegers(MacroAssembler* masm,
3000
3061
 
3001
3062
  // If the argument is undefined it converts to zero (ECMA-262, section 9.5).
3002
3063
  __ bind(&check_undefined_arg2);
3003
- __ cmp(eax, Factory::undefined_value());
3064
+ __ cmp(eax, factory->undefined_value());
3004
3065
  __ j(not_equal, conversion_failure);
3005
3066
  __ mov(ecx, Immediate(0));
3006
3067
  __ jmp(&done);
3007
3068
 
3008
3069
  __ bind(&arg2_is_object);
3009
3070
  __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset));
3010
- __ cmp(ebx, Factory::heap_number_map());
3071
+ __ cmp(ebx, factory->heap_number_map());
3011
3072
  __ j(not_equal, &check_undefined_arg2);
3012
3073
 
3013
3074
  // Get the untagged integer version of the eax heap number in ecx.
@@ -3094,14 +3155,15 @@ void FloatingPointHelper::LoadSSE2Operands(MacroAssembler* masm,
3094
3155
  // Load operand in edx into xmm0, or branch to not_numbers.
3095
3156
  __ test(edx, Immediate(kSmiTagMask));
3096
3157
  __ j(zero, &load_smi_edx, not_taken); // Argument in edx is a smi.
3097
- __ cmp(FieldOperand(edx, HeapObject::kMapOffset), Factory::heap_number_map());
3158
+ Factory* factory = masm->isolate()->factory();
3159
+ __ cmp(FieldOperand(edx, HeapObject::kMapOffset), factory->heap_number_map());
3098
3160
  __ j(not_equal, not_numbers); // Argument in edx is not a number.
3099
3161
  __ movdbl(xmm0, FieldOperand(edx, HeapNumber::kValueOffset));
3100
3162
  __ bind(&load_eax);
3101
3163
  // Load operand in eax into xmm1, or branch to not_numbers.
3102
3164
  __ test(eax, Immediate(kSmiTagMask));
3103
3165
  __ j(zero, &load_smi_eax, not_taken); // Argument in eax is a smi.
3104
- __ cmp(FieldOperand(eax, HeapObject::kMapOffset), Factory::heap_number_map());
3166
+ __ cmp(FieldOperand(eax, HeapObject::kMapOffset), factory->heap_number_map());
3105
3167
  __ j(equal, &load_float_eax);
3106
3168
  __ jmp(not_numbers); // Argument in eax is not a number.
3107
3169
  __ bind(&load_smi_edx);
@@ -3219,14 +3281,15 @@ void FloatingPointHelper::CheckFloatOperands(MacroAssembler* masm,
3219
3281
  __ test(edx, Immediate(kSmiTagMask));
3220
3282
  __ j(zero, &test_other, not_taken); // argument in edx is OK
3221
3283
  __ mov(scratch, FieldOperand(edx, HeapObject::kMapOffset));
3222
- __ cmp(scratch, Factory::heap_number_map());
3284
+ Factory* factory = masm->isolate()->factory();
3285
+ __ cmp(scratch, factory->heap_number_map());
3223
3286
  __ j(not_equal, non_float); // argument in edx is not a number -> NaN
3224
3287
 
3225
3288
  __ bind(&test_other);
3226
3289
  __ test(eax, Immediate(kSmiTagMask));
3227
3290
  __ j(zero, &done); // argument in eax is OK
3228
3291
  __ mov(scratch, FieldOperand(eax, HeapObject::kMapOffset));
3229
- __ cmp(scratch, Factory::heap_number_map());
3292
+ __ cmp(scratch, factory->heap_number_map());
3230
3293
  __ j(not_equal, non_float); // argument in eax is not a number -> NaN
3231
3294
 
3232
3295
  // Fall-through: Both operands are numbers.
@@ -3272,7 +3335,7 @@ void GenericUnaryOpStub::Generate(MacroAssembler* masm) {
3272
3335
  }
3273
3336
 
3274
3337
  __ mov(edx, FieldOperand(eax, HeapObject::kMapOffset));
3275
- __ cmp(edx, Factory::heap_number_map());
3338
+ __ cmp(edx, masm->isolate()->factory()->heap_number_map());
3276
3339
  __ j(not_equal, &slow);
3277
3340
  if (overwrite_ == UNARY_OVERWRITE) {
3278
3341
  __ mov(edx, FieldOperand(eax, HeapNumber::kExponentOffset));
@@ -3304,7 +3367,7 @@ void GenericUnaryOpStub::Generate(MacroAssembler* masm) {
3304
3367
 
3305
3368
  // Check if the operand is a heap number.
3306
3369
  __ mov(edx, FieldOperand(eax, HeapObject::kMapOffset));
3307
- __ cmp(edx, Factory::heap_number_map());
3370
+ __ cmp(edx, masm->isolate()->factory()->heap_number_map());
3308
3371
  __ j(not_equal, &slow, not_taken);
3309
3372
 
3310
3373
  // Convert the heap number in eax to an untagged integer in ecx.
@@ -3399,15 +3462,16 @@ void MathPowStub::Generate(MacroAssembler* masm) {
3399
3462
  __ test(edx, Immediate(kSmiTagMask));
3400
3463
  __ j(not_zero, &base_nonsmi);
3401
3464
 
3402
- // Optimized version when both exponent and base is a smi.
3465
+ // Optimized version when both exponent and base are smis.
3403
3466
  Label powi;
3404
3467
  __ SmiUntag(edx);
3405
3468
  __ cvtsi2sd(xmm0, Operand(edx));
3406
3469
  __ jmp(&powi);
3407
3470
  // exponent is smi and base is a heapnumber.
3408
3471
  __ bind(&base_nonsmi);
3472
+ Factory* factory = masm->isolate()->factory();
3409
3473
  __ cmp(FieldOperand(edx, HeapObject::kMapOffset),
3410
- Factory::heap_number_map());
3474
+ factory->heap_number_map());
3411
3475
  __ j(not_equal, &call_runtime);
3412
3476
 
3413
3477
  __ movdbl(xmm0, FieldOperand(edx, HeapNumber::kValueOffset));
@@ -3438,7 +3502,6 @@ void MathPowStub::Generate(MacroAssembler* masm) {
3438
3502
  __ j(not_carry, &no_multiply);
3439
3503
  __ mulsd(xmm1, xmm0);
3440
3504
  __ bind(&no_multiply);
3441
- __ test(eax, Operand(eax));
3442
3505
  __ mulsd(xmm0, xmm0);
3443
3506
  __ j(not_zero, &while_true);
3444
3507
 
@@ -3460,7 +3523,7 @@ void MathPowStub::Generate(MacroAssembler* masm) {
3460
3523
  // on doubles.
3461
3524
  __ bind(&exponent_nonsmi);
3462
3525
  __ cmp(FieldOperand(eax, HeapObject::kMapOffset),
3463
- Factory::heap_number_map());
3526
+ factory->heap_number_map());
3464
3527
  __ j(not_equal, &call_runtime);
3465
3528
  __ movdbl(xmm1, FieldOperand(eax, HeapNumber::kValueOffset));
3466
3529
  // Test if exponent is nan.
@@ -3477,7 +3540,7 @@ void MathPowStub::Generate(MacroAssembler* masm) {
3477
3540
 
3478
3541
  __ bind(&base_not_smi);
3479
3542
  __ cmp(FieldOperand(edx, HeapObject::kMapOffset),
3480
- Factory::heap_number_map());
3543
+ factory->heap_number_map());
3481
3544
  __ j(not_equal, &call_runtime);
3482
3545
  __ mov(ecx, FieldOperand(edx, HeapNumber::kExponentOffset));
3483
3546
  __ and_(ecx, HeapNumber::kExponentMask);
@@ -3525,7 +3588,7 @@ void MathPowStub::Generate(MacroAssembler* masm) {
3525
3588
  __ AllocateHeapNumber(ecx, eax, edx, &call_runtime);
3526
3589
  __ movdbl(FieldOperand(ecx, HeapNumber::kValueOffset), xmm1);
3527
3590
  __ mov(eax, ecx);
3528
- __ ret(2);
3591
+ __ ret(2 * kPointerSize);
3529
3592
 
3530
3593
  __ bind(&call_runtime);
3531
3594
  __ TailCallRuntime(Runtime::kMath_pow_cfunction, 2, 1);
@@ -3629,16 +3692,16 @@ void ArgumentsAccessStub::GenerateNewObject(MacroAssembler* masm) {
3629
3692
  __ j(zero, &add_arguments_object);
3630
3693
  __ lea(ecx, Operand(ecx, times_2, FixedArray::kHeaderSize));
3631
3694
  __ bind(&add_arguments_object);
3632
- __ add(Operand(ecx), Immediate(Heap::kArgumentsObjectSize));
3695
+ __ add(Operand(ecx), Immediate(GetArgumentsObjectSize()));
3633
3696
 
3634
3697
  // Do the allocation of both objects in one go.
3635
3698
  __ AllocateInNewSpace(ecx, eax, edx, ebx, &runtime, TAG_OBJECT);
3636
3699
 
3637
3700
  // Get the arguments boilerplate from the current (global) context.
3638
- int offset = Context::SlotOffset(Context::ARGUMENTS_BOILERPLATE_INDEX);
3639
3701
  __ mov(edi, Operand(esi, Context::SlotOffset(Context::GLOBAL_INDEX)));
3640
3702
  __ mov(edi, FieldOperand(edi, GlobalObject::kGlobalContextOffset));
3641
- __ mov(edi, Operand(edi, offset));
3703
+ __ mov(edi, Operand(edi,
3704
+ Context::SlotOffset(GetArgumentsBoilerplateIndex())));
3642
3705
 
3643
3706
  // Copy the JS object part.
3644
3707
  for (int i = 0; i < JSObject::kHeaderSize; i += kPointerSize) {
@@ -3646,15 +3709,21 @@ void ArgumentsAccessStub::GenerateNewObject(MacroAssembler* masm) {
3646
3709
  __ mov(FieldOperand(eax, i), ebx);
3647
3710
  }
3648
3711
 
3649
- // Setup the callee in-object property.
3650
- STATIC_ASSERT(Heap::arguments_callee_index == 0);
3651
- __ mov(ebx, Operand(esp, 3 * kPointerSize));
3652
- __ mov(FieldOperand(eax, JSObject::kHeaderSize), ebx);
3712
+ if (type_ == NEW_NON_STRICT) {
3713
+ // Setup the callee in-object property.
3714
+ STATIC_ASSERT(Heap::kArgumentsCalleeIndex == 1);
3715
+ __ mov(ebx, Operand(esp, 3 * kPointerSize));
3716
+ __ mov(FieldOperand(eax, JSObject::kHeaderSize +
3717
+ Heap::kArgumentsCalleeIndex * kPointerSize),
3718
+ ebx);
3719
+ }
3653
3720
 
3654
3721
  // Get the length (smi tagged) and set that as an in-object property too.
3655
- STATIC_ASSERT(Heap::arguments_length_index == 1);
3722
+ STATIC_ASSERT(Heap::kArgumentsLengthIndex == 0);
3656
3723
  __ mov(ecx, Operand(esp, 1 * kPointerSize));
3657
- __ mov(FieldOperand(eax, JSObject::kHeaderSize + kPointerSize), ecx);
3724
+ __ mov(FieldOperand(eax, JSObject::kHeaderSize +
3725
+ Heap::kArgumentsLengthIndex * kPointerSize),
3726
+ ecx);
3658
3727
 
3659
3728
  // If there are no actual arguments, we're done.
3660
3729
  Label done;
@@ -3666,10 +3735,11 @@ void ArgumentsAccessStub::GenerateNewObject(MacroAssembler* masm) {
3666
3735
 
3667
3736
  // Setup the elements pointer in the allocated arguments object and
3668
3737
  // initialize the header in the elements fixed array.
3669
- __ lea(edi, Operand(eax, Heap::kArgumentsObjectSize));
3738
+ __ lea(edi, Operand(eax, GetArgumentsObjectSize()));
3670
3739
  __ mov(FieldOperand(eax, JSObject::kElementsOffset), edi);
3671
3740
  __ mov(FieldOperand(edi, FixedArray::kMapOffset),
3672
- Immediate(Factory::fixed_array_map()));
3741
+ Immediate(masm->isolate()->factory()->fixed_array_map()));
3742
+
3673
3743
  __ mov(FieldOperand(edi, FixedArray::kLengthOffset), ecx);
3674
3744
  // Untag the length for the loop below.
3675
3745
  __ SmiUntag(ecx);
@@ -3722,9 +3792,10 @@ void RegExpExecStub::Generate(MacroAssembler* masm) {
3722
3792
 
3723
3793
  // Ensure that a RegExp stack is allocated.
3724
3794
  ExternalReference address_of_regexp_stack_memory_address =
3725
- ExternalReference::address_of_regexp_stack_memory_address();
3795
+ ExternalReference::address_of_regexp_stack_memory_address(
3796
+ masm->isolate());
3726
3797
  ExternalReference address_of_regexp_stack_memory_size =
3727
- ExternalReference::address_of_regexp_stack_memory_size();
3798
+ ExternalReference::address_of_regexp_stack_memory_size(masm->isolate());
3728
3799
  __ mov(ebx, Operand::StaticVariable(address_of_regexp_stack_memory_size));
3729
3800
  __ test(ebx, Operand(ebx));
3730
3801
  __ j(zero, &runtime, not_taken);
@@ -3796,7 +3867,8 @@ void RegExpExecStub::Generate(MacroAssembler* masm) {
3796
3867
  // Check that the JSArray is in fast case.
3797
3868
  __ mov(ebx, FieldOperand(eax, JSArray::kElementsOffset));
3798
3869
  __ mov(eax, FieldOperand(ebx, HeapObject::kMapOffset));
3799
- __ cmp(eax, Factory::fixed_array_map());
3870
+ Factory* factory = masm->isolate()->factory();
3871
+ __ cmp(eax, factory->fixed_array_map());
3800
3872
  __ j(not_equal, &runtime);
3801
3873
  // Check that the last match info has space for the capture registers and the
3802
3874
  // additional information.
@@ -3834,7 +3906,7 @@ void RegExpExecStub::Generate(MacroAssembler* masm) {
3834
3906
  __ j(not_zero, &runtime);
3835
3907
  // String is a cons string.
3836
3908
  __ mov(edx, FieldOperand(eax, ConsString::kSecondOffset));
3837
- __ cmp(Operand(edx), Factory::empty_string());
3909
+ __ cmp(Operand(edx), factory->empty_string());
3838
3910
  __ j(not_equal, &runtime);
3839
3911
  __ mov(eax, FieldOperand(eax, ConsString::kFirstOffset));
3840
3912
  __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset));
@@ -3884,11 +3956,17 @@ void RegExpExecStub::Generate(MacroAssembler* masm) {
3884
3956
  // edx: code
3885
3957
  // edi: encoding of subject string (1 if ascii 0 if two_byte);
3886
3958
  // All checks done. Now push arguments for native regexp code.
3887
- __ IncrementCounter(&Counters::regexp_entry_native, 1);
3959
+ Counters* counters = masm->isolate()->counters();
3960
+ __ IncrementCounter(counters->regexp_entry_native(), 1);
3888
3961
 
3889
- static const int kRegExpExecuteArguments = 7;
3962
+ // Isolates: note we add an additional parameter here (isolate pointer).
3963
+ static const int kRegExpExecuteArguments = 8;
3890
3964
  __ EnterApiExitFrame(kRegExpExecuteArguments);
3891
3965
 
3966
+ // Argument 8: Pass current isolate address.
3967
+ __ mov(Operand(esp, 7 * kPointerSize),
3968
+ Immediate(ExternalReference::isolate_address()));
3969
+
3892
3970
  // Argument 7: Indicate that this is a direct call from JavaScript.
3893
3971
  __ mov(Operand(esp, 6 * kPointerSize), Immediate(1));
3894
3972
 
@@ -3899,7 +3977,8 @@ void RegExpExecStub::Generate(MacroAssembler* masm) {
3899
3977
 
3900
3978
  // Argument 5: static offsets vector buffer.
3901
3979
  __ mov(Operand(esp, 4 * kPointerSize),
3902
- Immediate(ExternalReference::address_of_static_offsets_vector()));
3980
+ Immediate(ExternalReference::address_of_static_offsets_vector(
3981
+ masm->isolate())));
3903
3982
 
3904
3983
  // Argument 4: End of string data
3905
3984
  // Argument 3: Start of string data
@@ -3951,9 +4030,11 @@ void RegExpExecStub::Generate(MacroAssembler* masm) {
3951
4030
  // stack overflow (on the backtrack stack) was detected in RegExp code but
3952
4031
  // haven't created the exception yet. Handle that in the runtime system.
3953
4032
  // TODO(592): Rerunning the RegExp to get the stack overflow exception.
3954
- ExternalReference pending_exception(Top::k_pending_exception_address);
4033
+ ExternalReference pending_exception(Isolate::k_pending_exception_address,
4034
+ masm->isolate());
3955
4035
  __ mov(edx,
3956
- Operand::StaticVariable(ExternalReference::the_hole_value_location()));
4036
+ Operand::StaticVariable(ExternalReference::the_hole_value_location(
4037
+ masm->isolate())));
3957
4038
  __ mov(eax, Operand::StaticVariable(pending_exception));
3958
4039
  __ cmp(edx, Operand(eax));
3959
4040
  __ j(equal, &runtime);
@@ -3964,7 +4045,7 @@ void RegExpExecStub::Generate(MacroAssembler* masm) {
3964
4045
 
3965
4046
  // Special handling of termination exceptions which are uncatchable
3966
4047
  // by javascript code.
3967
- __ cmp(eax, Factory::termination_exception());
4048
+ __ cmp(eax, factory->termination_exception());
3968
4049
  Label throw_termination_exception;
3969
4050
  __ j(equal, &throw_termination_exception);
3970
4051
 
@@ -3976,7 +4057,7 @@ void RegExpExecStub::Generate(MacroAssembler* masm) {
3976
4057
 
3977
4058
  __ bind(&failure);
3978
4059
  // For failure to match, return null.
3979
- __ mov(Operand(eax), Factory::null_value());
4060
+ __ mov(Operand(eax), factory->null_value());
3980
4061
  __ ret(4 * kPointerSize);
3981
4062
 
3982
4063
  // Load RegExp data.
@@ -4012,7 +4093,7 @@ void RegExpExecStub::Generate(MacroAssembler* masm) {
4012
4093
 
4013
4094
  // Get the static offsets vector filled by the native regexp code.
4014
4095
  ExternalReference address_of_static_offsets_vector =
4015
- ExternalReference::address_of_static_offsets_vector();
4096
+ ExternalReference::address_of_static_offsets_vector(masm->isolate());
4016
4097
  __ mov(ecx, Immediate(address_of_static_offsets_vector));
4017
4098
 
4018
4099
  // ebx: last_match_info backing store (FixedArray)
@@ -4077,7 +4158,8 @@ void RegExpConstructResultStub::Generate(MacroAssembler* masm) {
4077
4158
  // Set elements to point to FixedArray allocated right after the JSArray.
4078
4159
  // Interleave operations for better latency.
4079
4160
  __ mov(edx, ContextOperand(esi, Context::GLOBAL_INDEX));
4080
- __ mov(ecx, Immediate(Factory::empty_fixed_array()));
4161
+ Factory* factory = masm->isolate()->factory();
4162
+ __ mov(ecx, Immediate(factory->empty_fixed_array()));
4081
4163
  __ lea(ebx, Operand(eax, JSRegExpResult::kSize));
4082
4164
  __ mov(edx, FieldOperand(edx, GlobalObject::kGlobalContextOffset));
4083
4165
  __ mov(FieldOperand(eax, JSObject::kElementsOffset), ebx);
@@ -4100,12 +4182,12 @@ void RegExpConstructResultStub::Generate(MacroAssembler* masm) {
4100
4182
 
4101
4183
  // Set map.
4102
4184
  __ mov(FieldOperand(ebx, HeapObject::kMapOffset),
4103
- Immediate(Factory::fixed_array_map()));
4185
+ Immediate(factory->fixed_array_map()));
4104
4186
  // Set length.
4105
4187
  __ mov(FieldOperand(ebx, FixedArray::kLengthOffset), ecx);
4106
4188
  // Fill contents of fixed-array with the-hole.
4107
4189
  __ SmiUntag(ecx);
4108
- __ mov(edx, Immediate(Factory::the_hole_value()));
4190
+ __ mov(edx, Immediate(factory->the_hole_value()));
4109
4191
  __ lea(ebx, FieldOperand(ebx, FixedArray::kHeaderSize));
4110
4192
  // Fill fixed array elements with hole.
4111
4193
  // eax: JSArray.
@@ -4141,7 +4223,8 @@ void NumberToStringStub::GenerateLookupNumberStringCache(MacroAssembler* masm,
4141
4223
  Register scratch = scratch2;
4142
4224
 
4143
4225
  // Load the number string cache.
4144
- ExternalReference roots_address = ExternalReference::roots_address();
4226
+ ExternalReference roots_address =
4227
+ ExternalReference::roots_address(masm->isolate());
4145
4228
  __ mov(scratch, Immediate(Heap::kNumberStringCacheRootIndex));
4146
4229
  __ mov(number_string_cache,
4147
4230
  Operand::StaticArray(scratch, times_pointer_size, roots_address));
@@ -4170,7 +4253,7 @@ void NumberToStringStub::GenerateLookupNumberStringCache(MacroAssembler* masm,
4170
4253
  __ jmp(&smi_hash_calculated);
4171
4254
  __ bind(&not_smi);
4172
4255
  __ cmp(FieldOperand(object, HeapObject::kMapOffset),
4173
- Factory::heap_number_map());
4256
+ masm->isolate()->factory()->heap_number_map());
4174
4257
  __ j(not_equal, not_found);
4175
4258
  STATIC_ASSERT(8 == kDoubleSize);
4176
4259
  __ mov(scratch, FieldOperand(object, HeapNumber::kValueOffset));
@@ -4220,7 +4303,8 @@ void NumberToStringStub::GenerateLookupNumberStringCache(MacroAssembler* masm,
4220
4303
  index,
4221
4304
  times_twice_pointer_size,
4222
4305
  FixedArray::kHeaderSize + kPointerSize));
4223
- __ IncrementCounter(&Counters::number_to_string_native, 1);
4306
+ Counters* counters = masm->isolate()->counters();
4307
+ __ IncrementCounter(counters->number_to_string_native(), 1);
4224
4308
  }
4225
4309
 
4226
4310
 
@@ -4286,14 +4370,14 @@ void CompareStub::Generate(MacroAssembler* masm) {
4286
4370
  // Check for undefined. undefined OP undefined is false even though
4287
4371
  // undefined == undefined.
4288
4372
  NearLabel check_for_nan;
4289
- __ cmp(edx, Factory::undefined_value());
4373
+ __ cmp(edx, masm->isolate()->factory()->undefined_value());
4290
4374
  __ j(not_equal, &check_for_nan);
4291
4375
  __ Set(eax, Immediate(Smi::FromInt(NegativeComparisonResult(cc_))));
4292
4376
  __ ret(0);
4293
4377
  __ bind(&check_for_nan);
4294
4378
  }
4295
4379
 
4296
- // Test for NaN. Sadly, we can't just compare to Factory::nan_value(),
4380
+ // Test for NaN. Sadly, we can't just compare to factory->nan_value(),
4297
4381
  // so we do the second best thing - test it ourselves.
4298
4382
  // Note: if cc_ != equal, never_nan_nan_ is not used.
4299
4383
  if (never_nan_nan_ && (cc_ == equal)) {
@@ -4302,7 +4386,7 @@ void CompareStub::Generate(MacroAssembler* masm) {
4302
4386
  } else {
4303
4387
  NearLabel heap_number;
4304
4388
  __ cmp(FieldOperand(edx, HeapObject::kMapOffset),
4305
- Immediate(Factory::heap_number_map()));
4389
+ Immediate(masm->isolate()->factory()->heap_number_map()));
4306
4390
  __ j(equal, &heap_number);
4307
4391
  if (cc_ != equal) {
4308
4392
  // Call runtime on identical JSObjects. Otherwise return equal.
@@ -4379,7 +4463,7 @@ void CompareStub::Generate(MacroAssembler* masm) {
4379
4463
 
4380
4464
  // Check if the non-smi operand is a heap number.
4381
4465
  __ cmp(FieldOperand(ebx, HeapObject::kMapOffset),
4382
- Immediate(Factory::heap_number_map()));
4466
+ Immediate(masm->isolate()->factory()->heap_number_map()));
4383
4467
  // If heap number, handle it in the slow case.
4384
4468
  __ j(equal, &slow);
4385
4469
  // Return non-equal (ebx is not zero)
@@ -4643,11 +4727,17 @@ void CallFunctionStub::Generate(MacroAssembler* masm) {
4643
4727
  __ Set(eax, Immediate(argc_));
4644
4728
  __ Set(ebx, Immediate(0));
4645
4729
  __ GetBuiltinEntry(edx, Builtins::CALL_NON_FUNCTION);
4646
- Handle<Code> adaptor(Builtins::builtin(Builtins::ArgumentsAdaptorTrampoline));
4730
+ Handle<Code> adaptor =
4731
+ masm->isolate()->builtins()->ArgumentsAdaptorTrampoline();
4647
4732
  __ jmp(adaptor, RelocInfo::CODE_TARGET);
4648
4733
  }
4649
4734
 
4650
4735
 
4736
+ bool CEntryStub::NeedsImmovableCode() {
4737
+ return false;
4738
+ }
4739
+
4740
+
4651
4741
  void CEntryStub::GenerateThrowTOS(MacroAssembler* masm) {
4652
4742
  __ Throw(eax);
4653
4743
  }
@@ -4684,7 +4774,7 @@ void CEntryStub::GenerateCore(MacroAssembler* masm,
4684
4774
  }
4685
4775
 
4686
4776
  ExternalReference scope_depth =
4687
- ExternalReference::heap_always_allocate_scope_depth();
4777
+ ExternalReference::heap_always_allocate_scope_depth(masm->isolate());
4688
4778
  if (always_allocate_scope) {
4689
4779
  __ inc(Operand::StaticVariable(scope_depth));
4690
4780
  }
@@ -4692,6 +4782,8 @@ void CEntryStub::GenerateCore(MacroAssembler* masm,
4692
4782
  // Call C function.
4693
4783
  __ mov(Operand(esp, 0 * kPointerSize), edi); // argc.
4694
4784
  __ mov(Operand(esp, 1 * kPointerSize), esi); // argv.
4785
+ __ mov(Operand(esp, 2 * kPointerSize),
4786
+ Immediate(ExternalReference::isolate_address()));
4695
4787
  __ call(Operand(ebx));
4696
4788
  // Result is in eax or edx:eax - do not destroy these registers!
4697
4789
 
@@ -4703,7 +4795,7 @@ void CEntryStub::GenerateCore(MacroAssembler* masm,
4703
4795
  // call as this may lead to crashes in the IC code later.
4704
4796
  if (FLAG_debug_code) {
4705
4797
  NearLabel okay;
4706
- __ cmp(eax, Factory::the_hole_value());
4798
+ __ cmp(eax, masm->isolate()->factory()->the_hole_value());
4707
4799
  __ j(not_equal, &okay);
4708
4800
  __ int3();
4709
4801
  __ bind(&okay);
@@ -4717,14 +4809,15 @@ void CEntryStub::GenerateCore(MacroAssembler* masm,
4717
4809
  __ test(ecx, Immediate(kFailureTagMask));
4718
4810
  __ j(zero, &failure_returned, not_taken);
4719
4811
 
4720
- ExternalReference pending_exception_address(Top::k_pending_exception_address);
4812
+ ExternalReference pending_exception_address(
4813
+ Isolate::k_pending_exception_address, masm->isolate());
4721
4814
 
4722
4815
  // Check that there is no pending exception, otherwise we
4723
4816
  // should have returned some failure value.
4724
4817
  if (FLAG_debug_code) {
4725
4818
  __ push(edx);
4726
4819
  __ mov(edx, Operand::StaticVariable(
4727
- ExternalReference::the_hole_value_location()));
4820
+ ExternalReference::the_hole_value_location(masm->isolate())));
4728
4821
  NearLabel okay;
4729
4822
  __ cmp(edx, Operand::StaticVariable(pending_exception_address));
4730
4823
  // Cannot use check here as it attempts to generate call into runtime.
@@ -4752,14 +4845,15 @@ void CEntryStub::GenerateCore(MacroAssembler* masm,
4752
4845
  __ j(equal, throw_out_of_memory_exception);
4753
4846
 
4754
4847
  // Retrieve the pending exception and clear the variable.
4848
+ ExternalReference the_hole_location =
4849
+ ExternalReference::the_hole_value_location(masm->isolate());
4755
4850
  __ mov(eax, Operand::StaticVariable(pending_exception_address));
4756
- __ mov(edx,
4757
- Operand::StaticVariable(ExternalReference::the_hole_value_location()));
4851
+ __ mov(edx, Operand::StaticVariable(the_hole_location));
4758
4852
  __ mov(Operand::StaticVariable(pending_exception_address), edx);
4759
4853
 
4760
4854
  // Special handling of termination exceptions which are uncatchable
4761
4855
  // by javascript code.
4762
- __ cmp(eax, Factory::termination_exception());
4856
+ __ cmp(eax, masm->isolate()->factory()->termination_exception());
4763
4857
  __ j(equal, throw_termination_exception);
4764
4858
 
4765
4859
  // Handle normal exception.
@@ -4859,12 +4953,13 @@ void JSEntryStub::GenerateBody(MacroAssembler* masm, bool is_construct) {
4859
4953
  __ push(ebx);
4860
4954
 
4861
4955
  // Save copies of the top frame descriptor on the stack.
4862
- ExternalReference c_entry_fp(Top::k_c_entry_fp_address);
4956
+ ExternalReference c_entry_fp(Isolate::k_c_entry_fp_address, masm->isolate());
4863
4957
  __ push(Operand::StaticVariable(c_entry_fp));
4864
4958
 
4865
4959
  #ifdef ENABLE_LOGGING_AND_PROFILING
4866
4960
  // If this is the outermost JS call, set js_entry_sp value.
4867
- ExternalReference js_entry_sp(Top::k_js_entry_sp_address);
4961
+ ExternalReference js_entry_sp(Isolate::k_js_entry_sp_address,
4962
+ masm->isolate());
4868
4963
  __ cmp(Operand::StaticVariable(js_entry_sp), Immediate(0));
4869
4964
  __ j(not_equal, &not_outermost_js);
4870
4965
  __ mov(Operand::StaticVariable(js_entry_sp), ebp);
@@ -4876,7 +4971,8 @@ void JSEntryStub::GenerateBody(MacroAssembler* masm, bool is_construct) {
4876
4971
 
4877
4972
  // Caught exception: Store result (exception) in the pending
4878
4973
  // exception field in the JSEnv and return a failure sentinel.
4879
- ExternalReference pending_exception(Top::k_pending_exception_address);
4974
+ ExternalReference pending_exception(Isolate::k_pending_exception_address,
4975
+ masm->isolate());
4880
4976
  __ mov(Operand::StaticVariable(pending_exception), eax);
4881
4977
  __ mov(eax, reinterpret_cast<int32_t>(Failure::Exception()));
4882
4978
  __ jmp(&exit);
@@ -4886,8 +4982,9 @@ void JSEntryStub::GenerateBody(MacroAssembler* masm, bool is_construct) {
4886
4982
  __ PushTryHandler(IN_JS_ENTRY, JS_ENTRY_HANDLER);
4887
4983
 
4888
4984
  // Clear any pending exceptions.
4889
- __ mov(edx,
4890
- Operand::StaticVariable(ExternalReference::the_hole_value_location()));
4985
+ ExternalReference the_hole_location =
4986
+ ExternalReference::the_hole_value_location(masm->isolate());
4987
+ __ mov(edx, Operand::StaticVariable(the_hole_location));
4891
4988
  __ mov(Operand::StaticVariable(pending_exception), edx);
4892
4989
 
4893
4990
  // Fake a receiver (NULL).
@@ -4898,10 +4995,13 @@ void JSEntryStub::GenerateBody(MacroAssembler* masm, bool is_construct) {
4898
4995
  // cannot store a reference to the trampoline code directly in this
4899
4996
  // stub, because the builtin stubs may not have been generated yet.
4900
4997
  if (is_construct) {
4901
- ExternalReference construct_entry(Builtins::JSConstructEntryTrampoline);
4998
+ ExternalReference construct_entry(
4999
+ Builtins::kJSConstructEntryTrampoline,
5000
+ masm->isolate());
4902
5001
  __ mov(edx, Immediate(construct_entry));
4903
5002
  } else {
4904
- ExternalReference entry(Builtins::JSEntryTrampoline);
5003
+ ExternalReference entry(Builtins::kJSEntryTrampoline,
5004
+ masm->isolate());
4905
5005
  __ mov(edx, Immediate(entry));
4906
5006
  }
4907
5007
  __ mov(edx, Operand(edx, 0)); // deref address
@@ -4909,7 +5009,9 @@ void JSEntryStub::GenerateBody(MacroAssembler* masm, bool is_construct) {
4909
5009
  __ call(Operand(edx));
4910
5010
 
4911
5011
  // Unlink this frame from the handler chain.
4912
- __ pop(Operand::StaticVariable(ExternalReference(Top::k_handler_address)));
5012
+ __ pop(Operand::StaticVariable(ExternalReference(
5013
+ Isolate::k_handler_address,
5014
+ masm->isolate())));
4913
5015
  // Pop next_sp.
4914
5016
  __ add(Operand(esp), Immediate(StackHandlerConstants::kSize - kPointerSize));
4915
5017
 
@@ -4924,7 +5026,9 @@ void JSEntryStub::GenerateBody(MacroAssembler* masm, bool is_construct) {
4924
5026
 
4925
5027
  // Restore the top frame descriptor from the stack.
4926
5028
  __ bind(&exit);
4927
- __ pop(Operand::StaticVariable(ExternalReference(Top::k_c_entry_fp_address)));
5029
+ __ pop(Operand::StaticVariable(ExternalReference(
5030
+ Isolate::k_c_entry_fp_address,
5031
+ masm->isolate())));
4928
5032
 
4929
5033
  // Restore callee-saved registers (C calling conventions).
4930
5034
  __ pop(ebx);
@@ -4973,7 +5077,8 @@ void InstanceofStub::Generate(MacroAssembler* masm) {
4973
5077
  static const int8_t kCmpEdiImmediateByte2 = BitCast<int8_t, uint8_t>(0xff);
4974
5078
  static const int8_t kMovEaxImmediateByte = BitCast<int8_t, uint8_t>(0xb8);
4975
5079
 
4976
- ExternalReference roots_address = ExternalReference::roots_address();
5080
+ ExternalReference roots_address =
5081
+ ExternalReference::roots_address(masm->isolate());
4977
5082
 
4978
5083
  ASSERT_EQ(object.code(), InstanceofStub::left().code());
4979
5084
  ASSERT_EQ(function.code(), InstanceofStub::right().code());
@@ -5049,7 +5154,8 @@ void InstanceofStub::Generate(MacroAssembler* masm) {
5049
5154
  __ bind(&loop);
5050
5155
  __ cmp(scratch, Operand(prototype));
5051
5156
  __ j(equal, &is_instance);
5052
- __ cmp(Operand(scratch), Immediate(Factory::null_value()));
5157
+ Factory* factory = masm->isolate()->factory();
5158
+ __ cmp(Operand(scratch), Immediate(factory->null_value()));
5053
5159
  __ j(equal, &is_not_instance);
5054
5160
  __ mov(scratch, FieldOperand(scratch, HeapObject::kMapOffset));
5055
5161
  __ mov(scratch, FieldOperand(scratch, Map::kPrototypeOffset));
@@ -5063,7 +5169,7 @@ void InstanceofStub::Generate(MacroAssembler* masm) {
5063
5169
  times_pointer_size, roots_address), eax);
5064
5170
  } else {
5065
5171
  // Get return address and delta to inlined map check.
5066
- __ mov(eax, Factory::true_value());
5172
+ __ mov(eax, factory->true_value());
5067
5173
  __ mov(scratch, Operand(esp, 0 * kPointerSize));
5068
5174
  __ sub(scratch, Operand(esp, 1 * kPointerSize));
5069
5175
  if (FLAG_debug_code) {
@@ -5085,7 +5191,7 @@ void InstanceofStub::Generate(MacroAssembler* masm) {
5085
5191
  scratch, times_pointer_size, roots_address), eax);
5086
5192
  } else {
5087
5193
  // Get return address and delta to inlined map check.
5088
- __ mov(eax, Factory::false_value());
5194
+ __ mov(eax, factory->false_value());
5089
5195
  __ mov(scratch, Operand(esp, 0 * kPointerSize));
5090
5196
  __ sub(scratch, Operand(esp, 1 * kPointerSize));
5091
5197
  if (FLAG_debug_code) {
@@ -5109,7 +5215,7 @@ void InstanceofStub::Generate(MacroAssembler* masm) {
5109
5215
  __ j(not_equal, &slow, not_taken);
5110
5216
 
5111
5217
  // Null is not instance of anything.
5112
- __ cmp(object, Factory::null_value());
5218
+ __ cmp(object, factory->null_value());
5113
5219
  __ j(not_equal, &object_not_null);
5114
5220
  __ Set(eax, Immediate(Smi::FromInt(1)));
5115
5221
  __ ret((HasArgsInRegisters() ? 0 : 2) * kPointerSize);
@@ -5150,10 +5256,10 @@ void InstanceofStub::Generate(MacroAssembler* masm) {
5150
5256
  NearLabel true_value, done;
5151
5257
  __ test(eax, Operand(eax));
5152
5258
  __ j(zero, &true_value);
5153
- __ mov(eax, Factory::false_value());
5259
+ __ mov(eax, factory->false_value());
5154
5260
  __ jmp(&done);
5155
5261
  __ bind(&true_value);
5156
- __ mov(eax, Factory::true_value());
5262
+ __ mov(eax, factory->true_value());
5157
5263
  __ bind(&done);
5158
5264
  __ ret((HasArgsInRegisters() ? 0 : 2) * kPointerSize);
5159
5265
  }
@@ -5188,7 +5294,8 @@ const char* CompareStub::GetName() {
5188
5294
 
5189
5295
  if (name_ != NULL) return name_;
5190
5296
  const int kMaxNameLength = 100;
5191
- name_ = Bootstrapper::AllocateAutoDeletedArray(kMaxNameLength);
5297
+ name_ = Isolate::Current()->bootstrapper()->AllocateAutoDeletedArray(
5298
+ kMaxNameLength);
5192
5299
  if (name_ == NULL) return "OOM";
5193
5300
 
5194
5301
  const char* cc_name;
@@ -5281,7 +5388,7 @@ void StringCharCodeAtGenerator::GenerateFast(MacroAssembler* masm) {
5281
5388
  // the case we would rather go to the runtime system now to flatten
5282
5389
  // the string.
5283
5390
  __ cmp(FieldOperand(object_, ConsString::kSecondOffset),
5284
- Immediate(Factory::empty_string()));
5391
+ Immediate(masm->isolate()->factory()->empty_string()));
5285
5392
  __ j(not_equal, &call_runtime_);
5286
5393
  // Get the first of the two strings and load its instance type.
5287
5394
  __ mov(object_, FieldOperand(object_, ConsString::kFirstOffset));
@@ -5326,7 +5433,10 @@ void StringCharCodeAtGenerator::GenerateSlow(
5326
5433
  // Index is not a smi.
5327
5434
  __ bind(&index_not_smi_);
5328
5435
  // If index is a heap number, try converting it to an integer.
5329
- __ CheckMap(index_, Factory::heap_number_map(), index_not_number_, true);
5436
+ __ CheckMap(index_,
5437
+ masm->isolate()->factory()->heap_number_map(),
5438
+ index_not_number_,
5439
+ true);
5330
5440
  call_helper.BeforeCall(masm);
5331
5441
  __ push(object_);
5332
5442
  __ push(index_);
@@ -5387,7 +5497,8 @@ void StringCharFromCodeGenerator::GenerateFast(MacroAssembler* masm) {
5387
5497
  ((~String::kMaxAsciiCharCode) << kSmiTagSize)));
5388
5498
  __ j(not_zero, &slow_case_, not_taken);
5389
5499
 
5390
- __ Set(result_, Immediate(Factory::single_character_string_cache()));
5500
+ Factory* factory = masm->isolate()->factory();
5501
+ __ Set(result_, Immediate(factory->single_character_string_cache()));
5391
5502
  STATIC_ASSERT(kSmiTag == 0);
5392
5503
  STATIC_ASSERT(kSmiTagSize == 1);
5393
5504
  STATIC_ASSERT(kSmiShiftSize == 0);
@@ -5395,7 +5506,7 @@ void StringCharFromCodeGenerator::GenerateFast(MacroAssembler* masm) {
5395
5506
  __ mov(result_, FieldOperand(result_,
5396
5507
  code_, times_half_pointer_size,
5397
5508
  FixedArray::kHeaderSize));
5398
- __ cmp(result_, Factory::undefined_value());
5509
+ __ cmp(result_, factory->undefined_value());
5399
5510
  __ j(equal, &slow_case_, not_taken);
5400
5511
  __ bind(&exit_);
5401
5512
  }
@@ -5481,7 +5592,8 @@ void StringAddStub::Generate(MacroAssembler* masm) {
5481
5592
  __ test(ecx, Operand(ecx));
5482
5593
  __ j(not_zero, &second_not_zero_length);
5483
5594
  // Second string is empty, result is first string which is already in eax.
5484
- __ IncrementCounter(&Counters::string_add_native, 1);
5595
+ Counters* counters = masm->isolate()->counters();
5596
+ __ IncrementCounter(counters->string_add_native(), 1);
5485
5597
  __ ret(2 * kPointerSize);
5486
5598
  __ bind(&second_not_zero_length);
5487
5599
  __ mov(ebx, FieldOperand(eax, String::kLengthOffset));
@@ -5490,7 +5602,7 @@ void StringAddStub::Generate(MacroAssembler* masm) {
5490
5602
  __ j(not_zero, &both_not_zero_length);
5491
5603
  // First string is empty, result is second string which is in edx.
5492
5604
  __ mov(eax, edx);
5493
- __ IncrementCounter(&Counters::string_add_native, 1);
5605
+ __ IncrementCounter(counters->string_add_native(), 1);
5494
5606
  __ ret(2 * kPointerSize);
5495
5607
 
5496
5608
  // Both strings are non-empty.
@@ -5505,8 +5617,8 @@ void StringAddStub::Generate(MacroAssembler* masm) {
5505
5617
  STATIC_ASSERT(Smi::kMaxValue == String::kMaxLength);
5506
5618
  // Handle exceptionally long strings in the runtime system.
5507
5619
  __ j(overflow, &string_add_runtime);
5508
- // Use the runtime system when adding two one character strings, as it
5509
- // contains optimizations for this specific case using the symbol table.
5620
+ // Use the symbol table when adding two one character strings, as it
5621
+ // helps later optimizations to return a symbol here.
5510
5622
  __ cmp(Operand(ebx), Immediate(Smi::FromInt(2)));
5511
5623
  __ j(not_equal, &longer_than_two);
5512
5624
 
@@ -5524,7 +5636,7 @@ void StringAddStub::Generate(MacroAssembler* masm) {
5524
5636
  StringHelper::GenerateTwoCharacterSymbolTableProbe(
5525
5637
  masm, ebx, ecx, eax, edx, edi,
5526
5638
  &make_two_character_string_no_reload, &make_two_character_string);
5527
- __ IncrementCounter(&Counters::string_add_native, 1);
5639
+ __ IncrementCounter(counters->string_add_native(), 1);
5528
5640
  __ ret(2 * kPointerSize);
5529
5641
 
5530
5642
  // Allocate a two character string.
@@ -5536,7 +5648,7 @@ void StringAddStub::Generate(MacroAssembler* masm) {
5536
5648
  __ movzx_b(ebx, FieldOperand(eax, SeqAsciiString::kHeaderSize));
5537
5649
  __ movzx_b(ecx, FieldOperand(edx, SeqAsciiString::kHeaderSize));
5538
5650
  __ bind(&make_two_character_string_no_reload);
5539
- __ IncrementCounter(&Counters::string_add_make_two_char, 1);
5651
+ __ IncrementCounter(counters->string_add_make_two_char(), 1);
5540
5652
  __ AllocateAsciiString(eax, // Result.
5541
5653
  2, // Length.
5542
5654
  edi, // Scratch 1.
@@ -5547,7 +5659,7 @@ void StringAddStub::Generate(MacroAssembler* masm) {
5547
5659
  __ or_(ebx, Operand(ecx));
5548
5660
  // Set the characters in the new string.
5549
5661
  __ mov_w(FieldOperand(eax, SeqAsciiString::kHeaderSize), ebx);
5550
- __ IncrementCounter(&Counters::string_add_native, 1);
5662
+ __ IncrementCounter(counters->string_add_native(), 1);
5551
5663
  __ ret(2 * kPointerSize);
5552
5664
 
5553
5665
  __ bind(&longer_than_two);
@@ -5578,7 +5690,7 @@ void StringAddStub::Generate(MacroAssembler* masm) {
5578
5690
  __ mov(FieldOperand(ecx, ConsString::kFirstOffset), eax);
5579
5691
  __ mov(FieldOperand(ecx, ConsString::kSecondOffset), edx);
5580
5692
  __ mov(eax, ecx);
5581
- __ IncrementCounter(&Counters::string_add_native, 1);
5693
+ __ IncrementCounter(counters->string_add_native(), 1);
5582
5694
  __ ret(2 * kPointerSize);
5583
5695
  __ bind(&non_ascii);
5584
5696
  // At least one of the strings is two-byte. Check whether it happens
@@ -5655,7 +5767,7 @@ void StringAddStub::Generate(MacroAssembler* masm) {
5655
5767
  // edx: first char of second argument
5656
5768
  // edi: length of second argument
5657
5769
  StringHelper::GenerateCopyCharacters(masm, ecx, edx, edi, ebx, true);
5658
- __ IncrementCounter(&Counters::string_add_native, 1);
5770
+ __ IncrementCounter(counters->string_add_native(), 1);
5659
5771
  __ ret(2 * kPointerSize);
5660
5772
 
5661
5773
  // Handle creating a flat two byte result.
@@ -5696,7 +5808,7 @@ void StringAddStub::Generate(MacroAssembler* masm) {
5696
5808
  // edx: first char of second argument
5697
5809
  // edi: length of second argument
5698
5810
  StringHelper::GenerateCopyCharacters(masm, ecx, edx, edi, ebx, false);
5699
- __ IncrementCounter(&Counters::string_add_native, 1);
5811
+ __ IncrementCounter(counters->string_add_native(), 1);
5700
5812
  __ ret(2 * kPointerSize);
5701
5813
 
5702
5814
  // Just jump to runtime to add the two strings.
@@ -5881,7 +5993,8 @@ void StringHelper::GenerateTwoCharacterSymbolTableProbe(MacroAssembler* masm,
5881
5993
 
5882
5994
  // Load the symbol table.
5883
5995
  Register symbol_table = c2;
5884
- ExternalReference roots_address = ExternalReference::roots_address();
5996
+ ExternalReference roots_address =
5997
+ ExternalReference::roots_address(masm->isolate());
5885
5998
  __ mov(scratch, Immediate(Heap::kSymbolTableRootIndex));
5886
5999
  __ mov(symbol_table,
5887
6000
  Operand::StaticArray(scratch, times_pointer_size, roots_address));
@@ -5921,8 +6034,11 @@ void StringHelper::GenerateTwoCharacterSymbolTableProbe(MacroAssembler* masm,
5921
6034
  SymbolTable::kElementsStartOffset));
5922
6035
 
5923
6036
  // If entry is undefined no string with this hash can be found.
5924
- __ cmp(candidate, Factory::undefined_value());
6037
+ Factory* factory = masm->isolate()->factory();
6038
+ __ cmp(candidate, factory->undefined_value());
5925
6039
  __ j(equal, not_found);
6040
+ __ cmp(candidate, factory->null_value());
6041
+ __ j(equal, &next_probe[i]);
5926
6042
 
5927
6043
  // If length is not 2 the string is not a candidate.
5928
6044
  __ cmp(FieldOperand(candidate, String::kLengthOffset),
@@ -6118,7 +6234,8 @@ void SubStringStub::Generate(MacroAssembler* masm) {
6118
6234
  // esi: character of sub string start
6119
6235
  StringHelper::GenerateCopyCharactersREP(masm, edi, esi, ecx, ebx, true);
6120
6236
  __ mov(esi, edx); // Restore esi.
6121
- __ IncrementCounter(&Counters::sub_string_native, 1);
6237
+ Counters* counters = masm->isolate()->counters();
6238
+ __ IncrementCounter(counters->sub_string_native(), 1);
6122
6239
  __ ret(3 * kPointerSize);
6123
6240
 
6124
6241
  __ bind(&non_ascii_flat);
@@ -6159,7 +6276,7 @@ void SubStringStub::Generate(MacroAssembler* masm) {
6159
6276
  __ mov(esi, edx); // Restore esi.
6160
6277
 
6161
6278
  __ bind(&return_eax);
6162
- __ IncrementCounter(&Counters::sub_string_native, 1);
6279
+ __ IncrementCounter(counters->sub_string_native(), 1);
6163
6280
  __ ret(3 * kPointerSize);
6164
6281
 
6165
6282
  // Just jump to runtime to create the sub string.
@@ -6178,7 +6295,8 @@ void StringCompareStub::GenerateCompareFlatAsciiStrings(MacroAssembler* masm,
6178
6295
  Label result_greater;
6179
6296
  Label compare_lengths;
6180
6297
 
6181
- __ IncrementCounter(&Counters::string_compare_native, 1);
6298
+ Counters* counters = masm->isolate()->counters();
6299
+ __ IncrementCounter(counters->string_compare_native(), 1);
6182
6300
 
6183
6301
  // Find minimum length.
6184
6302
  NearLabel left_shorter;
@@ -6269,7 +6387,7 @@ void StringCompareStub::Generate(MacroAssembler* masm) {
6269
6387
  STATIC_ASSERT(EQUAL == 0);
6270
6388
  STATIC_ASSERT(kSmiTag == 0);
6271
6389
  __ Set(eax, Immediate(Smi::FromInt(EQUAL)));
6272
- __ IncrementCounter(&Counters::string_compare_native, 1);
6390
+ __ IncrementCounter(masm->isolate()->counters()->string_compare_native(), 1);
6273
6391
  __ ret(2 * kPointerSize);
6274
6392
 
6275
6393
  __ bind(&not_same);
@@ -6291,59 +6409,6 @@ void StringCompareStub::Generate(MacroAssembler* masm) {
6291
6409
  }
6292
6410
 
6293
6411
 
6294
- void StringCharAtStub::Generate(MacroAssembler* masm) {
6295
- // Expects two arguments (object, index) on the stack:
6296
-
6297
- // Stack frame on entry.
6298
- // esp[0]: return address
6299
- // esp[4]: index
6300
- // esp[8]: object
6301
-
6302
- Register object = ebx;
6303
- Register index = eax;
6304
- Register scratch1 = ecx;
6305
- Register scratch2 = edx;
6306
- Register result = eax;
6307
-
6308
- __ pop(scratch1); // Return address.
6309
- __ pop(index);
6310
- __ pop(object);
6311
- __ push(scratch1);
6312
-
6313
- Label need_conversion;
6314
- Label index_out_of_range;
6315
- Label done;
6316
- StringCharAtGenerator generator(object,
6317
- index,
6318
- scratch1,
6319
- scratch2,
6320
- result,
6321
- &need_conversion,
6322
- &need_conversion,
6323
- &index_out_of_range,
6324
- STRING_INDEX_IS_NUMBER);
6325
- generator.GenerateFast(masm);
6326
- __ jmp(&done);
6327
-
6328
- __ bind(&index_out_of_range);
6329
- // When the index is out of range, the spec requires us to return
6330
- // the empty string.
6331
- __ Set(result, Immediate(Factory::empty_string()));
6332
- __ jmp(&done);
6333
-
6334
- __ bind(&need_conversion);
6335
- // Move smi zero into the result register, which will trigger
6336
- // conversion.
6337
- __ Set(result, Immediate(Smi::FromInt(0)));
6338
- __ jmp(&done);
6339
-
6340
- StubRuntimeCallHelper call_helper;
6341
- generator.GenerateSlow(masm, call_helper);
6342
-
6343
- __ bind(&done);
6344
- __ ret(0);
6345
- }
6346
-
6347
6412
  void ICCompareStub::GenerateSmis(MacroAssembler* masm) {
6348
6413
  ASSERT(state_ == CompareIC::SMIS);
6349
6414
  NearLabel miss;
@@ -6454,7 +6519,8 @@ void ICCompareStub::GenerateMiss(MacroAssembler* masm) {
6454
6519
  __ push(ecx);
6455
6520
 
6456
6521
  // Call the runtime system in a fresh internal frame.
6457
- ExternalReference miss = ExternalReference(IC_Utility(IC::kCompareIC_Miss));
6522
+ ExternalReference miss = ExternalReference(IC_Utility(IC::kCompareIC_Miss),
6523
+ masm->isolate());
6458
6524
  __ EnterInternalFrame();
6459
6525
  __ push(edx);
6460
6526
  __ push(eax);
@@ -6476,148 +6542,6 @@ void ICCompareStub::GenerateMiss(MacroAssembler* masm) {
6476
6542
  }
6477
6543
 
6478
6544
 
6479
- // Loads a indexed element from a pixel array.
6480
- void GenerateFastPixelArrayLoad(MacroAssembler* masm,
6481
- Register receiver,
6482
- Register key,
6483
- Register elements,
6484
- Register untagged_key,
6485
- Register result,
6486
- Label* not_pixel_array,
6487
- Label* key_not_smi,
6488
- Label* out_of_range) {
6489
- // Register use:
6490
- // receiver - holds the receiver and is unchanged.
6491
- // key - holds the key and is unchanged (must be a smi).
6492
- // elements - is set to the the receiver's element if
6493
- // the receiver doesn't have a pixel array or the
6494
- // key is not a smi, otherwise it's the elements'
6495
- // external pointer.
6496
- // untagged_key - is set to the untagged key
6497
-
6498
- // Some callers already have verified that the key is a smi. key_not_smi is
6499
- // set to NULL as a sentinel for that case. Otherwise, add an explicit check
6500
- // to ensure the key is a smi must be added.
6501
- if (key_not_smi != NULL) {
6502
- __ JumpIfNotSmi(key, key_not_smi);
6503
- } else {
6504
- if (FLAG_debug_code) {
6505
- __ AbortIfNotSmi(key);
6506
- }
6507
- }
6508
- __ mov(untagged_key, key);
6509
- __ SmiUntag(untagged_key);
6510
-
6511
- __ mov(elements, FieldOperand(receiver, JSObject::kElementsOffset));
6512
- // By passing NULL as not_pixel_array, callers signal that they have already
6513
- // verified that the receiver has pixel array elements.
6514
- if (not_pixel_array != NULL) {
6515
- __ CheckMap(elements, Factory::pixel_array_map(), not_pixel_array, true);
6516
- } else {
6517
- if (FLAG_debug_code) {
6518
- // Map check should have already made sure that elements is a pixel array.
6519
- __ cmp(FieldOperand(elements, HeapObject::kMapOffset),
6520
- Immediate(Factory::pixel_array_map()));
6521
- __ Assert(equal, "Elements isn't a pixel array");
6522
- }
6523
- }
6524
-
6525
- // Key must be in range.
6526
- __ cmp(untagged_key, FieldOperand(elements, PixelArray::kLengthOffset));
6527
- __ j(above_equal, out_of_range); // unsigned check handles negative keys.
6528
-
6529
- // Perform the indexed load and tag the result as a smi.
6530
- __ mov(elements, FieldOperand(elements, PixelArray::kExternalPointerOffset));
6531
- __ movzx_b(result, Operand(elements, untagged_key, times_1, 0));
6532
- __ SmiTag(result);
6533
- __ ret(0);
6534
- }
6535
-
6536
-
6537
- // Stores an indexed element into a pixel array, clamping the stored value.
6538
- void GenerateFastPixelArrayStore(MacroAssembler* masm,
6539
- Register receiver,
6540
- Register key,
6541
- Register value,
6542
- Register elements,
6543
- Register scratch1,
6544
- bool load_elements_from_receiver,
6545
- Label* key_not_smi,
6546
- Label* value_not_smi,
6547
- Label* not_pixel_array,
6548
- Label* out_of_range) {
6549
- // Register use:
6550
- // receiver - holds the receiver and is unchanged unless the
6551
- // store succeeds.
6552
- // key - holds the key (must be a smi) and is unchanged.
6553
- // value - holds the value (must be a smi) and is unchanged.
6554
- // elements - holds the element object of the receiver on entry if
6555
- // load_elements_from_receiver is false, otherwise used
6556
- // internally to store the pixel arrays elements and
6557
- // external array pointer.
6558
- //
6559
- // receiver, key and value remain unmodified until it's guaranteed that the
6560
- // store will succeed.
6561
- Register external_pointer = elements;
6562
- Register untagged_key = scratch1;
6563
- Register untagged_value = receiver; // Only set once success guaranteed.
6564
-
6565
- // Fetch the receiver's elements if the caller hasn't already done so.
6566
- if (load_elements_from_receiver) {
6567
- __ mov(elements, FieldOperand(receiver, JSObject::kElementsOffset));
6568
- }
6569
-
6570
- // By passing NULL as not_pixel_array, callers signal that they have already
6571
- // verified that the receiver has pixel array elements.
6572
- if (not_pixel_array != NULL) {
6573
- __ CheckMap(elements, Factory::pixel_array_map(), not_pixel_array, true);
6574
- } else {
6575
- if (FLAG_debug_code) {
6576
- // Map check should have already made sure that elements is a pixel array.
6577
- __ cmp(FieldOperand(elements, HeapObject::kMapOffset),
6578
- Immediate(Factory::pixel_array_map()));
6579
- __ Assert(equal, "Elements isn't a pixel array");
6580
- }
6581
- }
6582
-
6583
- // Some callers already have verified that the key is a smi. key_not_smi is
6584
- // set to NULL as a sentinel for that case. Otherwise, add an explicit check
6585
- // to ensure the key is a smi must be added.
6586
- if (key_not_smi != NULL) {
6587
- __ JumpIfNotSmi(key, key_not_smi);
6588
- } else {
6589
- if (FLAG_debug_code) {
6590
- __ AbortIfNotSmi(key);
6591
- }
6592
- }
6593
-
6594
- // Key must be a smi and it must be in range.
6595
- __ mov(untagged_key, key);
6596
- __ SmiUntag(untagged_key);
6597
- __ cmp(untagged_key, FieldOperand(elements, PixelArray::kLengthOffset));
6598
- __ j(above_equal, out_of_range); // unsigned check handles negative keys.
6599
-
6600
- // Value must be a smi.
6601
- __ JumpIfNotSmi(value, value_not_smi);
6602
- __ mov(untagged_value, value);
6603
- __ SmiUntag(untagged_value);
6604
-
6605
- { // Clamp the value to [0..255].
6606
- NearLabel done;
6607
- __ test(untagged_value, Immediate(0xFFFFFF00));
6608
- __ j(zero, &done);
6609
- __ setcc(negative, untagged_value); // 1 if negative, 0 if positive.
6610
- __ dec_b(untagged_value); // 0 if negative, 255 if positive.
6611
- __ bind(&done);
6612
- }
6613
-
6614
- __ mov(external_pointer,
6615
- FieldOperand(elements, PixelArray::kExternalPointerOffset));
6616
- __ mov_b(Operand(external_pointer, untagged_key, times_1, 0), untagged_value);
6617
- __ ret(0); // Return value in eax.
6618
- }
6619
-
6620
-
6621
6545
  #undef __
6622
6546
 
6623
6547
  } } // namespace v8::internal