libv8 3.11.8.17 → 3.16.14.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (754) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -2
  3. data/Gemfile +1 -1
  4. data/Rakefile +6 -7
  5. data/lib/libv8/version.rb +1 -1
  6. data/vendor/v8/.gitignore +24 -3
  7. data/vendor/v8/AUTHORS +7 -0
  8. data/vendor/v8/ChangeLog +839 -0
  9. data/vendor/v8/DEPS +1 -1
  10. data/vendor/v8/Makefile.android +92 -0
  11. data/vendor/v8/OWNERS +11 -0
  12. data/vendor/v8/PRESUBMIT.py +71 -0
  13. data/vendor/v8/SConstruct +34 -39
  14. data/vendor/v8/build/android.gypi +56 -37
  15. data/vendor/v8/build/common.gypi +112 -30
  16. data/vendor/v8/build/gyp_v8 +1 -1
  17. data/vendor/v8/build/standalone.gypi +15 -11
  18. data/vendor/v8/include/v8-debug.h +9 -1
  19. data/vendor/v8/include/v8-preparser.h +4 -3
  20. data/vendor/v8/include/v8-profiler.h +25 -25
  21. data/vendor/v8/include/v8-testing.h +4 -3
  22. data/vendor/v8/include/v8.h +994 -540
  23. data/vendor/v8/preparser/preparser-process.cc +3 -3
  24. data/vendor/v8/samples/lineprocessor.cc +20 -27
  25. data/vendor/v8/samples/process.cc +18 -14
  26. data/vendor/v8/samples/shell.cc +16 -15
  27. data/vendor/v8/src/SConscript +15 -14
  28. data/vendor/v8/src/accessors.cc +169 -77
  29. data/vendor/v8/src/accessors.h +4 -0
  30. data/vendor/v8/src/allocation-inl.h +2 -2
  31. data/vendor/v8/src/allocation.h +7 -7
  32. data/vendor/v8/src/api.cc +810 -497
  33. data/vendor/v8/src/api.h +85 -60
  34. data/vendor/v8/src/arm/assembler-arm-inl.h +179 -22
  35. data/vendor/v8/src/arm/assembler-arm.cc +633 -264
  36. data/vendor/v8/src/arm/assembler-arm.h +264 -197
  37. data/vendor/v8/src/arm/builtins-arm.cc +117 -27
  38. data/vendor/v8/src/arm/code-stubs-arm.cc +1241 -700
  39. data/vendor/v8/src/arm/code-stubs-arm.h +35 -138
  40. data/vendor/v8/src/arm/codegen-arm.cc +285 -16
  41. data/vendor/v8/src/arm/codegen-arm.h +22 -0
  42. data/vendor/v8/src/arm/constants-arm.cc +5 -3
  43. data/vendor/v8/src/arm/constants-arm.h +24 -11
  44. data/vendor/v8/src/arm/debug-arm.cc +3 -3
  45. data/vendor/v8/src/arm/deoptimizer-arm.cc +382 -92
  46. data/vendor/v8/src/arm/disasm-arm.cc +61 -12
  47. data/vendor/v8/src/arm/frames-arm.h +0 -14
  48. data/vendor/v8/src/arm/full-codegen-arm.cc +332 -304
  49. data/vendor/v8/src/arm/ic-arm.cc +180 -259
  50. data/vendor/v8/src/arm/lithium-arm.cc +364 -316
  51. data/vendor/v8/src/arm/lithium-arm.h +512 -275
  52. data/vendor/v8/src/arm/lithium-codegen-arm.cc +1768 -809
  53. data/vendor/v8/src/arm/lithium-codegen-arm.h +97 -35
  54. data/vendor/v8/src/arm/lithium-gap-resolver-arm.cc +12 -5
  55. data/vendor/v8/src/arm/macro-assembler-arm.cc +439 -228
  56. data/vendor/v8/src/arm/macro-assembler-arm.h +116 -70
  57. data/vendor/v8/src/arm/regexp-macro-assembler-arm.cc +54 -44
  58. data/vendor/v8/src/arm/regexp-macro-assembler-arm.h +3 -10
  59. data/vendor/v8/src/arm/simulator-arm.cc +272 -238
  60. data/vendor/v8/src/arm/simulator-arm.h +38 -8
  61. data/vendor/v8/src/arm/stub-cache-arm.cc +522 -895
  62. data/vendor/v8/src/array.js +101 -70
  63. data/vendor/v8/src/assembler.cc +270 -19
  64. data/vendor/v8/src/assembler.h +110 -15
  65. data/vendor/v8/src/ast.cc +79 -69
  66. data/vendor/v8/src/ast.h +255 -301
  67. data/vendor/v8/src/atomicops.h +7 -1
  68. data/vendor/v8/src/atomicops_internals_tsan.h +335 -0
  69. data/vendor/v8/src/bootstrapper.cc +481 -418
  70. data/vendor/v8/src/bootstrapper.h +4 -4
  71. data/vendor/v8/src/builtins.cc +498 -311
  72. data/vendor/v8/src/builtins.h +75 -47
  73. data/vendor/v8/src/checks.cc +2 -1
  74. data/vendor/v8/src/checks.h +8 -0
  75. data/vendor/v8/src/code-stubs-hydrogen.cc +253 -0
  76. data/vendor/v8/src/code-stubs.cc +249 -84
  77. data/vendor/v8/src/code-stubs.h +501 -169
  78. data/vendor/v8/src/codegen.cc +36 -18
  79. data/vendor/v8/src/codegen.h +25 -3
  80. data/vendor/v8/src/collection.js +54 -17
  81. data/vendor/v8/src/compilation-cache.cc +24 -16
  82. data/vendor/v8/src/compilation-cache.h +15 -6
  83. data/vendor/v8/src/compiler.cc +497 -195
  84. data/vendor/v8/src/compiler.h +246 -38
  85. data/vendor/v8/src/contexts.cc +64 -24
  86. data/vendor/v8/src/contexts.h +60 -29
  87. data/vendor/v8/src/conversions-inl.h +24 -14
  88. data/vendor/v8/src/conversions.h +7 -4
  89. data/vendor/v8/src/counters.cc +21 -12
  90. data/vendor/v8/src/counters.h +44 -16
  91. data/vendor/v8/src/cpu-profiler.h +1 -1
  92. data/vendor/v8/src/d8-debug.cc +2 -2
  93. data/vendor/v8/src/d8-readline.cc +13 -2
  94. data/vendor/v8/src/d8.cc +681 -273
  95. data/vendor/v8/src/d8.gyp +4 -4
  96. data/vendor/v8/src/d8.h +38 -18
  97. data/vendor/v8/src/d8.js +0 -617
  98. data/vendor/v8/src/data-flow.h +55 -0
  99. data/vendor/v8/src/date.js +1 -42
  100. data/vendor/v8/src/dateparser-inl.h +5 -1
  101. data/vendor/v8/src/debug-agent.cc +10 -15
  102. data/vendor/v8/src/debug-debugger.js +147 -149
  103. data/vendor/v8/src/debug.cc +323 -164
  104. data/vendor/v8/src/debug.h +26 -14
  105. data/vendor/v8/src/deoptimizer.cc +765 -290
  106. data/vendor/v8/src/deoptimizer.h +130 -28
  107. data/vendor/v8/src/disassembler.cc +10 -4
  108. data/vendor/v8/src/elements-kind.cc +7 -2
  109. data/vendor/v8/src/elements-kind.h +19 -0
  110. data/vendor/v8/src/elements.cc +607 -285
  111. data/vendor/v8/src/elements.h +36 -13
  112. data/vendor/v8/src/execution.cc +52 -31
  113. data/vendor/v8/src/execution.h +4 -4
  114. data/vendor/v8/src/extensions/externalize-string-extension.cc +5 -4
  115. data/vendor/v8/src/extensions/gc-extension.cc +5 -1
  116. data/vendor/v8/src/extensions/statistics-extension.cc +153 -0
  117. data/vendor/v8/src/{inspector.h → extensions/statistics-extension.h} +12 -23
  118. data/vendor/v8/src/factory.cc +101 -134
  119. data/vendor/v8/src/factory.h +36 -31
  120. data/vendor/v8/src/flag-definitions.h +102 -25
  121. data/vendor/v8/src/flags.cc +9 -5
  122. data/vendor/v8/src/frames-inl.h +10 -0
  123. data/vendor/v8/src/frames.cc +116 -26
  124. data/vendor/v8/src/frames.h +96 -12
  125. data/vendor/v8/src/full-codegen.cc +219 -74
  126. data/vendor/v8/src/full-codegen.h +63 -21
  127. data/vendor/v8/src/func-name-inferrer.cc +8 -7
  128. data/vendor/v8/src/func-name-inferrer.h +5 -3
  129. data/vendor/v8/src/gdb-jit.cc +71 -57
  130. data/vendor/v8/src/global-handles.cc +230 -101
  131. data/vendor/v8/src/global-handles.h +26 -27
  132. data/vendor/v8/src/globals.h +17 -19
  133. data/vendor/v8/src/handles-inl.h +59 -12
  134. data/vendor/v8/src/handles.cc +180 -200
  135. data/vendor/v8/src/handles.h +80 -11
  136. data/vendor/v8/src/hashmap.h +60 -40
  137. data/vendor/v8/src/heap-inl.h +107 -45
  138. data/vendor/v8/src/heap-profiler.cc +38 -19
  139. data/vendor/v8/src/heap-profiler.h +24 -14
  140. data/vendor/v8/src/heap.cc +1123 -738
  141. data/vendor/v8/src/heap.h +385 -146
  142. data/vendor/v8/src/hydrogen-instructions.cc +700 -217
  143. data/vendor/v8/src/hydrogen-instructions.h +1158 -472
  144. data/vendor/v8/src/hydrogen.cc +3319 -1662
  145. data/vendor/v8/src/hydrogen.h +411 -170
  146. data/vendor/v8/src/ia32/assembler-ia32-inl.h +46 -16
  147. data/vendor/v8/src/ia32/assembler-ia32.cc +131 -61
  148. data/vendor/v8/src/ia32/assembler-ia32.h +115 -57
  149. data/vendor/v8/src/ia32/builtins-ia32.cc +99 -5
  150. data/vendor/v8/src/ia32/code-stubs-ia32.cc +787 -495
  151. data/vendor/v8/src/ia32/code-stubs-ia32.h +10 -100
  152. data/vendor/v8/src/ia32/codegen-ia32.cc +227 -23
  153. data/vendor/v8/src/ia32/codegen-ia32.h +14 -0
  154. data/vendor/v8/src/ia32/deoptimizer-ia32.cc +428 -87
  155. data/vendor/v8/src/ia32/disasm-ia32.cc +28 -1
  156. data/vendor/v8/src/ia32/frames-ia32.h +6 -16
  157. data/vendor/v8/src/ia32/full-codegen-ia32.cc +280 -272
  158. data/vendor/v8/src/ia32/ic-ia32.cc +150 -250
  159. data/vendor/v8/src/ia32/lithium-codegen-ia32.cc +1600 -517
  160. data/vendor/v8/src/ia32/lithium-codegen-ia32.h +90 -24
  161. data/vendor/v8/src/ia32/lithium-gap-resolver-ia32.cc +10 -6
  162. data/vendor/v8/src/ia32/lithium-gap-resolver-ia32.h +2 -2
  163. data/vendor/v8/src/ia32/lithium-ia32.cc +405 -302
  164. data/vendor/v8/src/ia32/lithium-ia32.h +526 -271
  165. data/vendor/v8/src/ia32/macro-assembler-ia32.cc +378 -119
  166. data/vendor/v8/src/ia32/macro-assembler-ia32.h +62 -28
  167. data/vendor/v8/src/ia32/regexp-macro-assembler-ia32.cc +43 -30
  168. data/vendor/v8/src/ia32/regexp-macro-assembler-ia32.h +2 -10
  169. data/vendor/v8/src/ia32/stub-cache-ia32.cc +492 -678
  170. data/vendor/v8/src/ic-inl.h +9 -4
  171. data/vendor/v8/src/ic.cc +836 -923
  172. data/vendor/v8/src/ic.h +228 -247
  173. data/vendor/v8/src/incremental-marking-inl.h +26 -30
  174. data/vendor/v8/src/incremental-marking.cc +276 -248
  175. data/vendor/v8/src/incremental-marking.h +29 -37
  176. data/vendor/v8/src/interface.cc +34 -25
  177. data/vendor/v8/src/interface.h +69 -25
  178. data/vendor/v8/src/interpreter-irregexp.cc +2 -2
  179. data/vendor/v8/src/isolate.cc +382 -76
  180. data/vendor/v8/src/isolate.h +109 -56
  181. data/vendor/v8/src/json-parser.h +217 -104
  182. data/vendor/v8/src/json-stringifier.h +745 -0
  183. data/vendor/v8/src/json.js +10 -132
  184. data/vendor/v8/src/jsregexp-inl.h +106 -0
  185. data/vendor/v8/src/jsregexp.cc +517 -285
  186. data/vendor/v8/src/jsregexp.h +145 -117
  187. data/vendor/v8/src/list-inl.h +35 -22
  188. data/vendor/v8/src/list.h +46 -19
  189. data/vendor/v8/src/lithium-allocator-inl.h +22 -2
  190. data/vendor/v8/src/lithium-allocator.cc +85 -70
  191. data/vendor/v8/src/lithium-allocator.h +21 -39
  192. data/vendor/v8/src/lithium.cc +259 -5
  193. data/vendor/v8/src/lithium.h +131 -32
  194. data/vendor/v8/src/liveedit-debugger.js +52 -3
  195. data/vendor/v8/src/liveedit.cc +393 -113
  196. data/vendor/v8/src/liveedit.h +7 -3
  197. data/vendor/v8/src/log-utils.cc +4 -2
  198. data/vendor/v8/src/log.cc +170 -140
  199. data/vendor/v8/src/log.h +62 -11
  200. data/vendor/v8/src/macro-assembler.h +17 -0
  201. data/vendor/v8/src/macros.py +2 -0
  202. data/vendor/v8/src/mark-compact-inl.h +3 -23
  203. data/vendor/v8/src/mark-compact.cc +801 -830
  204. data/vendor/v8/src/mark-compact.h +154 -47
  205. data/vendor/v8/src/marking-thread.cc +85 -0
  206. data/vendor/v8/src/{inspector.cc → marking-thread.h} +32 -24
  207. data/vendor/v8/src/math.js +12 -18
  208. data/vendor/v8/src/messages.cc +18 -8
  209. data/vendor/v8/src/messages.js +314 -261
  210. data/vendor/v8/src/mips/assembler-mips-inl.h +58 -6
  211. data/vendor/v8/src/mips/assembler-mips.cc +92 -75
  212. data/vendor/v8/src/mips/assembler-mips.h +54 -60
  213. data/vendor/v8/src/mips/builtins-mips.cc +116 -17
  214. data/vendor/v8/src/mips/code-stubs-mips.cc +919 -556
  215. data/vendor/v8/src/mips/code-stubs-mips.h +22 -131
  216. data/vendor/v8/src/mips/codegen-mips.cc +281 -6
  217. data/vendor/v8/src/mips/codegen-mips.h +22 -0
  218. data/vendor/v8/src/mips/constants-mips.cc +2 -0
  219. data/vendor/v8/src/mips/constants-mips.h +12 -2
  220. data/vendor/v8/src/mips/deoptimizer-mips.cc +286 -50
  221. data/vendor/v8/src/mips/disasm-mips.cc +13 -0
  222. data/vendor/v8/src/mips/full-codegen-mips.cc +297 -284
  223. data/vendor/v8/src/mips/ic-mips.cc +182 -263
  224. data/vendor/v8/src/mips/lithium-codegen-mips.cc +1208 -556
  225. data/vendor/v8/src/mips/lithium-codegen-mips.h +72 -19
  226. data/vendor/v8/src/mips/lithium-gap-resolver-mips.cc +9 -2
  227. data/vendor/v8/src/mips/lithium-mips.cc +290 -302
  228. data/vendor/v8/src/mips/lithium-mips.h +463 -266
  229. data/vendor/v8/src/mips/macro-assembler-mips.cc +208 -115
  230. data/vendor/v8/src/mips/macro-assembler-mips.h +67 -24
  231. data/vendor/v8/src/mips/regexp-macro-assembler-mips.cc +40 -25
  232. data/vendor/v8/src/mips/regexp-macro-assembler-mips.h +3 -9
  233. data/vendor/v8/src/mips/simulator-mips.cc +112 -40
  234. data/vendor/v8/src/mips/simulator-mips.h +5 -0
  235. data/vendor/v8/src/mips/stub-cache-mips.cc +502 -884
  236. data/vendor/v8/src/mirror-debugger.js +157 -30
  237. data/vendor/v8/src/mksnapshot.cc +88 -14
  238. data/vendor/v8/src/object-observe.js +235 -0
  239. data/vendor/v8/src/objects-debug.cc +178 -176
  240. data/vendor/v8/src/objects-inl.h +1333 -486
  241. data/vendor/v8/src/objects-printer.cc +125 -43
  242. data/vendor/v8/src/objects-visiting-inl.h +578 -6
  243. data/vendor/v8/src/objects-visiting.cc +2 -2
  244. data/vendor/v8/src/objects-visiting.h +172 -79
  245. data/vendor/v8/src/objects.cc +3533 -2885
  246. data/vendor/v8/src/objects.h +1352 -1131
  247. data/vendor/v8/src/optimizing-compiler-thread.cc +152 -0
  248. data/vendor/v8/src/optimizing-compiler-thread.h +111 -0
  249. data/vendor/v8/src/parser.cc +390 -500
  250. data/vendor/v8/src/parser.h +45 -33
  251. data/vendor/v8/src/platform-cygwin.cc +10 -21
  252. data/vendor/v8/src/platform-freebsd.cc +36 -41
  253. data/vendor/v8/src/platform-linux.cc +160 -124
  254. data/vendor/v8/src/platform-macos.cc +30 -27
  255. data/vendor/v8/src/platform-nullos.cc +17 -1
  256. data/vendor/v8/src/platform-openbsd.cc +19 -50
  257. data/vendor/v8/src/platform-posix.cc +14 -0
  258. data/vendor/v8/src/platform-solaris.cc +20 -53
  259. data/vendor/v8/src/platform-win32.cc +49 -26
  260. data/vendor/v8/src/platform.h +40 -1
  261. data/vendor/v8/src/preparser.cc +8 -5
  262. data/vendor/v8/src/preparser.h +2 -2
  263. data/vendor/v8/src/prettyprinter.cc +16 -0
  264. data/vendor/v8/src/prettyprinter.h +2 -0
  265. data/vendor/v8/src/profile-generator-inl.h +1 -0
  266. data/vendor/v8/src/profile-generator.cc +209 -147
  267. data/vendor/v8/src/profile-generator.h +15 -12
  268. data/vendor/v8/src/property-details.h +46 -31
  269. data/vendor/v8/src/property.cc +27 -46
  270. data/vendor/v8/src/property.h +163 -83
  271. data/vendor/v8/src/proxy.js +7 -2
  272. data/vendor/v8/src/regexp-macro-assembler-irregexp.cc +4 -13
  273. data/vendor/v8/src/regexp-macro-assembler-irregexp.h +1 -2
  274. data/vendor/v8/src/regexp-macro-assembler-tracer.cc +1 -11
  275. data/vendor/v8/src/regexp-macro-assembler-tracer.h +0 -1
  276. data/vendor/v8/src/regexp-macro-assembler.cc +31 -14
  277. data/vendor/v8/src/regexp-macro-assembler.h +14 -11
  278. data/vendor/v8/src/regexp-stack.cc +1 -0
  279. data/vendor/v8/src/regexp.js +9 -8
  280. data/vendor/v8/src/rewriter.cc +18 -7
  281. data/vendor/v8/src/runtime-profiler.cc +52 -43
  282. data/vendor/v8/src/runtime-profiler.h +0 -25
  283. data/vendor/v8/src/runtime.cc +2006 -2023
  284. data/vendor/v8/src/runtime.h +56 -49
  285. data/vendor/v8/src/safepoint-table.cc +12 -18
  286. data/vendor/v8/src/safepoint-table.h +11 -8
  287. data/vendor/v8/src/scanner.cc +1 -0
  288. data/vendor/v8/src/scanner.h +4 -10
  289. data/vendor/v8/src/scopeinfo.cc +35 -9
  290. data/vendor/v8/src/scopeinfo.h +64 -3
  291. data/vendor/v8/src/scopes.cc +251 -156
  292. data/vendor/v8/src/scopes.h +61 -27
  293. data/vendor/v8/src/serialize.cc +348 -396
  294. data/vendor/v8/src/serialize.h +125 -114
  295. data/vendor/v8/src/small-pointer-list.h +11 -11
  296. data/vendor/v8/src/{smart-array-pointer.h → smart-pointers.h} +64 -15
  297. data/vendor/v8/src/snapshot-common.cc +64 -15
  298. data/vendor/v8/src/snapshot-empty.cc +7 -1
  299. data/vendor/v8/src/snapshot.h +9 -2
  300. data/vendor/v8/src/spaces-inl.h +17 -0
  301. data/vendor/v8/src/spaces.cc +477 -183
  302. data/vendor/v8/src/spaces.h +238 -58
  303. data/vendor/v8/src/splay-tree-inl.h +8 -7
  304. data/vendor/v8/src/splay-tree.h +24 -10
  305. data/vendor/v8/src/store-buffer.cc +12 -5
  306. data/vendor/v8/src/store-buffer.h +2 -4
  307. data/vendor/v8/src/string-search.h +22 -6
  308. data/vendor/v8/src/string-stream.cc +11 -8
  309. data/vendor/v8/src/string.js +47 -15
  310. data/vendor/v8/src/stub-cache.cc +461 -224
  311. data/vendor/v8/src/stub-cache.h +164 -102
  312. data/vendor/v8/src/sweeper-thread.cc +105 -0
  313. data/vendor/v8/src/sweeper-thread.h +81 -0
  314. data/vendor/v8/src/token.h +1 -0
  315. data/vendor/v8/src/transitions-inl.h +220 -0
  316. data/vendor/v8/src/transitions.cc +160 -0
  317. data/vendor/v8/src/transitions.h +207 -0
  318. data/vendor/v8/src/type-info.cc +182 -181
  319. data/vendor/v8/src/type-info.h +31 -19
  320. data/vendor/v8/src/unicode-inl.h +62 -106
  321. data/vendor/v8/src/unicode.cc +57 -67
  322. data/vendor/v8/src/unicode.h +45 -91
  323. data/vendor/v8/src/uri.js +57 -29
  324. data/vendor/v8/src/utils.h +105 -5
  325. data/vendor/v8/src/v8-counters.cc +54 -11
  326. data/vendor/v8/src/v8-counters.h +134 -19
  327. data/vendor/v8/src/v8.cc +29 -29
  328. data/vendor/v8/src/v8.h +1 -0
  329. data/vendor/v8/src/v8conversions.cc +26 -22
  330. data/vendor/v8/src/v8globals.h +56 -43
  331. data/vendor/v8/src/v8natives.js +83 -30
  332. data/vendor/v8/src/v8threads.cc +42 -21
  333. data/vendor/v8/src/v8threads.h +4 -1
  334. data/vendor/v8/src/v8utils.cc +9 -93
  335. data/vendor/v8/src/v8utils.h +37 -33
  336. data/vendor/v8/src/variables.cc +6 -3
  337. data/vendor/v8/src/variables.h +6 -13
  338. data/vendor/v8/src/version.cc +2 -2
  339. data/vendor/v8/src/vm-state-inl.h +11 -0
  340. data/vendor/v8/src/x64/assembler-x64-inl.h +39 -8
  341. data/vendor/v8/src/x64/assembler-x64.cc +78 -64
  342. data/vendor/v8/src/x64/assembler-x64.h +38 -33
  343. data/vendor/v8/src/x64/builtins-x64.cc +105 -7
  344. data/vendor/v8/src/x64/code-stubs-x64.cc +790 -413
  345. data/vendor/v8/src/x64/code-stubs-x64.h +10 -106
  346. data/vendor/v8/src/x64/codegen-x64.cc +210 -8
  347. data/vendor/v8/src/x64/codegen-x64.h +20 -1
  348. data/vendor/v8/src/x64/deoptimizer-x64.cc +336 -75
  349. data/vendor/v8/src/x64/disasm-x64.cc +15 -0
  350. data/vendor/v8/src/x64/frames-x64.h +0 -14
  351. data/vendor/v8/src/x64/full-codegen-x64.cc +293 -270
  352. data/vendor/v8/src/x64/ic-x64.cc +153 -251
  353. data/vendor/v8/src/x64/lithium-codegen-x64.cc +1379 -531
  354. data/vendor/v8/src/x64/lithium-codegen-x64.h +67 -23
  355. data/vendor/v8/src/x64/lithium-gap-resolver-x64.cc +2 -2
  356. data/vendor/v8/src/x64/lithium-x64.cc +349 -289
  357. data/vendor/v8/src/x64/lithium-x64.h +460 -250
  358. data/vendor/v8/src/x64/macro-assembler-x64.cc +350 -177
  359. data/vendor/v8/src/x64/macro-assembler-x64.h +67 -49
  360. data/vendor/v8/src/x64/regexp-macro-assembler-x64.cc +46 -33
  361. data/vendor/v8/src/x64/regexp-macro-assembler-x64.h +2 -3
  362. data/vendor/v8/src/x64/stub-cache-x64.cc +484 -653
  363. data/vendor/v8/src/zone-inl.h +9 -27
  364. data/vendor/v8/src/zone.cc +5 -5
  365. data/vendor/v8/src/zone.h +53 -27
  366. data/vendor/v8/test/benchmarks/testcfg.py +5 -0
  367. data/vendor/v8/test/cctest/cctest.cc +4 -0
  368. data/vendor/v8/test/cctest/cctest.gyp +3 -1
  369. data/vendor/v8/test/cctest/cctest.h +57 -9
  370. data/vendor/v8/test/cctest/cctest.status +15 -15
  371. data/vendor/v8/test/cctest/test-accessors.cc +26 -0
  372. data/vendor/v8/test/cctest/test-alloc.cc +22 -30
  373. data/vendor/v8/test/cctest/test-api.cc +1943 -314
  374. data/vendor/v8/test/cctest/test-assembler-arm.cc +133 -13
  375. data/vendor/v8/test/cctest/test-assembler-ia32.cc +1 -1
  376. data/vendor/v8/test/cctest/test-assembler-mips.cc +12 -0
  377. data/vendor/v8/test/cctest/test-ast.cc +4 -2
  378. data/vendor/v8/test/cctest/test-compiler.cc +61 -29
  379. data/vendor/v8/test/cctest/test-dataflow.cc +2 -2
  380. data/vendor/v8/test/cctest/test-debug.cc +212 -33
  381. data/vendor/v8/test/cctest/test-decls.cc +257 -11
  382. data/vendor/v8/test/cctest/test-dictionary.cc +24 -10
  383. data/vendor/v8/test/cctest/test-disasm-arm.cc +118 -1
  384. data/vendor/v8/test/cctest/test-disasm-ia32.cc +3 -2
  385. data/vendor/v8/test/cctest/test-flags.cc +14 -1
  386. data/vendor/v8/test/cctest/test-func-name-inference.cc +7 -4
  387. data/vendor/v8/test/cctest/test-global-object.cc +51 -0
  388. data/vendor/v8/test/cctest/test-hashing.cc +32 -23
  389. data/vendor/v8/test/cctest/test-heap-profiler.cc +131 -77
  390. data/vendor/v8/test/cctest/test-heap.cc +1084 -143
  391. data/vendor/v8/test/cctest/test-list.cc +1 -1
  392. data/vendor/v8/test/cctest/test-liveedit.cc +3 -2
  393. data/vendor/v8/test/cctest/test-lockers.cc +12 -13
  394. data/vendor/v8/test/cctest/test-log.cc +10 -8
  395. data/vendor/v8/test/cctest/test-macro-assembler-x64.cc +2 -2
  396. data/vendor/v8/test/cctest/test-mark-compact.cc +44 -22
  397. data/vendor/v8/test/cctest/test-object-observe.cc +434 -0
  398. data/vendor/v8/test/cctest/test-parsing.cc +86 -39
  399. data/vendor/v8/test/cctest/test-platform-linux.cc +6 -0
  400. data/vendor/v8/test/cctest/test-platform-win32.cc +7 -0
  401. data/vendor/v8/test/cctest/test-random.cc +5 -4
  402. data/vendor/v8/test/cctest/test-regexp.cc +137 -101
  403. data/vendor/v8/test/cctest/test-serialize.cc +150 -230
  404. data/vendor/v8/test/cctest/test-sockets.cc +1 -1
  405. data/vendor/v8/test/cctest/test-spaces.cc +139 -0
  406. data/vendor/v8/test/cctest/test-strings.cc +736 -74
  407. data/vendor/v8/test/cctest/test-thread-termination.cc +10 -11
  408. data/vendor/v8/test/cctest/test-threads.cc +4 -4
  409. data/vendor/v8/test/cctest/test-utils.cc +16 -0
  410. data/vendor/v8/test/cctest/test-weakmaps.cc +7 -3
  411. data/vendor/v8/test/cctest/testcfg.py +64 -5
  412. data/vendor/v8/test/es5conform/testcfg.py +5 -0
  413. data/vendor/v8/test/message/message.status +1 -1
  414. data/vendor/v8/test/message/overwritten-builtins.out +3 -0
  415. data/vendor/v8/test/message/testcfg.py +89 -8
  416. data/vendor/v8/test/message/try-catch-finally-no-message.out +26 -26
  417. data/vendor/v8/test/mjsunit/accessor-map-sharing.js +18 -2
  418. data/vendor/v8/test/mjsunit/allocation-site-info.js +126 -0
  419. data/vendor/v8/test/mjsunit/array-bounds-check-removal.js +62 -1
  420. data/vendor/v8/test/mjsunit/array-iteration.js +1 -1
  421. data/vendor/v8/test/mjsunit/array-literal-transitions.js +2 -0
  422. data/vendor/v8/test/mjsunit/array-natives-elements.js +317 -0
  423. data/vendor/v8/test/mjsunit/array-reduce.js +8 -8
  424. data/vendor/v8/test/mjsunit/array-slice.js +12 -0
  425. data/vendor/v8/test/mjsunit/array-store-and-grow.js +4 -1
  426. data/vendor/v8/test/mjsunit/assert-opt-and-deopt.js +1 -1
  427. data/vendor/v8/test/mjsunit/bugs/bug-2337.js +53 -0
  428. data/vendor/v8/test/mjsunit/compare-known-objects-slow.js +69 -0
  429. data/vendor/v8/test/mjsunit/compiler/alloc-object-huge.js +3 -1
  430. data/vendor/v8/test/mjsunit/compiler/inline-accessors.js +368 -0
  431. data/vendor/v8/test/mjsunit/compiler/inline-arguments.js +87 -1
  432. data/vendor/v8/test/mjsunit/compiler/inline-closures.js +49 -0
  433. data/vendor/v8/test/mjsunit/compiler/inline-construct.js +55 -43
  434. data/vendor/v8/test/mjsunit/compiler/inline-literals.js +39 -0
  435. data/vendor/v8/test/mjsunit/compiler/multiply-add.js +69 -0
  436. data/vendor/v8/test/mjsunit/compiler/optimized-closures.js +57 -0
  437. data/vendor/v8/test/mjsunit/compiler/parallel-proto-change.js +44 -0
  438. data/vendor/v8/test/mjsunit/compiler/property-static.js +69 -0
  439. data/vendor/v8/test/mjsunit/compiler/proto-chain-constant.js +55 -0
  440. data/vendor/v8/test/mjsunit/compiler/proto-chain-load.js +44 -0
  441. data/vendor/v8/test/mjsunit/compiler/regress-gvn.js +3 -2
  442. data/vendor/v8/test/mjsunit/compiler/regress-or.js +6 -2
  443. data/vendor/v8/test/mjsunit/compiler/rotate.js +224 -0
  444. data/vendor/v8/test/mjsunit/compiler/uint32.js +173 -0
  445. data/vendor/v8/test/mjsunit/count-based-osr.js +2 -1
  446. data/vendor/v8/test/mjsunit/d8-os.js +3 -3
  447. data/vendor/v8/test/mjsunit/date-parse.js +3 -0
  448. data/vendor/v8/test/mjsunit/date.js +22 -0
  449. data/vendor/v8/test/mjsunit/debug-break-inline.js +1 -0
  450. data/vendor/v8/test/mjsunit/debug-evaluate-locals-optimized-double.js +22 -12
  451. data/vendor/v8/test/mjsunit/debug-evaluate-locals-optimized.js +21 -10
  452. data/vendor/v8/test/mjsunit/debug-liveedit-compile-error.js +60 -0
  453. data/vendor/v8/test/mjsunit/debug-liveedit-double-call.js +142 -0
  454. data/vendor/v8/test/mjsunit/debug-liveedit-literals.js +94 -0
  455. data/vendor/v8/test/mjsunit/debug-liveedit-restart-frame.js +153 -0
  456. data/vendor/v8/test/mjsunit/debug-multiple-breakpoints.js +1 -1
  457. data/vendor/v8/test/mjsunit/debug-script-breakpoints-closure.js +67 -0
  458. data/vendor/v8/test/mjsunit/debug-script-breakpoints-nested.js +82 -0
  459. data/vendor/v8/test/mjsunit/debug-script.js +4 -2
  460. data/vendor/v8/test/mjsunit/debug-set-variable-value.js +308 -0
  461. data/vendor/v8/test/mjsunit/debug-stepout-scope-part1.js +190 -0
  462. data/vendor/v8/test/mjsunit/debug-stepout-scope-part2.js +83 -0
  463. data/vendor/v8/test/mjsunit/debug-stepout-scope-part3.js +80 -0
  464. data/vendor/v8/test/mjsunit/debug-stepout-scope-part4.js +80 -0
  465. data/vendor/v8/test/mjsunit/debug-stepout-scope-part5.js +77 -0
  466. data/vendor/v8/test/mjsunit/debug-stepout-scope-part6.js +79 -0
  467. data/vendor/v8/test/mjsunit/debug-stepout-scope-part7.js +79 -0
  468. data/vendor/v8/test/mjsunit/{debug-stepout-scope.js → debug-stepout-scope-part8.js} +0 -189
  469. data/vendor/v8/test/mjsunit/delete-non-configurable.js +74 -0
  470. data/vendor/v8/test/mjsunit/deopt-minus-zero.js +56 -0
  471. data/vendor/v8/test/mjsunit/elements-kind.js +6 -4
  472. data/vendor/v8/test/mjsunit/elements-length-no-holey.js +33 -0
  473. data/vendor/v8/test/mjsunit/elements-transition-hoisting.js +46 -19
  474. data/vendor/v8/test/mjsunit/error-accessors.js +54 -0
  475. data/vendor/v8/test/mjsunit/error-constructors.js +1 -14
  476. data/vendor/v8/test/mjsunit/error-tostring.js +8 -0
  477. data/vendor/v8/test/mjsunit/eval-stack-trace.js +204 -0
  478. data/vendor/v8/test/mjsunit/external-array.js +364 -1
  479. data/vendor/v8/test/mjsunit/fast-array-length.js +37 -0
  480. data/vendor/v8/test/mjsunit/fast-non-keyed.js +113 -0
  481. data/vendor/v8/test/mjsunit/fast-prototype.js +117 -0
  482. data/vendor/v8/test/mjsunit/function-call.js +14 -18
  483. data/vendor/v8/test/mjsunit/fuzz-natives-part1.js +230 -0
  484. data/vendor/v8/test/mjsunit/fuzz-natives-part2.js +229 -0
  485. data/vendor/v8/test/mjsunit/fuzz-natives-part3.js +229 -0
  486. data/vendor/v8/test/mjsunit/{fuzz-natives.js → fuzz-natives-part4.js} +12 -2
  487. data/vendor/v8/test/mjsunit/generated-transition-stub.js +218 -0
  488. data/vendor/v8/test/mjsunit/greedy.js +1 -1
  489. data/vendor/v8/test/mjsunit/harmony/block-conflicts.js +2 -1
  490. data/vendor/v8/test/mjsunit/harmony/block-let-crankshaft.js +1 -1
  491. data/vendor/v8/test/mjsunit/harmony/collections.js +69 -11
  492. data/vendor/v8/test/mjsunit/harmony/debug-blockscopes.js +2 -2
  493. data/vendor/v8/test/mjsunit/harmony/module-linking.js +180 -3
  494. data/vendor/v8/test/mjsunit/harmony/module-parsing.js +31 -0
  495. data/vendor/v8/test/mjsunit/harmony/module-recompile.js +87 -0
  496. data/vendor/v8/test/mjsunit/harmony/module-resolution.js +15 -2
  497. data/vendor/v8/test/mjsunit/harmony/object-observe.js +1056 -0
  498. data/vendor/v8/test/mjsunit/harmony/proxies-json.js +178 -0
  499. data/vendor/v8/test/mjsunit/harmony/proxies.js +25 -10
  500. data/vendor/v8/test/mjsunit/json-parser-recursive.js +33 -0
  501. data/vendor/v8/test/mjsunit/json-stringify-recursive.js +52 -0
  502. data/vendor/v8/test/mjsunit/json.js +38 -2
  503. data/vendor/v8/test/mjsunit/json2.js +153 -0
  504. data/vendor/v8/test/mjsunit/limit-locals.js +5 -4
  505. data/vendor/v8/test/mjsunit/manual-parallel-recompile.js +79 -0
  506. data/vendor/v8/test/mjsunit/math-exp-precision.js +64 -0
  507. data/vendor/v8/test/mjsunit/math-floor-negative.js +59 -0
  508. data/vendor/v8/test/mjsunit/math-floor-of-div-minus-zero.js +41 -0
  509. data/vendor/v8/test/mjsunit/math-floor-of-div-nosudiv.js +288 -0
  510. data/vendor/v8/test/mjsunit/math-floor-of-div.js +81 -9
  511. data/vendor/v8/test/mjsunit/{math-floor.js → math-floor-part1.js} +1 -72
  512. data/vendor/v8/test/mjsunit/math-floor-part2.js +76 -0
  513. data/vendor/v8/test/mjsunit/math-floor-part3.js +78 -0
  514. data/vendor/v8/test/mjsunit/math-floor-part4.js +76 -0
  515. data/vendor/v8/test/mjsunit/mirror-object.js +43 -9
  516. data/vendor/v8/test/mjsunit/mjsunit.js +1 -1
  517. data/vendor/v8/test/mjsunit/mjsunit.status +52 -27
  518. data/vendor/v8/test/mjsunit/mul-exhaustive-part1.js +491 -0
  519. data/vendor/v8/test/mjsunit/mul-exhaustive-part10.js +470 -0
  520. data/vendor/v8/test/mjsunit/mul-exhaustive-part2.js +525 -0
  521. data/vendor/v8/test/mjsunit/mul-exhaustive-part3.js +532 -0
  522. data/vendor/v8/test/mjsunit/mul-exhaustive-part4.js +509 -0
  523. data/vendor/v8/test/mjsunit/mul-exhaustive-part5.js +505 -0
  524. data/vendor/v8/test/mjsunit/mul-exhaustive-part6.js +554 -0
  525. data/vendor/v8/test/mjsunit/mul-exhaustive-part7.js +497 -0
  526. data/vendor/v8/test/mjsunit/mul-exhaustive-part8.js +526 -0
  527. data/vendor/v8/test/mjsunit/mul-exhaustive-part9.js +533 -0
  528. data/vendor/v8/test/mjsunit/new-function.js +34 -0
  529. data/vendor/v8/test/mjsunit/numops-fuzz-part1.js +1172 -0
  530. data/vendor/v8/test/mjsunit/numops-fuzz-part2.js +1178 -0
  531. data/vendor/v8/test/mjsunit/numops-fuzz-part3.js +1178 -0
  532. data/vendor/v8/test/mjsunit/numops-fuzz-part4.js +1177 -0
  533. data/vendor/v8/test/mjsunit/object-define-property.js +107 -2
  534. data/vendor/v8/test/mjsunit/override-read-only-property.js +6 -4
  535. data/vendor/v8/test/mjsunit/packed-elements.js +2 -2
  536. data/vendor/v8/test/mjsunit/parse-int-float.js +4 -4
  537. data/vendor/v8/test/mjsunit/pixel-array-rounding.js +1 -1
  538. data/vendor/v8/test/mjsunit/readonly.js +228 -0
  539. data/vendor/v8/test/mjsunit/regexp-capture-3.js +16 -18
  540. data/vendor/v8/test/mjsunit/regexp-capture.js +2 -0
  541. data/vendor/v8/test/mjsunit/regexp-global.js +122 -0
  542. data/vendor/v8/test/mjsunit/regexp-results-cache.js +78 -0
  543. data/vendor/v8/test/mjsunit/regress/regress-1117.js +12 -3
  544. data/vendor/v8/test/mjsunit/regress/regress-1118.js +1 -1
  545. data/vendor/v8/test/mjsunit/regress/regress-115100.js +36 -0
  546. data/vendor/v8/test/mjsunit/regress/regress-1199637.js +1 -3
  547. data/vendor/v8/test/mjsunit/regress/regress-121407.js +1 -1
  548. data/vendor/v8/test/mjsunit/regress/regress-131923.js +30 -0
  549. data/vendor/v8/test/mjsunit/regress/regress-131994.js +70 -0
  550. data/vendor/v8/test/mjsunit/regress/regress-133211.js +35 -0
  551. data/vendor/v8/test/mjsunit/regress/regress-133211b.js +39 -0
  552. data/vendor/v8/test/mjsunit/regress/regress-136048.js +34 -0
  553. data/vendor/v8/test/mjsunit/regress/regress-137768.js +73 -0
  554. data/vendor/v8/test/mjsunit/regress/regress-143967.js +34 -0
  555. data/vendor/v8/test/mjsunit/regress/regress-145201.js +107 -0
  556. data/vendor/v8/test/mjsunit/regress/regress-147497.js +45 -0
  557. data/vendor/v8/test/mjsunit/regress/regress-148378.js +38 -0
  558. data/vendor/v8/test/mjsunit/regress/regress-1563.js +1 -1
  559. data/vendor/v8/test/mjsunit/regress/regress-1591.js +48 -0
  560. data/vendor/v8/test/mjsunit/regress/regress-164442.js +45 -0
  561. data/vendor/v8/test/mjsunit/regress/regress-165637.js +61 -0
  562. data/vendor/v8/test/mjsunit/regress/regress-166379.js +39 -0
  563. data/vendor/v8/test/mjsunit/regress/regress-166553.js +33 -0
  564. data/vendor/v8/test/mjsunit/regress/regress-1692.js +1 -1
  565. data/vendor/v8/test/mjsunit/regress/regress-171641.js +40 -0
  566. data/vendor/v8/test/mjsunit/regress/regress-1980.js +1 -1
  567. data/vendor/v8/test/mjsunit/regress/regress-2073.js +99 -0
  568. data/vendor/v8/test/mjsunit/regress/regress-2119.js +36 -0
  569. data/vendor/v8/test/mjsunit/regress/regress-2156.js +39 -0
  570. data/vendor/v8/test/mjsunit/regress/regress-2163.js +70 -0
  571. data/vendor/v8/test/mjsunit/regress/regress-2170.js +58 -0
  572. data/vendor/v8/test/mjsunit/regress/regress-2172.js +35 -0
  573. data/vendor/v8/test/mjsunit/regress/regress-2185-2.js +145 -0
  574. data/vendor/v8/test/mjsunit/regress/regress-2185.js +38 -0
  575. data/vendor/v8/test/mjsunit/regress/regress-2186.js +49 -0
  576. data/vendor/v8/test/mjsunit/regress/regress-2193.js +58 -0
  577. data/vendor/v8/test/mjsunit/regress/regress-2219.js +32 -0
  578. data/vendor/v8/test/mjsunit/regress/regress-2225.js +65 -0
  579. data/vendor/v8/test/mjsunit/regress/regress-2226.js +36 -0
  580. data/vendor/v8/test/mjsunit/regress/regress-2234.js +41 -0
  581. data/vendor/v8/test/mjsunit/regress/regress-2243.js +31 -0
  582. data/vendor/v8/test/mjsunit/regress/regress-2249.js +33 -0
  583. data/vendor/v8/test/mjsunit/regress/regress-2250.js +68 -0
  584. data/vendor/v8/test/mjsunit/regress/regress-2261.js +113 -0
  585. data/vendor/v8/test/mjsunit/regress/regress-2263.js +30 -0
  586. data/vendor/v8/test/mjsunit/regress/regress-2284.js +32 -0
  587. data/vendor/v8/test/mjsunit/regress/regress-2285.js +32 -0
  588. data/vendor/v8/test/mjsunit/regress/regress-2286.js +32 -0
  589. data/vendor/v8/test/mjsunit/regress/regress-2289.js +34 -0
  590. data/vendor/v8/test/mjsunit/regress/regress-2291.js +36 -0
  591. data/vendor/v8/test/mjsunit/regress/regress-2294.js +70 -0
  592. data/vendor/v8/test/mjsunit/regress/regress-2296.js +40 -0
  593. data/vendor/v8/test/mjsunit/regress/regress-2315.js +40 -0
  594. data/vendor/v8/test/mjsunit/regress/regress-2318.js +66 -0
  595. data/vendor/v8/test/mjsunit/regress/regress-2322.js +36 -0
  596. data/vendor/v8/test/mjsunit/regress/regress-2326.js +54 -0
  597. data/vendor/v8/test/mjsunit/regress/regress-2336.js +53 -0
  598. data/vendor/v8/test/mjsunit/regress/regress-2339.js +59 -0
  599. data/vendor/v8/test/mjsunit/regress/regress-2346.js +123 -0
  600. data/vendor/v8/test/mjsunit/regress/regress-2373.js +29 -0
  601. data/vendor/v8/test/mjsunit/regress/regress-2374.js +33 -0
  602. data/vendor/v8/test/mjsunit/regress/regress-2398.js +41 -0
  603. data/vendor/v8/test/mjsunit/regress/regress-2410.js +36 -0
  604. data/vendor/v8/test/mjsunit/regress/regress-2416.js +75 -0
  605. data/vendor/v8/test/mjsunit/regress/regress-2419.js +37 -0
  606. data/vendor/v8/test/mjsunit/regress/regress-2433.js +36 -0
  607. data/vendor/v8/test/mjsunit/regress/regress-2437.js +156 -0
  608. data/vendor/v8/test/mjsunit/regress/regress-2438.js +52 -0
  609. data/vendor/v8/test/mjsunit/regress/regress-2443.js +129 -0
  610. data/vendor/v8/test/mjsunit/regress/regress-2444.js +120 -0
  611. data/vendor/v8/test/mjsunit/regress/regress-2489.js +50 -0
  612. data/vendor/v8/test/mjsunit/regress/regress-2499.js +40 -0
  613. data/vendor/v8/test/mjsunit/regress/regress-334.js +1 -1
  614. data/vendor/v8/test/mjsunit/regress/regress-492.js +39 -1
  615. data/vendor/v8/test/mjsunit/regress/regress-builtin-array-op.js +38 -0
  616. data/vendor/v8/test/mjsunit/regress/regress-cnlt-elements.js +43 -0
  617. data/vendor/v8/test/mjsunit/regress/regress-cnlt-enum-indices.js +45 -0
  618. data/vendor/v8/test/mjsunit/regress/regress-cntl-descriptors-enum.js +46 -0
  619. data/vendor/v8/test/mjsunit/regress/regress-convert-enum.js +60 -0
  620. data/vendor/v8/test/mjsunit/regress/regress-convert-enum2.js +46 -0
  621. data/vendor/v8/test/mjsunit/regress/regress-convert-transition.js +40 -0
  622. data/vendor/v8/test/mjsunit/regress/regress-crbug-119926.js +3 -1
  623. data/vendor/v8/test/mjsunit/regress/regress-crbug-125148.js +90 -0
  624. data/vendor/v8/test/mjsunit/regress/regress-crbug-134055.js +63 -0
  625. data/vendor/v8/test/mjsunit/regress/regress-crbug-134609.js +59 -0
  626. data/vendor/v8/test/mjsunit/regress/regress-crbug-135008.js +45 -0
  627. data/vendor/v8/test/mjsunit/regress/regress-crbug-135066.js +55 -0
  628. data/vendor/v8/test/mjsunit/regress/regress-crbug-137689.js +47 -0
  629. data/vendor/v8/test/mjsunit/regress/regress-crbug-138887.js +48 -0
  630. data/vendor/v8/test/mjsunit/regress/regress-crbug-140083.js +44 -0
  631. data/vendor/v8/test/mjsunit/regress/regress-crbug-142087.js +38 -0
  632. data/vendor/v8/test/mjsunit/regress/regress-crbug-142218.js +44 -0
  633. data/vendor/v8/test/mjsunit/regress/regress-crbug-145961.js +39 -0
  634. data/vendor/v8/test/mjsunit/regress/regress-crbug-146910.js +33 -0
  635. data/vendor/v8/test/mjsunit/regress/regress-crbug-147475.js +48 -0
  636. data/vendor/v8/test/mjsunit/regress/regress-crbug-148376.js +35 -0
  637. data/vendor/v8/test/mjsunit/regress/regress-crbug-150545.js +53 -0
  638. data/vendor/v8/test/mjsunit/regress/regress-crbug-150729.js +39 -0
  639. data/vendor/v8/test/mjsunit/regress/regress-crbug-157019.js +54 -0
  640. data/vendor/v8/test/mjsunit/regress/regress-crbug-157520.js +38 -0
  641. data/vendor/v8/test/mjsunit/regress/regress-crbug-158185.js +39 -0
  642. data/vendor/v8/test/mjsunit/regress/regress-crbug-160010.js +35 -0
  643. data/vendor/v8/test/mjsunit/regress/regress-crbug-162085.js +71 -0
  644. data/vendor/v8/test/mjsunit/regress/regress-crbug-168545.js +34 -0
  645. data/vendor/v8/test/mjsunit/regress/regress-crbug-170856.js +33 -0
  646. data/vendor/v8/test/mjsunit/regress/regress-crbug-172345.js +34 -0
  647. data/vendor/v8/test/mjsunit/regress/regress-crbug-173974.js +36 -0
  648. data/vendor/v8/test/mjsunit/regress/regress-crbug-18639.js +9 -5
  649. data/vendor/v8/test/mjsunit/regress/regress-debug-code-recompilation.js +2 -1
  650. data/vendor/v8/test/mjsunit/regress/regress-deep-proto.js +45 -0
  651. data/vendor/v8/test/mjsunit/regress/regress-delete-empty-double.js +40 -0
  652. data/vendor/v8/test/mjsunit/regress/regress-iteration-order.js +42 -0
  653. data/vendor/v8/test/mjsunit/regress/regress-json-stringify-gc.js +41 -0
  654. data/vendor/v8/test/mjsunit/regress/regress-latin-1.js +78 -0
  655. data/vendor/v8/test/mjsunit/regress/regress-load-elements.js +49 -0
  656. data/vendor/v8/test/mjsunit/regress/regress-observe-empty-double-array.js +38 -0
  657. data/vendor/v8/test/mjsunit/regress/regress-undefined-store-keyed-fast-element.js +37 -0
  658. data/vendor/v8/test/mjsunit/shift-for-integer-div.js +59 -0
  659. data/vendor/v8/test/mjsunit/stack-traces-gc.js +119 -0
  660. data/vendor/v8/test/mjsunit/stack-traces-overflow.js +122 -0
  661. data/vendor/v8/test/mjsunit/stack-traces.js +39 -1
  662. data/vendor/v8/test/mjsunit/str-to-num.js +7 -2
  663. data/vendor/v8/test/mjsunit/strict-mode.js +36 -11
  664. data/vendor/v8/test/mjsunit/string-charcodeat.js +3 -0
  665. data/vendor/v8/test/mjsunit/string-natives.js +72 -0
  666. data/vendor/v8/test/mjsunit/string-split.js +17 -0
  667. data/vendor/v8/test/mjsunit/testcfg.py +76 -6
  668. data/vendor/v8/test/mjsunit/tools/tickprocessor.js +4 -1
  669. data/vendor/v8/test/mjsunit/try-finally-continue.js +72 -0
  670. data/vendor/v8/test/mjsunit/typed-array-slice.js +61 -0
  671. data/vendor/v8/test/mjsunit/unbox-double-arrays.js +2 -0
  672. data/vendor/v8/test/mjsunit/uri.js +12 -0
  673. data/vendor/v8/test/mjsunit/with-readonly.js +4 -2
  674. data/vendor/v8/test/mozilla/mozilla.status +19 -113
  675. data/vendor/v8/test/mozilla/testcfg.py +122 -3
  676. data/vendor/v8/test/preparser/preparser.status +5 -0
  677. data/vendor/v8/test/preparser/strict-identifiers.pyt +1 -1
  678. data/vendor/v8/test/preparser/testcfg.py +101 -5
  679. data/vendor/v8/test/sputnik/sputnik.status +1 -1
  680. data/vendor/v8/test/sputnik/testcfg.py +5 -0
  681. data/vendor/v8/test/test262/README +2 -2
  682. data/vendor/v8/test/test262/test262.status +13 -36
  683. data/vendor/v8/test/test262/testcfg.py +102 -8
  684. data/vendor/v8/tools/android-build.sh +0 -0
  685. data/vendor/v8/tools/android-ll-prof.sh +69 -0
  686. data/vendor/v8/tools/android-run.py +109 -0
  687. data/vendor/v8/tools/android-sync.sh +105 -0
  688. data/vendor/v8/tools/bash-completion.sh +0 -0
  689. data/vendor/v8/tools/check-static-initializers.sh +0 -0
  690. data/vendor/v8/tools/common-includes.sh +15 -22
  691. data/vendor/v8/tools/disasm.py +4 -4
  692. data/vendor/v8/tools/fuzz-harness.sh +0 -0
  693. data/vendor/v8/tools/gen-postmortem-metadata.py +6 -8
  694. data/vendor/v8/tools/grokdump.py +404 -129
  695. data/vendor/v8/tools/gyp/v8.gyp +105 -43
  696. data/vendor/v8/tools/linux-tick-processor +5 -5
  697. data/vendor/v8/tools/ll_prof.py +75 -15
  698. data/vendor/v8/tools/merge-to-branch.sh +2 -2
  699. data/vendor/v8/tools/plot-timer-events +70 -0
  700. data/vendor/v8/tools/plot-timer-events.js +510 -0
  701. data/vendor/v8/tools/presubmit.py +1 -0
  702. data/vendor/v8/tools/push-to-trunk.sh +14 -4
  703. data/vendor/v8/tools/run-llprof.sh +69 -0
  704. data/vendor/v8/tools/run-tests.py +372 -0
  705. data/vendor/v8/tools/run-valgrind.py +1 -1
  706. data/vendor/v8/tools/status-file-converter.py +39 -0
  707. data/vendor/v8/tools/test-server.py +224 -0
  708. data/vendor/v8/tools/test-wrapper-gypbuild.py +13 -16
  709. data/vendor/v8/tools/test.py +10 -19
  710. data/vendor/v8/tools/testrunner/README +174 -0
  711. data/vendor/v8/tools/testrunner/__init__.py +26 -0
  712. data/vendor/v8/tools/testrunner/local/__init__.py +26 -0
  713. data/vendor/v8/tools/testrunner/local/commands.py +153 -0
  714. data/vendor/v8/tools/testrunner/local/execution.py +182 -0
  715. data/vendor/v8/tools/testrunner/local/old_statusfile.py +460 -0
  716. data/vendor/v8/tools/testrunner/local/progress.py +238 -0
  717. data/vendor/v8/tools/testrunner/local/statusfile.py +145 -0
  718. data/vendor/v8/tools/testrunner/local/testsuite.py +187 -0
  719. data/vendor/v8/tools/testrunner/local/utils.py +108 -0
  720. data/vendor/v8/tools/testrunner/local/verbose.py +99 -0
  721. data/vendor/v8/tools/testrunner/network/__init__.py +26 -0
  722. data/vendor/v8/tools/testrunner/network/distro.py +90 -0
  723. data/vendor/v8/tools/testrunner/network/endpoint.py +124 -0
  724. data/vendor/v8/tools/testrunner/network/network_execution.py +253 -0
  725. data/vendor/v8/tools/testrunner/network/perfdata.py +120 -0
  726. data/vendor/v8/tools/testrunner/objects/__init__.py +26 -0
  727. data/vendor/v8/tools/testrunner/objects/context.py +50 -0
  728. data/vendor/v8/tools/testrunner/objects/output.py +60 -0
  729. data/vendor/v8/tools/testrunner/objects/peer.py +80 -0
  730. data/vendor/v8/tools/testrunner/objects/testcase.py +83 -0
  731. data/vendor/v8/tools/testrunner/objects/workpacket.py +90 -0
  732. data/vendor/v8/tools/testrunner/server/__init__.py +26 -0
  733. data/vendor/v8/tools/testrunner/server/compression.py +111 -0
  734. data/vendor/v8/tools/testrunner/server/constants.py +51 -0
  735. data/vendor/v8/tools/testrunner/server/daemon.py +147 -0
  736. data/vendor/v8/tools/testrunner/server/local_handler.py +119 -0
  737. data/vendor/v8/tools/testrunner/server/main.py +245 -0
  738. data/vendor/v8/tools/testrunner/server/presence_handler.py +120 -0
  739. data/vendor/v8/tools/testrunner/server/signatures.py +63 -0
  740. data/vendor/v8/tools/testrunner/server/status_handler.py +112 -0
  741. data/vendor/v8/tools/testrunner/server/work_handler.py +150 -0
  742. data/vendor/v8/tools/tick-processor.html +168 -0
  743. data/vendor/v8/tools/tickprocessor-driver.js +5 -3
  744. data/vendor/v8/tools/tickprocessor.js +58 -15
  745. metadata +534 -30
  746. data/patches/add-freebsd9-and-freebsd10-to-gyp-GetFlavor.patch +0 -11
  747. data/patches/do-not-imply-vfp3-and-armv7.patch +0 -44
  748. data/patches/fPIC-on-x64.patch +0 -14
  749. data/vendor/v8/src/liveobjectlist-inl.h +0 -126
  750. data/vendor/v8/src/liveobjectlist.cc +0 -2631
  751. data/vendor/v8/src/liveobjectlist.h +0 -319
  752. data/vendor/v8/test/mjsunit/mul-exhaustive.js +0 -4629
  753. data/vendor/v8/test/mjsunit/numops-fuzz.js +0 -4609
  754. data/vendor/v8/test/mjsunit/regress/regress-1969.js +0 -5045
@@ -42,15 +42,11 @@ namespace internal {
42
42
 
43
43
 
44
44
  template <class C>
45
- static C* FindInPrototypeChain(Object* obj, bool* found_it) {
46
- ASSERT(!*found_it);
47
- Heap* heap = HEAP;
48
- while (!Is<C>(obj)) {
49
- if (obj == heap->null_value()) return NULL;
50
- obj = obj->GetPrototype();
45
+ static C* FindInstanceOf(Object* obj) {
46
+ for (Object* cur = obj; !cur->IsNull(); cur = cur->GetPrototype()) {
47
+ if (Is<C>(cur)) return C::cast(cur);
51
48
  }
52
- *found_it = true;
53
- return C::cast(obj);
49
+ return NULL;
54
50
  }
55
51
 
56
52
 
@@ -81,10 +77,8 @@ MaybeObject* Accessors::ReadOnlySetAccessor(JSObject*, Object* value, void*) {
81
77
 
82
78
  MaybeObject* Accessors::ArrayGetLength(Object* object, void*) {
83
79
  // Traverse the prototype chain until we reach an array.
84
- bool found_it = false;
85
- JSArray* holder = FindInPrototypeChain<JSArray>(object, &found_it);
86
- if (!found_it) return Smi::FromInt(0);
87
- return holder->length();
80
+ JSArray* holder = FindInstanceOf<JSArray>(object);
81
+ return holder == NULL ? Smi::FromInt(0) : holder->length();
88
82
  }
89
83
 
90
84
 
@@ -92,9 +86,9 @@ MaybeObject* Accessors::ArrayGetLength(Object* object, void*) {
92
86
  Object* Accessors::FlattenNumber(Object* value) {
93
87
  if (value->IsNumber() || !value->IsJSValue()) return value;
94
88
  JSValue* wrapper = JSValue::cast(value);
95
- ASSERT(Isolate::Current()->context()->global_context()->number_function()->
89
+ ASSERT(Isolate::Current()->context()->native_context()->number_function()->
96
90
  has_initial_map());
97
- Map* number_map = Isolate::Current()->context()->global_context()->
91
+ Map* number_map = Isolate::Current()->context()->native_context()->
98
92
  number_function()->initial_map();
99
93
  if (wrapper->map() == number_map) return wrapper->value();
100
94
  return value;
@@ -118,7 +112,7 @@ MaybeObject* Accessors::ArraySetLength(JSObject* object, Object* value, void*) {
118
112
  HandleScope scope(isolate);
119
113
 
120
114
  // Protect raw pointers.
121
- Handle<JSObject> object_handle(object, isolate);
115
+ Handle<JSArray> array_handle(JSArray::cast(object), isolate);
122
116
  Handle<Object> value_handle(value, isolate);
123
117
 
124
118
  bool has_exception;
@@ -128,7 +122,7 @@ MaybeObject* Accessors::ArraySetLength(JSObject* object, Object* value, void*) {
128
122
  if (has_exception) return Failure::Exception();
129
123
 
130
124
  if (uint32_v->Number() == number_v->Number()) {
131
- return Handle<JSArray>::cast(object_handle)->SetElementsLength(*uint32_v);
125
+ return array_handle->SetElementsLength(*uint32_v);
132
126
  }
133
127
  return isolate->Throw(
134
128
  *isolate->factory()->NewRangeError("invalid_array_length",
@@ -448,15 +442,12 @@ const AccessorDescriptor Accessors::ScriptEvalFromFunctionName = {
448
442
 
449
443
  MaybeObject* Accessors::FunctionGetPrototype(Object* object, void*) {
450
444
  Heap* heap = Isolate::Current()->heap();
451
- bool found_it = false;
452
- JSFunction* function = FindInPrototypeChain<JSFunction>(object, &found_it);
453
- if (!found_it) return heap->undefined_value();
445
+ JSFunction* function = FindInstanceOf<JSFunction>(object);
446
+ if (function == NULL) return heap->undefined_value();
454
447
  while (!function->should_have_prototype()) {
455
- found_it = false;
456
- function = FindInPrototypeChain<JSFunction>(object->GetPrototype(),
457
- &found_it);
448
+ function = FindInstanceOf<JSFunction>(function->GetPrototype());
458
449
  // There has to be one because we hit the getter.
459
- ASSERT(found_it);
450
+ ASSERT(function != NULL);
460
451
  }
461
452
 
462
453
  if (!function->has_prototype()) {
@@ -474,25 +465,46 @@ MaybeObject* Accessors::FunctionGetPrototype(Object* object, void*) {
474
465
 
475
466
 
476
467
  MaybeObject* Accessors::FunctionSetPrototype(JSObject* object,
477
- Object* value,
468
+ Object* value_raw,
478
469
  void*) {
479
- Heap* heap = object->GetHeap();
480
- bool found_it = false;
481
- JSFunction* function = FindInPrototypeChain<JSFunction>(object, &found_it);
482
- if (!found_it) return heap->undefined_value();
483
- if (!function->should_have_prototype()) {
470
+ Isolate* isolate = object->GetIsolate();
471
+ Heap* heap = isolate->heap();
472
+ JSFunction* function_raw = FindInstanceOf<JSFunction>(object);
473
+ if (function_raw == NULL) return heap->undefined_value();
474
+ if (!function_raw->should_have_prototype()) {
484
475
  // Since we hit this accessor, object will have no prototype property.
485
476
  return object->SetLocalPropertyIgnoreAttributes(heap->prototype_symbol(),
486
- value,
477
+ value_raw,
487
478
  NONE);
488
479
  }
489
480
 
490
- Object* prototype;
491
- { MaybeObject* maybe_prototype = function->SetPrototype(value);
492
- if (!maybe_prototype->ToObject(&prototype)) return maybe_prototype;
481
+ HandleScope scope(isolate);
482
+ Handle<JSFunction> function(function_raw, isolate);
483
+ Handle<Object> value(value_raw, isolate);
484
+
485
+ Handle<Object> old_value;
486
+ bool is_observed =
487
+ FLAG_harmony_observation &&
488
+ *function == object &&
489
+ function->map()->is_observed();
490
+ if (is_observed) {
491
+ if (function->has_prototype())
492
+ old_value = handle(function->prototype(), isolate);
493
+ else
494
+ old_value = isolate->factory()->NewFunctionPrototype(function);
493
495
  }
494
- ASSERT(function->prototype() == value);
495
- return function;
496
+
497
+ Handle<Object> result;
498
+ MaybeObject* maybe_result = function->SetPrototype(*value);
499
+ if (!maybe_result->ToHandle(&result, isolate)) return maybe_result;
500
+ ASSERT(function->prototype() == *value);
501
+
502
+ if (is_observed && !old_value->SameValue(*value)) {
503
+ JSObject::EnqueueChangeRecord(
504
+ function, "updated", isolate->factory()->prototype_symbol(), old_value);
505
+ }
506
+
507
+ return *function;
496
508
  }
497
509
 
498
510
 
@@ -509,22 +521,20 @@ const AccessorDescriptor Accessors::FunctionPrototype = {
509
521
 
510
522
 
511
523
  MaybeObject* Accessors::FunctionGetLength(Object* object, void*) {
512
- bool found_it = false;
513
- JSFunction* function = FindInPrototypeChain<JSFunction>(object, &found_it);
514
- if (!found_it) return Smi::FromInt(0);
524
+ JSFunction* function = FindInstanceOf<JSFunction>(object);
525
+ if (function == NULL) return Smi::FromInt(0);
515
526
  // Check if already compiled.
516
- if (!function->shared()->is_compiled()) {
517
- // If the function isn't compiled yet, the length is not computed
518
- // correctly yet. Compile it now and return the right length.
519
- HandleScope scope;
520
- Handle<JSFunction> handle(function);
521
- if (!JSFunction::CompileLazy(handle, KEEP_EXCEPTION)) {
522
- return Failure::Exception();
523
- }
524
- return Smi::FromInt(handle->shared()->length());
525
- } else {
527
+ if (function->shared()->is_compiled()) {
526
528
  return Smi::FromInt(function->shared()->length());
527
529
  }
530
+ // If the function isn't compiled yet, the length is not computed correctly
531
+ // yet. Compile it now and return the right length.
532
+ HandleScope scope;
533
+ Handle<JSFunction> handle(function);
534
+ if (JSFunction::CompileLazy(handle, KEEP_EXCEPTION)) {
535
+ return Smi::FromInt(handle->shared()->length());
536
+ }
537
+ return Failure::Exception();
528
538
  }
529
539
 
530
540
 
@@ -541,10 +551,8 @@ const AccessorDescriptor Accessors::FunctionLength = {
541
551
 
542
552
 
543
553
  MaybeObject* Accessors::FunctionGetName(Object* object, void*) {
544
- bool found_it = false;
545
- JSFunction* holder = FindInPrototypeChain<JSFunction>(object, &found_it);
546
- if (!found_it) return HEAP->undefined_value();
547
- return holder->shared()->name();
554
+ JSFunction* holder = FindInstanceOf<JSFunction>(object);
555
+ return holder == NULL ? HEAP->undefined_value() : holder->shared()->name();
548
556
  }
549
557
 
550
558
 
@@ -589,9 +597,8 @@ static MaybeObject* ConstructArgumentsObjectForInlinedFunction(
589
597
  MaybeObject* Accessors::FunctionGetArguments(Object* object, void*) {
590
598
  Isolate* isolate = Isolate::Current();
591
599
  HandleScope scope(isolate);
592
- bool found_it = false;
593
- JSFunction* holder = FindInPrototypeChain<JSFunction>(object, &found_it);
594
- if (!found_it) return isolate->heap()->undefined_value();
600
+ JSFunction* holder = FindInstanceOf<JSFunction>(object);
601
+ if (holder == NULL) return isolate->heap()->undefined_value();
595
602
  Handle<JSFunction> function(holder, isolate);
596
603
 
597
604
  if (function->shared()->native()) return isolate->heap()->null_value();
@@ -664,19 +671,6 @@ const AccessorDescriptor Accessors::FunctionArguments = {
664
671
  //
665
672
 
666
673
 
667
- static MaybeObject* CheckNonStrictCallerOrThrow(
668
- Isolate* isolate,
669
- JSFunction* caller) {
670
- DisableAssertNoAllocation enable_allocation;
671
- if (!caller->shared()->is_classic_mode()) {
672
- return isolate->Throw(
673
- *isolate->factory()->NewTypeError("strict_caller",
674
- HandleVector<Object>(NULL, 0)));
675
- }
676
- return caller;
677
- }
678
-
679
-
680
674
  class FrameFunctionIterator {
681
675
  public:
682
676
  FrameFunctionIterator(Isolate* isolate, const AssertNoAllocation& promise)
@@ -727,9 +721,8 @@ MaybeObject* Accessors::FunctionGetCaller(Object* object, void*) {
727
721
  Isolate* isolate = Isolate::Current();
728
722
  HandleScope scope(isolate);
729
723
  AssertNoAllocation no_alloc;
730
- bool found_it = false;
731
- JSFunction* holder = FindInPrototypeChain<JSFunction>(object, &found_it);
732
- if (!found_it) return isolate->heap()->undefined_value();
724
+ JSFunction* holder = FindInstanceOf<JSFunction>(object);
725
+ if (holder == NULL) return isolate->heap()->undefined_value();
733
726
  if (holder->shared()->native()) return isolate->heap()->null_value();
734
727
  Handle<JSFunction> function(holder, isolate);
735
728
 
@@ -755,13 +748,23 @@ MaybeObject* Accessors::FunctionGetCaller(Object* object, void*) {
755
748
  caller = potential_caller;
756
749
  potential_caller = it.next();
757
750
  }
751
+ if (!caller->shared()->native() && potential_caller != NULL) {
752
+ caller = potential_caller;
753
+ }
758
754
  // If caller is bound, return null. This is compatible with JSC, and
759
755
  // allows us to make bound functions use the strict function map
760
756
  // and its associated throwing caller and arguments.
761
757
  if (caller->shared()->bound()) {
762
758
  return isolate->heap()->null_value();
763
759
  }
764
- return CheckNonStrictCallerOrThrow(isolate, caller);
760
+ // Censor if the caller is not a classic mode function.
761
+ // Change from ES5, which used to throw, see:
762
+ // https://bugs.ecmascript.org/show_bug.cgi?id=310
763
+ if (!caller->shared()->is_classic_mode()) {
764
+ return isolate->heap()->null_value();
765
+ }
766
+
767
+ return caller;
765
768
  }
766
769
 
767
770
 
@@ -777,7 +780,7 @@ const AccessorDescriptor Accessors::FunctionCaller = {
777
780
  //
778
781
 
779
782
 
780
- MaybeObject* Accessors::ObjectGetPrototype(Object* receiver, void*) {
783
+ static inline Object* GetPrototypeSkipHiddenPrototypes(Object* receiver) {
781
784
  Object* current = receiver->GetPrototype();
782
785
  while (current->IsJSObject() &&
783
786
  JSObject::cast(current)->map()->is_hidden_prototype()) {
@@ -787,12 +790,36 @@ MaybeObject* Accessors::ObjectGetPrototype(Object* receiver, void*) {
787
790
  }
788
791
 
789
792
 
790
- MaybeObject* Accessors::ObjectSetPrototype(JSObject* receiver,
791
- Object* value,
793
+ MaybeObject* Accessors::ObjectGetPrototype(Object* receiver, void*) {
794
+ return GetPrototypeSkipHiddenPrototypes(receiver);
795
+ }
796
+
797
+
798
+ MaybeObject* Accessors::ObjectSetPrototype(JSObject* receiver_raw,
799
+ Object* value_raw,
792
800
  void*) {
793
- const bool skip_hidden_prototypes = true;
801
+ const bool kSkipHiddenPrototypes = true;
794
802
  // To be consistent with other Set functions, return the value.
795
- return receiver->SetPrototype(value, skip_hidden_prototypes);
803
+ if (!(FLAG_harmony_observation && receiver_raw->map()->is_observed()))
804
+ return receiver_raw->SetPrototype(value_raw, kSkipHiddenPrototypes);
805
+
806
+ Isolate* isolate = receiver_raw->GetIsolate();
807
+ HandleScope scope(isolate);
808
+ Handle<JSObject> receiver(receiver_raw);
809
+ Handle<Object> value(value_raw);
810
+ Handle<Object> old_value(GetPrototypeSkipHiddenPrototypes(*receiver));
811
+
812
+ MaybeObject* result = receiver->SetPrototype(*value, kSkipHiddenPrototypes);
813
+ Handle<Object> hresult;
814
+ if (!result->ToHandle(&hresult, isolate)) return result;
815
+
816
+ Handle<Object> new_value(GetPrototypeSkipHiddenPrototypes(*receiver));
817
+ if (!new_value->SameValue(*old_value)) {
818
+ JSObject::EnqueueChangeRecord(receiver, "prototype",
819
+ isolate->factory()->Proto_symbol(),
820
+ old_value);
821
+ }
822
+ return *hresult;
796
823
  }
797
824
 
798
825
 
@@ -802,4 +829,69 @@ const AccessorDescriptor Accessors::ObjectPrototype = {
802
829
  0
803
830
  };
804
831
 
832
+
833
+ //
834
+ // Accessors::MakeModuleExport
835
+ //
836
+
837
+ static v8::Handle<v8::Value> ModuleGetExport(
838
+ v8::Local<v8::String> property,
839
+ const v8::AccessorInfo& info) {
840
+ JSModule* instance = JSModule::cast(*v8::Utils::OpenHandle(*info.Holder()));
841
+ Context* context = Context::cast(instance->context());
842
+ ASSERT(context->IsModuleContext());
843
+ int slot = info.Data()->Int32Value();
844
+ Object* value = context->get(slot);
845
+ if (value->IsTheHole()) {
846
+ Handle<String> name = v8::Utils::OpenHandle(*property);
847
+ Isolate* isolate = instance->GetIsolate();
848
+ isolate->ScheduleThrow(
849
+ *isolate->factory()->NewReferenceError("not_defined",
850
+ HandleVector(&name, 1)));
851
+ return v8::Handle<v8::Value>();
852
+ }
853
+ return v8::Utils::ToLocal(Handle<Object>(value));
854
+ }
855
+
856
+
857
+ static void ModuleSetExport(
858
+ v8::Local<v8::String> property,
859
+ v8::Local<v8::Value> value,
860
+ const v8::AccessorInfo& info) {
861
+ JSModule* instance = JSModule::cast(*v8::Utils::OpenHandle(*info.Holder()));
862
+ Context* context = Context::cast(instance->context());
863
+ ASSERT(context->IsModuleContext());
864
+ int slot = info.Data()->Int32Value();
865
+ Object* old_value = context->get(slot);
866
+ if (old_value->IsTheHole()) {
867
+ Handle<String> name = v8::Utils::OpenHandle(*property);
868
+ Isolate* isolate = instance->GetIsolate();
869
+ isolate->ScheduleThrow(
870
+ *isolate->factory()->NewReferenceError("not_defined",
871
+ HandleVector(&name, 1)));
872
+ return;
873
+ }
874
+ context->set(slot, *v8::Utils::OpenHandle(*value));
875
+ }
876
+
877
+
878
+ Handle<AccessorInfo> Accessors::MakeModuleExport(
879
+ Handle<String> name,
880
+ int index,
881
+ PropertyAttributes attributes) {
882
+ Factory* factory = name->GetIsolate()->factory();
883
+ Handle<AccessorInfo> info = factory->NewAccessorInfo();
884
+ info->set_property_attributes(attributes);
885
+ info->set_all_can_read(true);
886
+ info->set_all_can_write(true);
887
+ info->set_name(*name);
888
+ info->set_data(Smi::FromInt(index));
889
+ Handle<Object> getter = v8::FromCData(&ModuleGetExport);
890
+ Handle<Object> setter = v8::FromCData(&ModuleSetExport);
891
+ info->set_getter(*getter);
892
+ if (!(attributes & ReadOnly)) info->set_setter(*setter);
893
+ return info;
894
+ }
895
+
896
+
805
897
  } } // namespace v8::internal
@@ -85,6 +85,10 @@ class Accessors : public AllStatic {
85
85
  void*);
86
86
  static MaybeObject* FunctionGetArguments(Object* object, void*);
87
87
 
88
+ // Accessor infos.
89
+ static Handle<AccessorInfo> MakeModuleExport(
90
+ Handle<String> name, int index, PropertyAttributes attributes);
91
+
88
92
  private:
89
93
  // Accessor functions only used through the descriptor.
90
94
  static MaybeObject* FunctionGetLength(Object* object, void*);
@@ -34,12 +34,12 @@ namespace v8 {
34
34
  namespace internal {
35
35
 
36
36
 
37
- void* PreallocatedStorage::New(size_t size) {
37
+ void* PreallocatedStorageAllocationPolicy::New(size_t size) {
38
38
  return Isolate::Current()->PreallocatedStorageNew(size);
39
39
  }
40
40
 
41
41
 
42
- void PreallocatedStorage::Delete(void* p) {
42
+ void PreallocatedStorageAllocationPolicy::Delete(void* p) {
43
43
  return Isolate::Current()->PreallocatedStorageDelete(p);
44
44
  }
45
45
 
@@ -104,7 +104,7 @@ char* StrNDup(const char* str, int n);
104
104
  // and free. Used as the default policy for lists.
105
105
  class FreeStoreAllocationPolicy {
106
106
  public:
107
- INLINE(static void* New(size_t size)) { return Malloced::New(size); }
107
+ INLINE(void* New(size_t size)) { return Malloced::New(size); }
108
108
  INLINE(static void Delete(void* p)) { Malloced::Delete(p); }
109
109
  };
110
110
 
@@ -117,12 +117,6 @@ class PreallocatedStorage {
117
117
  explicit PreallocatedStorage(size_t size);
118
118
  size_t size() { return size_; }
119
119
 
120
- // TODO(isolates): Get rid of these-- we'll have to change the allocator
121
- // interface to include a pointer to an isolate to do this
122
- // efficiently.
123
- static inline void* New(size_t size);
124
- static inline void Delete(void* p);
125
-
126
120
  private:
127
121
  size_t size_;
128
122
  PreallocatedStorage* previous_;
@@ -137,6 +131,12 @@ class PreallocatedStorage {
137
131
  };
138
132
 
139
133
 
134
+ struct PreallocatedStorageAllocationPolicy {
135
+ INLINE(void* New(size_t size));
136
+ INLINE(static void Delete(void* ptr));
137
+ };
138
+
139
+
140
140
  } } // namespace v8::internal
141
141
 
142
142
  #endif // V8_ALLOCATION_H_
data/vendor/v8/src/api.cc CHANGED
@@ -33,6 +33,7 @@
33
33
  #include "../include/v8-profiler.h"
34
34
  #include "../include/v8-testing.h"
35
35
  #include "bootstrapper.h"
36
+ #include "code-stubs.h"
36
37
  #include "compiler.h"
37
38
  #include "conversions-inl.h"
38
39
  #include "counters.h"
@@ -127,8 +128,13 @@ namespace v8 {
127
128
 
128
129
  static void DefaultFatalErrorHandler(const char* location,
129
130
  const char* message) {
130
- i::VMState __state__(i::Isolate::Current(), i::OTHER);
131
- API_Fatal(location, message);
131
+ i::Isolate* isolate = i::Isolate::Current();
132
+ if (isolate->IsInitialized()) {
133
+ i::VMState __state__(isolate, i::OTHER);
134
+ API_Fatal(location, message);
135
+ } else {
136
+ API_Fatal(location, message);
137
+ }
132
138
  }
133
139
 
134
140
 
@@ -201,15 +207,21 @@ void i::V8::FatalProcessOutOfMemory(const char* location, bool take_snapshot) {
201
207
  int end_marker;
202
208
  heap_stats.end_marker = &end_marker;
203
209
  i::Isolate* isolate = i::Isolate::Current();
204
- // BUG(1718):
205
- // Don't use the take_snapshot since we don't support HeapIterator here
206
- // without doing a special GC.
207
- isolate->heap()->RecordStats(&heap_stats, false);
210
+ if (isolate->heap()->HasBeenSetUp()) {
211
+ // BUG(1718): Don't use the take_snapshot since we don't support
212
+ // HeapIterator here without doing a special GC.
213
+ isolate->heap()->RecordStats(&heap_stats, false);
214
+ }
208
215
  i::V8::SetFatalError();
209
216
  FatalErrorCallback callback = GetFatalErrorHandler();
217
+ const char* message = "Allocation failed - process out of memory";
210
218
  {
211
- LEAVE_V8(isolate);
212
- callback(location, "Allocation failed - process out of memory");
219
+ if (isolate->IsInitialized()) {
220
+ LEAVE_V8(isolate);
221
+ callback(location, message);
222
+ } else {
223
+ callback(location, message);
224
+ }
213
225
  }
214
226
  // If the callback returns, we stop execution.
215
227
  UNREACHABLE();
@@ -540,7 +552,9 @@ Extension::Extension(const char* name,
540
552
  source_(source, source_length_),
541
553
  dep_count_(dep_count),
542
554
  deps_(deps),
543
- auto_enable_(false) { }
555
+ auto_enable_(false) {
556
+ CHECK(source != NULL || source_length_ == 0);
557
+ }
544
558
 
545
559
 
546
560
  v8::Handle<Primitive> Undefined() {
@@ -612,57 +626,36 @@ bool SetResourceConstraints(ResourceConstraints* constraints) {
612
626
  }
613
627
 
614
628
 
615
- i::Object** V8::GlobalizeReference(i::Object** obj) {
616
- i::Isolate* isolate = i::Isolate::Current();
629
+ i::Object** V8::GlobalizeReference(i::Isolate* isolate, i::Object** obj) {
617
630
  if (IsDeadCheck(isolate, "V8::Persistent::New")) return NULL;
618
631
  LOG_API(isolate, "Persistent::New");
619
- i::Handle<i::Object> result =
620
- isolate->global_handles()->Create(*obj);
632
+ i::Handle<i::Object> result = isolate->global_handles()->Create(*obj);
621
633
  return result.location();
622
634
  }
623
635
 
624
636
 
625
- void V8::MakeWeak(i::Object** object, void* parameters,
626
- WeakReferenceCallback callback) {
627
- i::Isolate* isolate = i::Isolate::Current();
637
+ void V8::MakeWeak(i::Isolate* isolate,
638
+ i::Object** object,
639
+ void* parameters,
640
+ WeakReferenceCallback weak_reference_callback,
641
+ NearDeathCallback near_death_callback) {
642
+ ASSERT(isolate == i::Isolate::Current());
628
643
  LOG_API(isolate, "MakeWeak");
629
- isolate->global_handles()->MakeWeak(object, parameters,
630
- callback);
644
+ isolate->global_handles()->MakeWeak(object,
645
+ parameters,
646
+ weak_reference_callback,
647
+ near_death_callback);
631
648
  }
632
649
 
633
650
 
634
- void V8::ClearWeak(i::Object** obj) {
635
- i::Isolate* isolate = i::Isolate::Current();
651
+ void V8::ClearWeak(i::Isolate* isolate, i::Object** obj) {
636
652
  LOG_API(isolate, "ClearWeak");
637
653
  isolate->global_handles()->ClearWeakness(obj);
638
654
  }
639
655
 
640
656
 
641
- void V8::MarkIndependent(i::Object** object) {
642
- i::Isolate* isolate = i::Isolate::Current();
643
- LOG_API(isolate, "MakeIndependent");
644
- isolate->global_handles()->MarkIndependent(object);
645
- }
646
-
647
-
648
- bool V8::IsGlobalNearDeath(i::Object** obj) {
649
- i::Isolate* isolate = i::Isolate::Current();
650
- LOG_API(isolate, "IsGlobalNearDeath");
651
- if (!isolate->IsInitialized()) return false;
652
- return i::GlobalHandles::IsNearDeath(obj);
653
- }
654
-
655
-
656
- bool V8::IsGlobalWeak(i::Object** obj) {
657
- i::Isolate* isolate = i::Isolate::Current();
658
- LOG_API(isolate, "IsGlobalWeak");
659
- if (!isolate->IsInitialized()) return false;
660
- return i::GlobalHandles::IsWeak(obj);
661
- }
662
-
663
-
664
- void V8::DisposeGlobal(i::Object** obj) {
665
- i::Isolate* isolate = i::Isolate::Current();
657
+ void V8::DisposeGlobal(i::Isolate* isolate, i::Object** obj) {
658
+ ASSERT(isolate == i::Isolate::Current());
666
659
  LOG_API(isolate, "DisposeGlobal");
667
660
  if (!isolate->IsInitialized()) return;
668
661
  isolate->global_handles()->Destroy(obj);
@@ -721,6 +714,12 @@ i::Object** HandleScope::CreateHandle(i::Object* value) {
721
714
  }
722
715
 
723
716
 
717
+ i::Object** HandleScope::CreateHandle(i::Isolate* isolate, i::Object* value) {
718
+ ASSERT(isolate == i::Isolate::Current());
719
+ return i::HandleScope::CreateHandle(value, isolate);
720
+ }
721
+
722
+
724
723
  i::Object** HandleScope::CreateHandle(i::HeapObject* value) {
725
724
  ASSERT(value->IsHeapObject());
726
725
  return reinterpret_cast<i::Object**>(
@@ -762,36 +761,77 @@ void Context::Exit() {
762
761
  }
763
762
 
764
763
 
765
- void Context::SetData(v8::Handle<String> data) {
766
- i::Handle<i::Context> env = Utils::OpenHandle(this);
767
- i::Isolate* isolate = env->GetIsolate();
768
- if (IsDeadCheck(isolate, "v8::Context::SetData()")) return;
769
- i::Handle<i::Object> raw_data = Utils::OpenHandle(*data);
770
- ASSERT(env->IsGlobalContext());
771
- if (env->IsGlobalContext()) {
772
- env->set_data(*raw_data);
773
- }
764
+ static void* DecodeSmiToAligned(i::Object* value, const char* location) {
765
+ ApiCheck(value->IsSmi(), location, "Not a Smi");
766
+ return reinterpret_cast<void*>(value);
774
767
  }
775
768
 
776
769
 
777
- v8::Local<v8::Value> Context::GetData() {
778
- i::Handle<i::Context> env = Utils::OpenHandle(this);
779
- i::Isolate* isolate = env->GetIsolate();
780
- if (IsDeadCheck(isolate, "v8::Context::GetData()")) {
781
- return v8::Local<Value>();
782
- }
783
- i::Object* raw_result = NULL;
784
- ASSERT(env->IsGlobalContext());
785
- if (env->IsGlobalContext()) {
786
- raw_result = env->data();
787
- } else {
788
- return Local<Value>();
770
+ static i::Smi* EncodeAlignedAsSmi(void* value, const char* location) {
771
+ i::Smi* smi = reinterpret_cast<i::Smi*>(value);
772
+ ApiCheck(smi->IsSmi(), location, "Pointer is not aligned");
773
+ return smi;
774
+ }
775
+
776
+
777
+ static i::Handle<i::FixedArray> EmbedderDataFor(Context* context,
778
+ int index,
779
+ bool can_grow,
780
+ const char* location) {
781
+ i::Handle<i::Context> env = Utils::OpenHandle(context);
782
+ bool ok = !IsDeadCheck(env->GetIsolate(), location) &&
783
+ ApiCheck(env->IsNativeContext(), location, "Not a native context") &&
784
+ ApiCheck(index >= 0, location, "Negative index");
785
+ if (!ok) return i::Handle<i::FixedArray>();
786
+ i::Handle<i::FixedArray> data(env->embedder_data());
787
+ if (index < data->length()) return data;
788
+ if (!can_grow) {
789
+ Utils::ReportApiFailure(location, "Index too large");
790
+ return i::Handle<i::FixedArray>();
789
791
  }
790
- i::Handle<i::Object> result(raw_result, isolate);
792
+ int new_size = i::Max(index, data->length() << 1) + 1;
793
+ data = env->GetIsolate()->factory()->CopySizeFixedArray(data, new_size);
794
+ env->set_embedder_data(*data);
795
+ return data;
796
+ }
797
+
798
+
799
+ v8::Local<v8::Value> Context::SlowGetEmbedderData(int index) {
800
+ const char* location = "v8::Context::GetEmbedderData()";
801
+ i::Handle<i::FixedArray> data = EmbedderDataFor(this, index, false, location);
802
+ if (data.is_null()) return Local<Value>();
803
+ i::Handle<i::Object> result(data->get(index), data->GetIsolate());
791
804
  return Utils::ToLocal(result);
792
805
  }
793
806
 
794
807
 
808
+ void Context::SetEmbedderData(int index, v8::Handle<Value> value) {
809
+ const char* location = "v8::Context::SetEmbedderData()";
810
+ i::Handle<i::FixedArray> data = EmbedderDataFor(this, index, true, location);
811
+ if (data.is_null()) return;
812
+ i::Handle<i::Object> val = Utils::OpenHandle(*value);
813
+ data->set(index, *val);
814
+ ASSERT_EQ(*Utils::OpenHandle(*value),
815
+ *Utils::OpenHandle(*GetEmbedderData(index)));
816
+ }
817
+
818
+
819
+ void* Context::SlowGetAlignedPointerFromEmbedderData(int index) {
820
+ const char* location = "v8::Context::GetAlignedPointerFromEmbedderData()";
821
+ i::Handle<i::FixedArray> data = EmbedderDataFor(this, index, false, location);
822
+ if (data.is_null()) return NULL;
823
+ return DecodeSmiToAligned(data->get(index), location);
824
+ }
825
+
826
+
827
+ void Context::SetAlignedPointerInEmbedderData(int index, void* value) {
828
+ const char* location = "v8::Context::SetAlignedPointerInEmbedderData()";
829
+ i::Handle<i::FixedArray> data = EmbedderDataFor(this, index, true, location);
830
+ data->set(index, EncodeAlignedAsSmi(value, location));
831
+ ASSERT_EQ(value, GetAlignedPointerFromEmbedderData(index));
832
+ }
833
+
834
+
795
835
  i::Object** v8::HandleScope::RawClose(i::Object** value) {
796
836
  if (!ApiCheck(!is_closed_,
797
837
  "v8::HandleScope::Close()",
@@ -813,7 +853,7 @@ i::Object** v8::HandleScope::RawClose(i::Object** value) {
813
853
  }
814
854
 
815
855
  // Allocate a new handle on the previous handle block.
816
- i::Handle<i::Object> handle(result);
856
+ i::Handle<i::Object> handle(result, isolate_);
817
857
  return handle.location();
818
858
  }
819
859
 
@@ -941,7 +981,7 @@ void FunctionTemplate::Inherit(v8::Handle<FunctionTemplate> value) {
941
981
 
942
982
 
943
983
  Local<FunctionTemplate> FunctionTemplate::New(InvocationCallback callback,
944
- v8::Handle<Value> data, v8::Handle<Signature> signature) {
984
+ v8::Handle<Value> data, v8::Handle<Signature> signature, int length) {
945
985
  i::Isolate* isolate = i::Isolate::Current();
946
986
  EnsureInitializedForIsolate(isolate, "v8::FunctionTemplate::New()");
947
987
  LOG_API(isolate, "FunctionTemplate::New");
@@ -958,6 +998,7 @@ Local<FunctionTemplate> FunctionTemplate::New(InvocationCallback callback,
958
998
  if (data.IsEmpty()) data = v8::Undefined();
959
999
  Utils::ToLocal(obj)->SetCallHandler(callback, data);
960
1000
  }
1001
+ obj->set_length(length);
961
1002
  obj->set_undetectable(false);
962
1003
  obj->set_needs_access_check(false);
963
1004
 
@@ -990,6 +1031,12 @@ Local<Signature> Signature::New(Handle<FunctionTemplate> receiver,
990
1031
  }
991
1032
 
992
1033
 
1034
+ Local<AccessorSignature> AccessorSignature::New(
1035
+ Handle<FunctionTemplate> receiver) {
1036
+ return Utils::AccessorSignatureToLocal(Utils::OpenHandle(*receiver));
1037
+ }
1038
+
1039
+
993
1040
  Local<TypeSwitch> TypeSwitch::New(Handle<FunctionTemplate> type) {
994
1041
  Handle<FunctionTemplate> types[1] = { type };
995
1042
  return TypeSwitch::New(1, types);
@@ -1057,9 +1104,9 @@ static i::Handle<i::AccessorInfo> MakeAccessorInfo(
1057
1104
  AccessorSetter setter,
1058
1105
  v8::Handle<Value> data,
1059
1106
  v8::AccessControl settings,
1060
- v8::PropertyAttribute attributes) {
1107
+ v8::PropertyAttribute attributes,
1108
+ v8::Handle<AccessorSignature> signature) {
1061
1109
  i::Handle<i::AccessorInfo> obj = FACTORY->NewAccessorInfo();
1062
- ASSERT(getter != NULL);
1063
1110
  SET_FIELD_WRAPPED(obj, set_getter, getter);
1064
1111
  SET_FIELD_WRAPPED(obj, set_setter, setter);
1065
1112
  if (data.IsEmpty()) data = v8::Undefined();
@@ -1069,6 +1116,9 @@ static i::Handle<i::AccessorInfo> MakeAccessorInfo(
1069
1116
  if (settings & ALL_CAN_WRITE) obj->set_all_can_write(true);
1070
1117
  if (settings & PROHIBITS_OVERWRITING) obj->set_prohibits_overwriting(true);
1071
1118
  obj->set_property_attributes(static_cast<PropertyAttributes>(attributes));
1119
+ if (!signature.IsEmpty()) {
1120
+ obj->set_expected_receiver_type(*Utils::OpenHandle(*signature));
1121
+ }
1072
1122
  return obj;
1073
1123
  }
1074
1124
 
@@ -1079,7 +1129,8 @@ void FunctionTemplate::AddInstancePropertyAccessor(
1079
1129
  AccessorSetter setter,
1080
1130
  v8::Handle<Value> data,
1081
1131
  v8::AccessControl settings,
1082
- v8::PropertyAttribute attributes) {
1132
+ v8::PropertyAttribute attributes,
1133
+ v8::Handle<AccessorSignature> signature) {
1083
1134
  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1084
1135
  if (IsDeadCheck(isolate,
1085
1136
  "v8::FunctionTemplate::AddInstancePropertyAccessor()")) {
@@ -1088,9 +1139,9 @@ void FunctionTemplate::AddInstancePropertyAccessor(
1088
1139
  ENTER_V8(isolate);
1089
1140
  i::HandleScope scope(isolate);
1090
1141
 
1091
- i::Handle<i::AccessorInfo> obj = MakeAccessorInfo(name,
1092
- getter, setter, data,
1093
- settings, attributes);
1142
+ i::Handle<i::AccessorInfo> obj = MakeAccessorInfo(name, getter, setter, data,
1143
+ settings, attributes,
1144
+ signature);
1094
1145
  i::Handle<i::Object> list(Utils::OpenHandle(this)->property_accessors());
1095
1146
  if (list->IsUndefined()) {
1096
1147
  list = NeanderArray().value();
@@ -1118,6 +1169,14 @@ Local<ObjectTemplate> FunctionTemplate::InstanceTemplate() {
1118
1169
  }
1119
1170
 
1120
1171
 
1172
+ void FunctionTemplate::SetLength(int length) {
1173
+ i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1174
+ if (IsDeadCheck(isolate, "v8::FunctionTemplate::SetLength()")) return;
1175
+ ENTER_V8(isolate);
1176
+ Utils::OpenHandle(this)->set_length(length);
1177
+ }
1178
+
1179
+
1121
1180
  void FunctionTemplate::SetClassName(Handle<String> name) {
1122
1181
  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1123
1182
  if (IsDeadCheck(isolate, "v8::FunctionTemplate::SetClassName()")) return;
@@ -1138,7 +1197,7 @@ void FunctionTemplate::SetHiddenPrototype(bool value) {
1138
1197
 
1139
1198
  void FunctionTemplate::ReadOnlyPrototype() {
1140
1199
  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1141
- if (IsDeadCheck(isolate, "v8::FunctionTemplate::SetPrototypeAttributes()")) {
1200
+ if (IsDeadCheck(isolate, "v8::FunctionTemplate::ReadOnlyPrototype()")) {
1142
1201
  return;
1143
1202
  }
1144
1203
  ENTER_V8(isolate);
@@ -1275,7 +1334,8 @@ void ObjectTemplate::SetAccessor(v8::Handle<String> name,
1275
1334
  AccessorSetter setter,
1276
1335
  v8::Handle<Value> data,
1277
1336
  AccessControl settings,
1278
- PropertyAttribute attribute) {
1337
+ PropertyAttribute attribute,
1338
+ v8::Handle<AccessorSignature> signature) {
1279
1339
  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1280
1340
  if (IsDeadCheck(isolate, "v8::ObjectTemplate::SetAccessor()")) return;
1281
1341
  ENTER_V8(isolate);
@@ -1289,7 +1349,8 @@ void ObjectTemplate::SetAccessor(v8::Handle<String> name,
1289
1349
  setter,
1290
1350
  data,
1291
1351
  settings,
1292
- attribute);
1352
+ attribute,
1353
+ signature);
1293
1354
  }
1294
1355
 
1295
1356
 
@@ -1524,9 +1585,10 @@ Local<Script> Script::New(v8::Handle<String> source,
1524
1585
  name_obj,
1525
1586
  line_offset,
1526
1587
  column_offset,
1588
+ isolate->global_context(),
1527
1589
  NULL,
1528
1590
  pre_data_impl,
1529
- Utils::OpenHandle(*script_data),
1591
+ Utils::OpenHandle(*script_data, true),
1530
1592
  i::NOT_NATIVES_CODE);
1531
1593
  has_pending_exception = result.is_null();
1532
1594
  EXCEPTION_BAILOUT_CHECK(isolate, Local<Script>());
@@ -1579,6 +1641,8 @@ Local<Value> Script::Run() {
1579
1641
  ON_BAILOUT(isolate, "v8::Script::Run()", return Local<Value>());
1580
1642
  LOG_API(isolate, "Script::Run");
1581
1643
  ENTER_V8(isolate);
1644
+ i::Logger::TimerEventScope timer_scope(
1645
+ isolate, i::Logger::TimerEventScope::v8_execute);
1582
1646
  i::Object* raw_result = NULL;
1583
1647
  {
1584
1648
  i::HandleScope scope(isolate);
@@ -1715,7 +1779,7 @@ v8::Local<Value> v8::TryCatch::StackTrace() const {
1715
1779
  if (!raw_obj->IsJSObject()) return v8::Local<Value>();
1716
1780
  i::HandleScope scope(isolate_);
1717
1781
  i::Handle<i::JSObject> obj(i::JSObject::cast(raw_obj), isolate_);
1718
- i::Handle<i::String> name = isolate_->factory()->LookupAsciiSymbol("stack");
1782
+ i::Handle<i::String> name = isolate_->factory()->stack_symbol();
1719
1783
  if (!obj->HasProperty(*name)) return v8::Local<Value>();
1720
1784
  i::Handle<i::Object> value = i::GetProperty(obj, name);
1721
1785
  if (value.is_null()) return v8::Local<Value>();
@@ -1826,7 +1890,7 @@ static i::Handle<i::Object> CallV8HeapFunction(const char* name,
1826
1890
  i::Handle<i::Object> argv[],
1827
1891
  bool* has_pending_exception) {
1828
1892
  i::Isolate* isolate = i::Isolate::Current();
1829
- i::Handle<i::String> fmt_str = isolate->factory()->LookupAsciiSymbol(name);
1893
+ i::Handle<i::String> fmt_str = isolate->factory()->LookupUtf8Symbol(name);
1830
1894
  i::Object* object_fun =
1831
1895
  isolate->js_builtins_object()->GetPropertyNoExceptionThrown(*fmt_str);
1832
1896
  i::Handle<i::JSFunction> fun =
@@ -2177,7 +2241,7 @@ bool Value::IsExternal() const {
2177
2241
  if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsExternal()")) {
2178
2242
  return false;
2179
2243
  }
2180
- return Utils::OpenHandle(this)->IsForeign();
2244
+ return Utils::OpenHandle(this)->IsExternal();
2181
2245
  }
2182
2246
 
2183
2247
 
@@ -2242,7 +2306,7 @@ bool Value::IsNumberObject() const {
2242
2306
  static i::Object* LookupBuiltin(i::Isolate* isolate,
2243
2307
  const char* builtin_name) {
2244
2308
  i::Handle<i::String> symbol =
2245
- isolate->factory()->LookupAsciiSymbol(builtin_name);
2309
+ isolate->factory()->LookupUtf8Symbol(builtin_name);
2246
2310
  i::Handle<i::JSBuiltinsObject> builtins = isolate->js_builtins_object();
2247
2311
  return builtins->GetPropertyNoExceptionThrown(*symbol);
2248
2312
  }
@@ -2251,7 +2315,11 @@ static i::Object* LookupBuiltin(i::Isolate* isolate,
2251
2315
  static bool CheckConstructor(i::Isolate* isolate,
2252
2316
  i::Handle<i::JSObject> obj,
2253
2317
  const char* class_name) {
2254
- return obj->map()->constructor() == LookupBuiltin(isolate, class_name);
2318
+ i::Object* constr = obj->map()->constructor();
2319
+ if (!constr->IsJSFunction()) return false;
2320
+ i::JSFunction* func = i::JSFunction::cast(constr);
2321
+ return func->shared()->native() &&
2322
+ constr == LookupBuiltin(isolate, class_name);
2255
2323
  }
2256
2324
 
2257
2325
 
@@ -2406,8 +2474,7 @@ Local<Integer> Value::ToInteger() const {
2406
2474
 
2407
2475
  void External::CheckCast(v8::Value* that) {
2408
2476
  if (IsDeadCheck(i::Isolate::Current(), "v8::External::Cast()")) return;
2409
- i::Handle<i::Object> obj = Utils::OpenHandle(that);
2410
- ApiCheck(obj->IsForeign(),
2477
+ ApiCheck(Utils::OpenHandle(that)->IsExternal(),
2411
2478
  "v8::External::Cast()",
2412
2479
  "Could not convert to external");
2413
2480
  }
@@ -2752,6 +2819,7 @@ bool v8::Object::Set(v8::Handle<Value> key, v8::Handle<Value> value,
2752
2819
  i::Handle<i::Object> value_obj = Utils::OpenHandle(*value);
2753
2820
  EXCEPTION_PREAMBLE(isolate);
2754
2821
  i::Handle<i::Object> obj = i::SetProperty(
2822
+ isolate,
2755
2823
  self,
2756
2824
  key_obj,
2757
2825
  value_obj,
@@ -2983,7 +3051,7 @@ Local<String> v8::Object::ObjectProtoToString() {
2983
3051
 
2984
3052
  } else {
2985
3053
  i::Handle<i::String> class_name = i::Handle<i::String>::cast(name);
2986
- if (class_name->IsEqualTo(i::CStrVector("Arguments"))) {
3054
+ if (class_name->IsOneByteEqualTo(STATIC_ASCII_VECTOR("Arguments"))) {
2987
3055
  return v8::String::New("[object Object]");
2988
3056
 
2989
3057
  } else {
@@ -3018,6 +3086,17 @@ Local<String> v8::Object::ObjectProtoToString() {
3018
3086
  }
3019
3087
 
3020
3088
 
3089
+ Local<Value> v8::Object::GetConstructor() {
3090
+ i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3091
+ ON_BAILOUT(isolate, "v8::Object::GetConstructor()",
3092
+ return Local<v8::Function>());
3093
+ ENTER_V8(isolate);
3094
+ i::Handle<i::JSObject> self = Utils::OpenHandle(this);
3095
+ i::Handle<i::Object> constructor(self->GetConstructor());
3096
+ return Utils::ToLocal(constructor);
3097
+ }
3098
+
3099
+
3021
3100
  Local<String> v8::Object::GetConstructorName() {
3022
3101
  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3023
3102
  ON_BAILOUT(isolate, "v8::Object::GetConstructorName()",
@@ -3079,9 +3158,10 @@ bool Object::SetAccessor(Handle<String> name,
3079
3158
  ON_BAILOUT(isolate, "v8::Object::SetAccessor()", return false);
3080
3159
  ENTER_V8(isolate);
3081
3160
  i::HandleScope scope(isolate);
3082
- i::Handle<i::AccessorInfo> info = MakeAccessorInfo(name,
3083
- getter, setter, data,
3084
- settings, attributes);
3161
+ v8::Handle<AccessorSignature> signature;
3162
+ i::Handle<i::AccessorInfo> info = MakeAccessorInfo(name, getter, setter, data,
3163
+ settings, attributes,
3164
+ signature);
3085
3165
  bool fast = Utils::OpenHandle(this)->HasFastProperties();
3086
3166
  i::Handle<i::Object> result = i::SetAccessor(Utils::OpenHandle(this), info);
3087
3167
  if (result.is_null() || result->IsUndefined()) return false;
@@ -3209,7 +3289,7 @@ void v8::Object::TurnOnAccessCheck() {
3209
3289
  i::Deoptimizer::DeoptimizeGlobalObject(*obj);
3210
3290
 
3211
3291
  i::Handle<i::Map> new_map =
3212
- isolate->factory()->CopyMapDropTransitions(i::Handle<i::Map>(obj->map()));
3292
+ isolate->factory()->CopyMap(i::Handle<i::Map>(obj->map()));
3213
3293
  new_map->set_is_access_check_needed(true);
3214
3294
  obj->set_map(*new_map);
3215
3295
  }
@@ -3244,7 +3324,7 @@ static i::Context* GetCreationContext(i::JSObject* object) {
3244
3324
  } else {
3245
3325
  function = i::JSFunction::cast(constructor);
3246
3326
  }
3247
- return function->context()->global_context();
3327
+ return function->context()->native_context();
3248
3328
  }
3249
3329
 
3250
3330
 
@@ -3273,13 +3353,15 @@ bool v8::Object::SetHiddenValue(v8::Handle<v8::String> key,
3273
3353
  v8::Handle<v8::Value> value) {
3274
3354
  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3275
3355
  ON_BAILOUT(isolate, "v8::Object::SetHiddenValue()", return false);
3356
+ if (value.IsEmpty()) return DeleteHiddenValue(key);
3276
3357
  ENTER_V8(isolate);
3277
3358
  i::HandleScope scope(isolate);
3278
3359
  i::Handle<i::JSObject> self = Utils::OpenHandle(this);
3279
3360
  i::Handle<i::String> key_obj = Utils::OpenHandle(*key);
3361
+ i::Handle<i::String> key_symbol = FACTORY->LookupSymbol(key_obj);
3280
3362
  i::Handle<i::Object> value_obj = Utils::OpenHandle(*value);
3281
3363
  i::Handle<i::Object> result =
3282
- i::JSObject::SetHiddenProperty(self, key_obj, value_obj);
3364
+ i::JSObject::SetHiddenProperty(self, key_symbol, value_obj);
3283
3365
  return *result == *self;
3284
3366
  }
3285
3367
 
@@ -3291,7 +3373,8 @@ v8::Local<v8::Value> v8::Object::GetHiddenValue(v8::Handle<v8::String> key) {
3291
3373
  ENTER_V8(isolate);
3292
3374
  i::Handle<i::JSObject> self = Utils::OpenHandle(this);
3293
3375
  i::Handle<i::String> key_obj = Utils::OpenHandle(*key);
3294
- i::Handle<i::Object> result(self->GetHiddenProperty(*key_obj));
3376
+ i::Handle<i::String> key_symbol = FACTORY->LookupSymbol(key_obj);
3377
+ i::Handle<i::Object> result(self->GetHiddenProperty(*key_symbol), isolate);
3295
3378
  if (result->IsUndefined()) return v8::Local<v8::Value>();
3296
3379
  return Utils::ToLocal(result);
3297
3380
  }
@@ -3304,7 +3387,8 @@ bool v8::Object::DeleteHiddenValue(v8::Handle<v8::String> key) {
3304
3387
  i::HandleScope scope(isolate);
3305
3388
  i::Handle<i::JSObject> self = Utils::OpenHandle(this);
3306
3389
  i::Handle<i::String> key_obj = Utils::OpenHandle(*key);
3307
- self->DeleteHiddenProperty(*key_obj);
3390
+ i::Handle<i::String> key_symbol = FACTORY->LookupSymbol(key_obj);
3391
+ self->DeleteHiddenProperty(*key_symbol);
3308
3392
  return true;
3309
3393
  }
3310
3394
 
@@ -3372,7 +3456,7 @@ void v8::Object::SetIndexedPropertiesToPixelData(uint8_t* data, int length) {
3372
3456
  ON_BAILOUT(isolate, "v8::SetElementsToPixelData()", return);
3373
3457
  ENTER_V8(isolate);
3374
3458
  i::HandleScope scope(isolate);
3375
- if (!ApiCheck(length <= i::ExternalPixelArray::kMaxLength,
3459
+ if (!ApiCheck(length >= 0 && length <= i::ExternalPixelArray::kMaxLength,
3376
3460
  "v8::Object::SetIndexedPropertiesToPixelData()",
3377
3461
  "length exceeds max acceptable value")) {
3378
3462
  return;
@@ -3428,7 +3512,7 @@ void v8::Object::SetIndexedPropertiesToExternalArrayData(
3428
3512
  ON_BAILOUT(isolate, "v8::SetIndexedPropertiesToExternalArrayData()", return);
3429
3513
  ENTER_V8(isolate);
3430
3514
  i::HandleScope scope(isolate);
3431
- if (!ApiCheck(length <= i::ExternalArray::kMaxLength,
3515
+ if (!ApiCheck(length >= 0 && length <= i::ExternalArray::kMaxLength,
3432
3516
  "v8::Object::SetIndexedPropertiesToExternalArrayData()",
3433
3517
  "length exceeds max acceptable value")) {
3434
3518
  return;
@@ -3527,6 +3611,8 @@ Local<v8::Value> Object::CallAsFunction(v8::Handle<v8::Object> recv,
3527
3611
  return Local<v8::Value>());
3528
3612
  LOG_API(isolate, "Object::CallAsFunction");
3529
3613
  ENTER_V8(isolate);
3614
+ i::Logger::TimerEventScope timer_scope(
3615
+ isolate, i::Logger::TimerEventScope::v8_execute);
3530
3616
  i::HandleScope scope(isolate);
3531
3617
  i::Handle<i::JSObject> obj = Utils::OpenHandle(this);
3532
3618
  i::Handle<i::Object> recv_obj = Utils::OpenHandle(*recv);
@@ -3558,6 +3644,8 @@ Local<v8::Value> Object::CallAsConstructor(int argc,
3558
3644
  return Local<v8::Object>());
3559
3645
  LOG_API(isolate, "Object::CallAsConstructor");
3560
3646
  ENTER_V8(isolate);
3647
+ i::Logger::TimerEventScope timer_scope(
3648
+ isolate, i::Logger::TimerEventScope::v8_execute);
3561
3649
  i::HandleScope scope(isolate);
3562
3650
  i::Handle<i::JSObject> obj = Utils::OpenHandle(this);
3563
3651
  STATIC_ASSERT(sizeof(v8::Handle<v8::Value>) == sizeof(i::Object**));
@@ -3600,6 +3688,8 @@ Local<v8::Object> Function::NewInstance(int argc,
3600
3688
  return Local<v8::Object>());
3601
3689
  LOG_API(isolate, "Function::NewInstance");
3602
3690
  ENTER_V8(isolate);
3691
+ i::Logger::TimerEventScope timer_scope(
3692
+ isolate, i::Logger::TimerEventScope::v8_execute);
3603
3693
  HandleScope scope;
3604
3694
  i::Handle<i::JSFunction> function = Utils::OpenHandle(this);
3605
3695
  STATIC_ASSERT(sizeof(v8::Handle<v8::Value>) == sizeof(i::Object**));
@@ -3618,6 +3708,8 @@ Local<v8::Value> Function::Call(v8::Handle<v8::Object> recv, int argc,
3618
3708
  ON_BAILOUT(isolate, "v8::Function::Call()", return Local<v8::Value>());
3619
3709
  LOG_API(isolate, "Function::Call");
3620
3710
  ENTER_V8(isolate);
3711
+ i::Logger::TimerEventScope timer_scope(
3712
+ isolate, i::Logger::TimerEventScope::v8_execute);
3621
3713
  i::Object* raw_result = NULL;
3622
3714
  {
3623
3715
  i::HandleScope scope(isolate);
@@ -3661,8 +3753,9 @@ ScriptOrigin Function::GetScriptOrigin() const {
3661
3753
  i::Handle<i::JSFunction> func = Utils::OpenHandle(this);
3662
3754
  if (func->shared()->script()->IsScript()) {
3663
3755
  i::Handle<i::Script> script(i::Script::cast(func->shared()->script()));
3756
+ i::Handle<i::Object> scriptName = GetScriptNameOrSourceURL(script);
3664
3757
  v8::ScriptOrigin origin(
3665
- Utils::ToLocal(i::Handle<i::Object>(script->name())),
3758
+ Utils::ToLocal(scriptName),
3666
3759
  v8::Integer::New(script->line_offset()->value()),
3667
3760
  v8::Integer::New(script->column_offset()->value()));
3668
3761
  return origin;
@@ -3707,109 +3800,238 @@ int String::Length() const {
3707
3800
  return str->length();
3708
3801
  }
3709
3802
 
3803
+ bool String::MayContainNonAscii() const {
3804
+ i::Handle<i::String> str = Utils::OpenHandle(this);
3805
+ if (IsDeadCheck(str->GetIsolate(), "v8::String::MayContainNonAscii()")) {
3806
+ return false;
3807
+ }
3808
+ return !str->HasOnlyAsciiChars();
3809
+ }
3810
+
3811
+
3812
+ bool String::IsOneByte() const {
3813
+ i::Handle<i::String> str = Utils::OpenHandle(this);
3814
+ if (IsDeadCheck(str->GetIsolate(), "v8::String::IsOneByte()")) {
3815
+ return false;
3816
+ }
3817
+ return str->IsOneByteConvertible();
3818
+ }
3819
+
3820
+
3821
+ class Utf8LengthVisitor {
3822
+ public:
3823
+ explicit Utf8LengthVisitor()
3824
+ : utf8_length_(0),
3825
+ last_character_(unibrow::Utf16::kNoPreviousCharacter) {}
3826
+
3827
+ inline int GetLength() {
3828
+ return utf8_length_;
3829
+ }
3830
+
3831
+ template<typename Char>
3832
+ inline void Visit(const Char* chars, unsigned length) {
3833
+ ASSERT(length > 0);
3834
+ // TODO(dcarney) Add back ascii fast path.
3835
+ int utf8_length = 0;
3836
+ int last_character = last_character_;
3837
+ for (unsigned i = 0; i < length; i++) {
3838
+ uint16_t c = chars[i];
3839
+ utf8_length += unibrow::Utf8::Length(c, last_character);
3840
+ last_character = c;
3841
+ }
3842
+ last_character_ = last_character;
3843
+ utf8_length_ += utf8_length;
3844
+ }
3845
+
3846
+ inline void VisitOneByteString(const uint8_t* chars, unsigned length) {
3847
+ Visit(chars, length);
3848
+ }
3849
+
3850
+ inline void VisitTwoByteString(const uint16_t* chars, unsigned length) {
3851
+ Visit(chars, length);
3852
+ }
3853
+
3854
+ private:
3855
+ int utf8_length_;
3856
+ int last_character_;
3857
+ DISALLOW_COPY_AND_ASSIGN(Utf8LengthVisitor);
3858
+ };
3859
+
3860
+
3861
+ static int Utf8Length(i::String* str, i::Isolate* isolate) {
3862
+ unsigned length = static_cast<unsigned>(str->length());
3863
+ if (length == 0) return 0;
3864
+ int32_t type = str->map()->instance_type();
3865
+ Utf8LengthVisitor visitor;
3866
+ // Non ConsString branch.
3867
+ if ((type & i::kStringRepresentationMask) != i::kConsStringTag) {
3868
+ i::ConsStringNullOp null_op;
3869
+ i::String::Visit(str, 0, visitor, null_op, type, length);
3870
+ return visitor.GetLength();
3871
+ }
3872
+ i::ConsStringIteratorOp* op = isolate->write_iterator();
3873
+ unsigned offset = 0;
3874
+ i::String* leaf = op->Operate(str, &offset, &type, &length);
3875
+ ASSERT(leaf != NULL);
3876
+ while (leaf != NULL) {
3877
+ i::ConsStringNullOp null_op;
3878
+ ASSERT(offset == 0);
3879
+ i::String::Visit(leaf, 0, visitor, null_op, type, length);
3880
+ leaf = op->ContinueOperation(&type, &length);
3881
+ }
3882
+ return visitor.GetLength();
3883
+ }
3884
+
3710
3885
 
3711
3886
  int String::Utf8Length() const {
3712
3887
  i::Handle<i::String> str = Utils::OpenHandle(this);
3713
- if (IsDeadCheck(str->GetIsolate(), "v8::String::Utf8Length()")) return 0;
3714
- return i::Utf8Length(str);
3715
- }
3716
-
3717
-
3718
- // Will fail with a negative answer if the recursion depth is too high.
3719
- static int RecursivelySerializeToUtf8(i::String* string,
3720
- char* buffer,
3721
- int start,
3722
- int end,
3723
- int recursion_budget,
3724
- int32_t previous_character,
3725
- int32_t* last_character) {
3726
- int utf8_bytes = 0;
3727
- while (true) {
3728
- if (string->IsAsciiRepresentation()) {
3729
- i::String::WriteToFlat(string, buffer, start, end);
3730
- *last_character = unibrow::Utf16::kNoPreviousCharacter;
3731
- return utf8_bytes + end - start;
3888
+ i::Isolate* isolate = str->GetIsolate();
3889
+ if (IsDeadCheck(isolate, "v8::String::Utf8Length()")) return 0;
3890
+ return v8::Utf8Length(*str, isolate);
3891
+ }
3892
+
3893
+
3894
+ class Utf8WriterVisitor {
3895
+ public:
3896
+ Utf8WriterVisitor(char* buffer, int capacity)
3897
+ : early_termination_(false),
3898
+ last_character_(unibrow::Utf16::kNoPreviousCharacter),
3899
+ buffer_(buffer),
3900
+ start_(buffer),
3901
+ capacity_(capacity),
3902
+ utf16_chars_read_(0) {
3903
+ }
3904
+
3905
+ static int WriteEndCharacter(uint16_t character,
3906
+ int last_character,
3907
+ int remaining,
3908
+ char* const buffer) {
3909
+ using namespace unibrow;
3910
+ ASSERT(remaining > 0);
3911
+ // We can't use a local buffer here because Encode needs to modify
3912
+ // previous characters in the stream. We know, however, that
3913
+ // exactly one character will be advanced.
3914
+ if (Utf16::IsTrailSurrogate(character) &&
3915
+ Utf16::IsLeadSurrogate(last_character)) {
3916
+ int written = Utf8::Encode(buffer, character, last_character);
3917
+ ASSERT(written == 1);
3918
+ return written;
3919
+ }
3920
+ // Use a scratch buffer to check the required characters.
3921
+ char temp_buffer[Utf8::kMaxEncodedSize];
3922
+ // Can't encode using last_character as gcc has array bounds issues.
3923
+ int written = Utf8::Encode(temp_buffer,
3924
+ character,
3925
+ unibrow::Utf16::kNoPreviousCharacter);
3926
+ // Won't fit.
3927
+ if (written > remaining) return 0;
3928
+ // Copy over the character from temp_buffer.
3929
+ for (int j = 0; j < written; j++) {
3930
+ buffer[j] = temp_buffer[j];
3732
3931
  }
3733
- switch (i::StringShape(string).representation_tag()) {
3734
- case i::kExternalStringTag: {
3735
- const uint16_t* data = i::ExternalTwoByteString::cast(string)->
3736
- ExternalTwoByteStringGetData(0);
3737
- char* current = buffer;
3738
- for (int i = start; i < end; i++) {
3739
- uint16_t character = data[i];
3740
- current +=
3741
- unibrow::Utf8::Encode(current, character, previous_character);
3742
- previous_character = character;
3743
- }
3744
- *last_character = previous_character;
3745
- return static_cast<int>(utf8_bytes + current - buffer);
3932
+ return written;
3933
+ }
3934
+
3935
+ template<typename Char>
3936
+ void Visit(const Char* chars, const int length) {
3937
+ using namespace unibrow;
3938
+ // TODO(dcarney): Add back ascii fast path.
3939
+ ASSERT(!early_termination_);
3940
+ ASSERT(length > 0);
3941
+ // Copy state to stack.
3942
+ char* buffer = buffer_;
3943
+ int last_character = last_character_;
3944
+ int i = 0;
3945
+ // Do a fast loop where there is no exit capacity check.
3946
+ while (true) {
3947
+ int fast_length;
3948
+ if (capacity_ == -1) {
3949
+ fast_length = length;
3950
+ } else {
3951
+ int remaining_capacity = capacity_ - static_cast<int>(buffer - start_);
3952
+ // Need enough space to write everything but one character.
3953
+ STATIC_ASSERT(Utf16::kMaxExtraUtf8BytesForOneUtf16CodeUnit == 3);
3954
+ int writable_length = (remaining_capacity - 3)/3;
3955
+ // Need to drop into slow loop.
3956
+ if (writable_length <= 0) break;
3957
+ fast_length = i + writable_length;
3958
+ if (fast_length > length) fast_length = length;
3746
3959
  }
3747
- case i::kSeqStringTag: {
3748
- const uint16_t* data =
3749
- i::SeqTwoByteString::cast(string)->SeqTwoByteStringGetData(0);
3750
- char* current = buffer;
3751
- for (int i = start; i < end; i++) {
3752
- uint16_t character = data[i];
3753
- current +=
3754
- unibrow::Utf8::Encode(current, character, previous_character);
3755
- previous_character = character;
3756
- }
3757
- *last_character = previous_character;
3758
- return static_cast<int>(utf8_bytes + current - buffer);
3960
+ // Write the characters to the stream.
3961
+ for (; i < fast_length; i++) {
3962
+ uint16_t character = *chars++;
3963
+ buffer += Utf8::Encode(buffer, character, last_character);
3964
+ last_character = character;
3965
+ ASSERT(capacity_ == -1 || (buffer - start_) <= capacity_);
3759
3966
  }
3760
- case i::kSlicedStringTag: {
3761
- i::SlicedString* slice = i::SlicedString::cast(string);
3762
- unsigned offset = slice->offset();
3763
- string = slice->parent();
3764
- start += offset;
3765
- end += offset;
3766
- continue;
3967
+ // Array is fully written. Exit.
3968
+ if (fast_length == length) {
3969
+ // Write state back out to object.
3970
+ last_character_ = last_character;
3971
+ buffer_ = buffer;
3972
+ utf16_chars_read_ += i;
3973
+ return;
3767
3974
  }
3768
- case i::kConsStringTag: {
3769
- i::ConsString* cons_string = i::ConsString::cast(string);
3770
- i::String* first = cons_string->first();
3771
- int boundary = first->length();
3772
- if (start >= boundary) {
3773
- // Only need RHS.
3774
- string = cons_string->second();
3775
- start -= boundary;
3776
- end -= boundary;
3777
- continue;
3778
- } else if (end <= boundary) {
3779
- // Only need LHS.
3780
- string = first;
3781
- } else {
3782
- if (recursion_budget == 0) return -1;
3783
- int extra_utf8_bytes =
3784
- RecursivelySerializeToUtf8(first,
3785
- buffer,
3786
- start,
3787
- boundary,
3788
- recursion_budget - 1,
3789
- previous_character,
3790
- &previous_character);
3791
- if (extra_utf8_bytes < 0) return extra_utf8_bytes;
3792
- buffer += extra_utf8_bytes;
3793
- utf8_bytes += extra_utf8_bytes;
3794
- string = cons_string->second();
3795
- start = 0;
3796
- end -= boundary;
3797
- }
3975
+ }
3976
+ ASSERT(capacity_ != -1);
3977
+ // Slow loop. Must check capacity on each iteration.
3978
+ int remaining_capacity = capacity_ - static_cast<int>(buffer - start_);
3979
+ ASSERT(remaining_capacity >= 0);
3980
+ for (; i < length && remaining_capacity > 0; i++) {
3981
+ uint16_t character = *chars++;
3982
+ int written = WriteEndCharacter(character,
3983
+ last_character,
3984
+ remaining_capacity,
3985
+ buffer);
3986
+ if (written == 0) {
3987
+ early_termination_ = true;
3988
+ break;
3798
3989
  }
3990
+ buffer += written;
3991
+ remaining_capacity -= written;
3992
+ last_character = character;
3799
3993
  }
3994
+ // Write state back out to object.
3995
+ last_character_ = last_character;
3996
+ buffer_ = buffer;
3997
+ utf16_chars_read_ += i;
3800
3998
  }
3801
- UNREACHABLE();
3802
- return 0;
3803
- }
3804
3999
 
4000
+ inline bool IsDone() {
4001
+ return early_termination_;
4002
+ }
3805
4003
 
3806
- bool String::MayContainNonAscii() const {
3807
- i::Handle<i::String> str = Utils::OpenHandle(this);
3808
- if (IsDeadCheck(str->GetIsolate(), "v8::String::MayContainNonAscii()")) {
3809
- return false;
4004
+ inline void VisitOneByteString(const uint8_t* chars, unsigned length) {
4005
+ Visit(chars, static_cast<int>(length));
4006
+ }
4007
+
4008
+ inline void VisitTwoByteString(const uint16_t* chars, unsigned length) {
4009
+ Visit(chars, static_cast<int>(length));
4010
+ }
4011
+
4012
+ inline int CompleteWrite(bool write_null, int* utf16_chars_read_out) {
4013
+ // Write out number of utf16 characters written to the stream.
4014
+ if (utf16_chars_read_out != NULL) {
4015
+ *utf16_chars_read_out = utf16_chars_read_;
4016
+ }
4017
+ // Only null terminate if all of the string was written and there's space.
4018
+ if (write_null &&
4019
+ !early_termination_ &&
4020
+ (capacity_ == -1 || (buffer_ - start_) < capacity_)) {
4021
+ *buffer_++ = '\0';
4022
+ }
4023
+ return static_cast<int>(buffer_ - start_);
3810
4024
  }
3811
- return !str->HasOnlyAsciiChars();
3812
- }
4025
+
4026
+ private:
4027
+ bool early_termination_;
4028
+ int last_character_;
4029
+ char* buffer_;
4030
+ char* const start_;
4031
+ int capacity_;
4032
+ int utf16_chars_read_;
4033
+ DISALLOW_IMPLICIT_CONSTRUCTORS(Utf8WriterVisitor);
4034
+ };
3813
4035
 
3814
4036
 
3815
4037
  int String::WriteUtf8(char* buffer,
@@ -3821,125 +4043,26 @@ int String::WriteUtf8(char* buffer,
3821
4043
  LOG_API(isolate, "String::WriteUtf8");
3822
4044
  ENTER_V8(isolate);
3823
4045
  i::Handle<i::String> str = Utils::OpenHandle(this);
3824
- int string_length = str->length();
3825
- if (str->IsAsciiRepresentation()) {
3826
- int len;
3827
- if (capacity == -1) {
3828
- capacity = str->length() + 1;
3829
- len = string_length;
3830
- } else {
3831
- len = i::Min(capacity, str->length());
3832
- }
3833
- i::String::WriteToFlat(*str, buffer, 0, len);
3834
- if (nchars_ref != NULL) *nchars_ref = len;
3835
- if (!(options & NO_NULL_TERMINATION) && capacity > len) {
3836
- buffer[len] = '\0';
3837
- return len + 1;
3838
- }
3839
- return len;
3840
- }
3841
-
3842
- if (capacity == -1 || capacity / 3 >= string_length) {
3843
- int32_t previous = unibrow::Utf16::kNoPreviousCharacter;
3844
- const int kMaxRecursion = 100;
3845
- int utf8_bytes =
3846
- RecursivelySerializeToUtf8(*str,
3847
- buffer,
3848
- 0,
3849
- string_length,
3850
- kMaxRecursion,
3851
- previous,
3852
- &previous);
3853
- if (utf8_bytes >= 0) {
3854
- // Success serializing with recursion.
3855
- if ((options & NO_NULL_TERMINATION) == 0 &&
3856
- (capacity > utf8_bytes || capacity == -1)) {
3857
- buffer[utf8_bytes++] = '\0';
3858
- }
3859
- if (nchars_ref != NULL) *nchars_ref = string_length;
3860
- return utf8_bytes;
3861
- }
3862
- FlattenString(str);
3863
- // Recurse once. This time around the string is flat and the serializing
3864
- // with recursion will certainly succeed.
3865
- return WriteUtf8(buffer, capacity, nchars_ref, options);
3866
- } else if (capacity >= string_length) {
3867
- // First check that the buffer is large enough. If it is, then recurse
3868
- // once without a capacity limit, which will get into the other branch of
3869
- // this 'if'.
3870
- int utf8_bytes = i::Utf8Length(str);
3871
- if ((options & NO_NULL_TERMINATION) == 0) utf8_bytes++;
3872
- if (utf8_bytes <= capacity) {
3873
- return WriteUtf8(buffer, -1, nchars_ref, options);
3874
- }
3875
- }
3876
-
3877
- // Slow case.
3878
- i::StringInputBuffer& write_input_buffer = *isolate->write_input_buffer();
3879
- isolate->string_tracker()->RecordWrite(str);
3880
4046
  if (options & HINT_MANY_WRITES_EXPECTED) {
3881
- // Flatten the string for efficiency. This applies whether we are
3882
- // using StringInputBuffer or Get(i) to access the characters.
3883
- FlattenString(str);
3884
- }
3885
- write_input_buffer.Reset(0, *str);
3886
- int len = str->length();
3887
- // Encode the first K - 3 bytes directly into the buffer since we
3888
- // know there's room for them. If no capacity is given we copy all
3889
- // of them here.
3890
- int fast_end = capacity - (unibrow::Utf8::kMaxEncodedSize - 1);
3891
- int i;
3892
- int pos = 0;
3893
- int nchars = 0;
3894
- int previous = unibrow::Utf16::kNoPreviousCharacter;
3895
- for (i = 0; i < len && (capacity == -1 || pos < fast_end); i++) {
3896
- i::uc32 c = write_input_buffer.GetNext();
3897
- int written = unibrow::Utf8::Encode(buffer + pos, c, previous);
3898
- pos += written;
3899
- nchars++;
3900
- previous = c;
3901
- }
3902
- if (i < len) {
3903
- // For the last characters we need to check the length for each one
3904
- // because they may be longer than the remaining space in the
3905
- // buffer.
3906
- char intermediate[unibrow::Utf8::kMaxEncodedSize];
3907
- for (; i < len && pos < capacity; i++) {
3908
- i::uc32 c = write_input_buffer.GetNext();
3909
- if (unibrow::Utf16::IsTrailSurrogate(c) &&
3910
- unibrow::Utf16::IsLeadSurrogate(previous)) {
3911
- // We can't use the intermediate buffer here because the encoding
3912
- // of surrogate pairs is done under assumption that you can step
3913
- // back and fix the UTF8 stream. Luckily we only need space for one
3914
- // more byte, so there is always space.
3915
- ASSERT(pos < capacity);
3916
- int written = unibrow::Utf8::Encode(buffer + pos, c, previous);
3917
- ASSERT(written == 1);
3918
- pos += written;
3919
- nchars++;
3920
- } else {
3921
- int written =
3922
- unibrow::Utf8::Encode(intermediate,
3923
- c,
3924
- unibrow::Utf16::kNoPreviousCharacter);
3925
- if (pos + written <= capacity) {
3926
- for (int j = 0; j < written; j++)
3927
- buffer[pos + j] = intermediate[j];
3928
- pos += written;
3929
- nchars++;
3930
- } else {
3931
- // We've reached the end of the buffer
3932
- break;
3933
- }
3934
- }
3935
- previous = c;
4047
+ FlattenString(str); // Flatten the string for efficiency.
4048
+ }
4049
+ Utf8WriterVisitor writer(buffer, capacity);
4050
+ i::ConsStringIteratorOp* op = isolate->write_iterator();
4051
+ op->Reset();
4052
+ int32_t type = str->map()->instance_type();
4053
+ unsigned str_length = static_cast<unsigned>(str->length());
4054
+ if (str_length != 0) {
4055
+ i::String::Visit(*str, 0, writer, *op, type, str_length);
4056
+ while (!writer.IsDone()) {
4057
+ unsigned length_out;
4058
+ i::String* next = op->ContinueOperation(&type, &length_out);
4059
+ if (next == NULL) break;
4060
+ // TODO(dcarney): need an asserting null op.
4061
+ i::ConsStringNullOp null_op;
4062
+ i::String::Visit(next, 0, writer, null_op, type, length_out);
3936
4063
  }
3937
4064
  }
3938
- if (nchars_ref != NULL) *nchars_ref = nchars;
3939
- if (!(options & NO_NULL_TERMINATION) &&
3940
- (i == len && (capacity == -1 || pos < capacity)))
3941
- buffer[pos++] = '\0';
3942
- return pos;
4065
+ return writer.CompleteWrite(!(options & NO_NULL_TERMINATION), nchars_ref);
3943
4066
  }
3944
4067
 
3945
4068
 
@@ -3951,54 +4074,75 @@ int String::WriteAscii(char* buffer,
3951
4074
  if (IsDeadCheck(isolate, "v8::String::WriteAscii()")) return 0;
3952
4075
  LOG_API(isolate, "String::WriteAscii");
3953
4076
  ENTER_V8(isolate);
3954
- i::StringInputBuffer& write_input_buffer = *isolate->write_input_buffer();
3955
4077
  ASSERT(start >= 0 && length >= -1);
3956
4078
  i::Handle<i::String> str = Utils::OpenHandle(this);
3957
4079
  isolate->string_tracker()->RecordWrite(str);
3958
4080
  if (options & HINT_MANY_WRITES_EXPECTED) {
3959
- // Flatten the string for efficiency. This applies whether we are
3960
- // using StringInputBuffer or Get(i) to access the characters.
3961
- str->TryFlatten();
4081
+ FlattenString(str); // Flatten the string for efficiency.
4082
+ }
4083
+
4084
+ if (str->HasOnlyAsciiChars()) {
4085
+ // WriteToFlat is faster than using the StringCharacterStream.
4086
+ if (length == -1) length = str->length() + 1;
4087
+ int len = i::Min(length, str->length() - start);
4088
+ i::String::WriteToFlat(*str,
4089
+ reinterpret_cast<uint8_t*>(buffer),
4090
+ start,
4091
+ start + len);
4092
+ if (!(options & PRESERVE_ASCII_NULL)) {
4093
+ for (int i = 0; i < len; i++) {
4094
+ if (buffer[i] == '\0') buffer[i] = ' ';
4095
+ }
4096
+ }
4097
+ if (!(options & NO_NULL_TERMINATION) && length > len) {
4098
+ buffer[len] = '\0';
4099
+ }
4100
+ return len;
3962
4101
  }
4102
+
3963
4103
  int end = length;
3964
- if ( (length == -1) || (length > str->length() - start) )
4104
+ if ((length == -1) || (length > str->length() - start)) {
3965
4105
  end = str->length() - start;
4106
+ }
3966
4107
  if (end < 0) return 0;
3967
- write_input_buffer.Reset(start, *str);
4108
+ i::StringCharacterStream write_stream(*str, isolate->write_iterator(), start);
3968
4109
  int i;
3969
4110
  for (i = 0; i < end; i++) {
3970
- char c = static_cast<char>(write_input_buffer.GetNext());
3971
- if (c == '\0') c = ' ';
4111
+ char c = static_cast<char>(write_stream.GetNext());
4112
+ if (c == '\0' && !(options & PRESERVE_ASCII_NULL)) c = ' ';
3972
4113
  buffer[i] = c;
3973
4114
  }
3974
- if (!(options & NO_NULL_TERMINATION) && (length == -1 || i < length))
4115
+ if (!(options & NO_NULL_TERMINATION) && (length == -1 || i < length)) {
3975
4116
  buffer[i] = '\0';
4117
+ }
3976
4118
  return i;
3977
4119
  }
3978
4120
 
3979
4121
 
3980
- int String::Write(uint16_t* buffer,
3981
- int start,
3982
- int length,
3983
- int options) const {
3984
- i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
4122
+ template<typename CharType>
4123
+ static inline int WriteHelper(const String* string,
4124
+ CharType* buffer,
4125
+ int start,
4126
+ int length,
4127
+ int options) {
4128
+ i::Isolate* isolate = Utils::OpenHandle(string)->GetIsolate();
3985
4129
  if (IsDeadCheck(isolate, "v8::String::Write()")) return 0;
3986
4130
  LOG_API(isolate, "String::Write");
3987
4131
  ENTER_V8(isolate);
3988
4132
  ASSERT(start >= 0 && length >= -1);
3989
- i::Handle<i::String> str = Utils::OpenHandle(this);
4133
+ i::Handle<i::String> str = Utils::OpenHandle(string);
3990
4134
  isolate->string_tracker()->RecordWrite(str);
3991
- if (options & HINT_MANY_WRITES_EXPECTED) {
4135
+ if (options & String::HINT_MANY_WRITES_EXPECTED) {
3992
4136
  // Flatten the string for efficiency. This applies whether we are
3993
- // using StringInputBuffer or Get(i) to access the characters.
3994
- str->TryFlatten();
4137
+ // using StringCharacterStream or Get(i) to access the characters.
4138
+ FlattenString(str);
3995
4139
  }
3996
4140
  int end = start + length;
3997
4141
  if ((length == -1) || (length > str->length() - start) )
3998
4142
  end = str->length();
3999
4143
  if (end < 0) return 0;
4000
4144
  i::String::WriteToFlat(*str, buffer, start, end);
4001
- if (!(options & NO_NULL_TERMINATION) &&
4145
+ if (!(options & String::NO_NULL_TERMINATION) &&
4002
4146
  (length == -1 || end - start < length)) {
4003
4147
  buffer[end - start] = '\0';
4004
4148
  }
@@ -4006,6 +4150,22 @@ int String::Write(uint16_t* buffer,
4006
4150
  }
4007
4151
 
4008
4152
 
4153
+ int String::WriteOneByte(uint8_t* buffer,
4154
+ int start,
4155
+ int length,
4156
+ int options) const {
4157
+ return WriteHelper(this, buffer, start, length, options);
4158
+ }
4159
+
4160
+
4161
+ int String::Write(uint16_t* buffer,
4162
+ int start,
4163
+ int length,
4164
+ int options) const {
4165
+ return WriteHelper(this, buffer, start, length, options);
4166
+ }
4167
+
4168
+
4009
4169
  bool v8::String::IsExternal() const {
4010
4170
  i::Handle<i::String> str = Utils::OpenHandle(this);
4011
4171
  if (IsDeadCheck(str->GetIsolate(), "v8::String::IsExternal()")) {
@@ -4039,6 +4199,29 @@ void v8::String::VerifyExternalStringResource(
4039
4199
  CHECK_EQ(expected, value);
4040
4200
  }
4041
4201
 
4202
+ void v8::String::VerifyExternalStringResourceBase(
4203
+ v8::String::ExternalStringResourceBase* value, Encoding encoding) const {
4204
+ i::Handle<i::String> str = Utils::OpenHandle(this);
4205
+ const v8::String::ExternalStringResourceBase* expected;
4206
+ Encoding expectedEncoding;
4207
+ if (i::StringShape(*str).IsExternalAscii()) {
4208
+ const void* resource =
4209
+ i::Handle<i::ExternalAsciiString>::cast(str)->resource();
4210
+ expected = reinterpret_cast<const ExternalStringResourceBase*>(resource);
4211
+ expectedEncoding = ASCII_ENCODING;
4212
+ } else if (i::StringShape(*str).IsExternalTwoByte()) {
4213
+ const void* resource =
4214
+ i::Handle<i::ExternalTwoByteString>::cast(str)->resource();
4215
+ expected = reinterpret_cast<const ExternalStringResourceBase*>(resource);
4216
+ expectedEncoding = TWO_BYTE_ENCODING;
4217
+ } else {
4218
+ expected = NULL;
4219
+ expectedEncoding = str->IsOneByteRepresentation() ? ASCII_ENCODING
4220
+ : TWO_BYTE_ENCODING;
4221
+ }
4222
+ CHECK_EQ(expected, value);
4223
+ CHECK_EQ(expectedEncoding, encoding);
4224
+ }
4042
4225
 
4043
4226
  const v8::String::ExternalAsciiStringResource*
4044
4227
  v8::String::GetExternalAsciiStringResource() const {
@@ -4113,74 +4296,57 @@ int v8::Object::InternalFieldCount() {
4113
4296
  }
4114
4297
 
4115
4298
 
4116
- Local<Value> v8::Object::CheckedGetInternalField(int index) {
4299
+ static bool InternalFieldOK(i::Handle<i::JSObject> obj,
4300
+ int index,
4301
+ const char* location) {
4302
+ return !IsDeadCheck(obj->GetIsolate(), location) &&
4303
+ ApiCheck(index < obj->GetInternalFieldCount(),
4304
+ location,
4305
+ "Internal field out of bounds");
4306
+ }
4307
+
4308
+
4309
+ Local<Value> v8::Object::SlowGetInternalField(int index) {
4117
4310
  i::Handle<i::JSObject> obj = Utils::OpenHandle(this);
4118
- if (IsDeadCheck(obj->GetIsolate(), "v8::Object::GetInternalField()")) {
4119
- return Local<Value>();
4120
- }
4121
- if (!ApiCheck(index < obj->GetInternalFieldCount(),
4122
- "v8::Object::GetInternalField()",
4123
- "Reading internal field out of bounds")) {
4124
- return Local<Value>();
4125
- }
4126
- i::Handle<i::Object> value(obj->GetInternalField(index));
4127
- Local<Value> result = Utils::ToLocal(value);
4128
- #ifdef DEBUG
4129
- Local<Value> unchecked = UncheckedGetInternalField(index);
4130
- ASSERT(unchecked.IsEmpty() || (unchecked == result));
4131
- #endif
4132
- return result;
4311
+ const char* location = "v8::Object::GetInternalField()";
4312
+ if (!InternalFieldOK(obj, index, location)) return Local<Value>();
4313
+ i::Handle<i::Object> value(obj->GetInternalField(index), obj->GetIsolate());
4314
+ return Utils::ToLocal(value);
4133
4315
  }
4134
4316
 
4135
4317
 
4136
4318
  void v8::Object::SetInternalField(int index, v8::Handle<Value> value) {
4137
4319
  i::Handle<i::JSObject> obj = Utils::OpenHandle(this);
4138
- i::Isolate* isolate = obj->GetIsolate();
4139
- if (IsDeadCheck(isolate, "v8::Object::SetInternalField()")) {
4140
- return;
4141
- }
4142
- if (!ApiCheck(index < obj->GetInternalFieldCount(),
4143
- "v8::Object::SetInternalField()",
4144
- "Writing internal field out of bounds")) {
4145
- return;
4146
- }
4147
- ENTER_V8(isolate);
4320
+ const char* location = "v8::Object::SetInternalField()";
4321
+ if (!InternalFieldOK(obj, index, location)) return;
4148
4322
  i::Handle<i::Object> val = Utils::OpenHandle(*value);
4149
4323
  obj->SetInternalField(index, *val);
4324
+ ASSERT_EQ(value, GetInternalField(index));
4150
4325
  }
4151
4326
 
4152
4327
 
4153
- static bool CanBeEncodedAsSmi(void* ptr) {
4154
- const uintptr_t address = reinterpret_cast<uintptr_t>(ptr);
4155
- return ((address & i::kEncodablePointerMask) == 0);
4328
+ void* v8::Object::SlowGetAlignedPointerFromInternalField(int index) {
4329
+ i::Handle<i::JSObject> obj = Utils::OpenHandle(this);
4330
+ const char* location = "v8::Object::GetAlignedPointerFromInternalField()";
4331
+ if (!InternalFieldOK(obj, index, location)) return NULL;
4332
+ return DecodeSmiToAligned(obj->GetInternalField(index), location);
4156
4333
  }
4157
4334
 
4158
4335
 
4159
- static i::Smi* EncodeAsSmi(void* ptr) {
4160
- ASSERT(CanBeEncodedAsSmi(ptr));
4161
- const uintptr_t address = reinterpret_cast<uintptr_t>(ptr);
4162
- i::Smi* result = reinterpret_cast<i::Smi*>(address << i::kPointerToSmiShift);
4163
- ASSERT(i::Internals::HasSmiTag(result));
4164
- ASSERT_EQ(result, i::Smi::FromInt(result->value()));
4165
- ASSERT_EQ(ptr, i::Internals::GetExternalPointerFromSmi(result));
4166
- return result;
4336
+ void v8::Object::SetAlignedPointerInInternalField(int index, void* value) {
4337
+ i::Handle<i::JSObject> obj = Utils::OpenHandle(this);
4338
+ const char* location = "v8::Object::SetAlignedPointerInInternalField()";
4339
+ if (!InternalFieldOK(obj, index, location)) return;
4340
+ obj->SetInternalField(index, EncodeAlignedAsSmi(value, location));
4341
+ ASSERT_EQ(value, GetAlignedPointerFromInternalField(index));
4167
4342
  }
4168
4343
 
4169
4344
 
4170
- void v8::Object::SetPointerInInternalField(int index, void* value) {
4171
- i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
4172
- ENTER_V8(isolate);
4173
- if (CanBeEncodedAsSmi(value)) {
4174
- Utils::OpenHandle(this)->SetInternalField(index, EncodeAsSmi(value));
4175
- } else {
4176
- HandleScope scope;
4177
- i::Handle<i::Foreign> foreign =
4178
- isolate->factory()->NewForeign(
4179
- reinterpret_cast<i::Address>(value), i::TENURED);
4180
- if (!foreign.is_null())
4181
- Utils::OpenHandle(this)->SetInternalField(index, *foreign);
4182
- }
4183
- ASSERT_EQ(value, GetPointerFromInternalField(index));
4345
+ static void* ExternalValue(i::Object* obj) {
4346
+ // Obscure semantics for undefined, but somehow checked in our unit tests...
4347
+ if (obj->IsUndefined()) return NULL;
4348
+ i::Object* foreign = i::JSObject::cast(obj)->GetInternalField(0);
4349
+ return i::Foreign::cast(foreign)->foreign_address();
4184
4350
  }
4185
4351
 
4186
4352
 
@@ -4207,6 +4373,20 @@ void v8::V8::SetReturnAddressLocationResolver(
4207
4373
  }
4208
4374
 
4209
4375
 
4376
+ bool v8::V8::SetFunctionEntryHook(FunctionEntryHook entry_hook) {
4377
+ return i::ProfileEntryHookStub::SetFunctionEntryHook(entry_hook);
4378
+ }
4379
+
4380
+
4381
+ void v8::V8::SetJitCodeEventHandler(
4382
+ JitCodeEventOptions options, JitCodeEventHandler event_handler) {
4383
+ i::Isolate* isolate = i::Isolate::Current();
4384
+ // Ensure that logging is initialized for our isolate.
4385
+ isolate->InitializeLoggingAndCounters();
4386
+ isolate->logger()->SetCodeEventHandler(options, event_handler);
4387
+ }
4388
+
4389
+
4210
4390
  bool v8::V8::Dispose() {
4211
4391
  i::Isolate* isolate = i::Isolate::Current();
4212
4392
  if (!ApiCheck(isolate != NULL && isolate->IsDefaultIsolate(),
@@ -4221,6 +4401,7 @@ bool v8::V8::Dispose() {
4221
4401
 
4222
4402
  HeapStatistics::HeapStatistics(): total_heap_size_(0),
4223
4403
  total_heap_size_executable_(0),
4404
+ total_physical_size_(0),
4224
4405
  used_heap_size_(0),
4225
4406
  heap_size_limit_(0) { }
4226
4407
 
@@ -4230,6 +4411,7 @@ void v8::V8::GetHeapStatistics(HeapStatistics* heap_statistics) {
4230
4411
  // Isolate is unitialized thus heap is not configured yet.
4231
4412
  heap_statistics->set_total_heap_size(0);
4232
4413
  heap_statistics->set_total_heap_size_executable(0);
4414
+ heap_statistics->set_total_physical_size(0);
4233
4415
  heap_statistics->set_used_heap_size(0);
4234
4416
  heap_statistics->set_heap_size_limit(0);
4235
4417
  return;
@@ -4239,6 +4421,7 @@ void v8::V8::GetHeapStatistics(HeapStatistics* heap_statistics) {
4239
4421
  heap_statistics->set_total_heap_size(heap->CommittedMemory());
4240
4422
  heap_statistics->set_total_heap_size_executable(
4241
4423
  heap->CommittedMemoryExecutable());
4424
+ heap_statistics->set_total_physical_size(heap->CommittedPhysicalMemory());
4242
4425
  heap_statistics->set_used_heap_size(heap->SizeOfObjects());
4243
4426
  heap_statistics->set_heap_size_limit(heap->MaxReserved());
4244
4427
  }
@@ -4251,6 +4434,47 @@ void v8::V8::VisitExternalResources(ExternalResourceVisitor* visitor) {
4251
4434
  }
4252
4435
 
4253
4436
 
4437
+ class VisitorAdapter : public i::ObjectVisitor {
4438
+ public:
4439
+ explicit VisitorAdapter(PersistentHandleVisitor* visitor)
4440
+ : visitor_(visitor) {}
4441
+ virtual void VisitPointers(i::Object** start, i::Object** end) {
4442
+ UNREACHABLE();
4443
+ }
4444
+ virtual void VisitEmbedderReference(i::Object** p, uint16_t class_id) {
4445
+ visitor_->VisitPersistentHandle(ToApi<Value>(i::Handle<i::Object>(p)),
4446
+ class_id);
4447
+ }
4448
+ private:
4449
+ PersistentHandleVisitor* visitor_;
4450
+ };
4451
+
4452
+
4453
+ void v8::V8::VisitHandlesWithClassIds(PersistentHandleVisitor* visitor) {
4454
+ i::Isolate* isolate = i::Isolate::Current();
4455
+ IsDeadCheck(isolate, "v8::V8::VisitHandlesWithClassId");
4456
+
4457
+ i::AssertNoAllocation no_allocation;
4458
+
4459
+ VisitorAdapter visitor_adapter(visitor);
4460
+ isolate->global_handles()->IterateAllRootsWithClassIds(&visitor_adapter);
4461
+ }
4462
+
4463
+
4464
+ void v8::V8::VisitHandlesForPartialDependence(
4465
+ Isolate* exported_isolate, PersistentHandleVisitor* visitor) {
4466
+ i::Isolate* isolate = reinterpret_cast<i::Isolate*>(exported_isolate);
4467
+ ASSERT(isolate == i::Isolate::Current());
4468
+ IsDeadCheck(isolate, "v8::V8::VisitHandlesForPartialDependence");
4469
+
4470
+ i::AssertNoAllocation no_allocation;
4471
+
4472
+ VisitorAdapter visitor_adapter(visitor);
4473
+ isolate->global_handles()->IterateAllRootsInNewSpaceWithClassIds(
4474
+ &visitor_adapter);
4475
+ }
4476
+
4477
+
4254
4478
  bool v8::V8::IdleNotification(int hint) {
4255
4479
  // Returning true tells the caller that it need not
4256
4480
  // continue to call IdleNotification.
@@ -4341,7 +4565,7 @@ Persistent<Context> v8::Context::New(
4341
4565
  // Create the environment.
4342
4566
  env = isolate->bootstrapper()->CreateEnvironment(
4343
4567
  isolate,
4344
- Utils::OpenHandle(*global_object),
4568
+ Utils::OpenHandle(*global_object, true),
4345
4569
  proxy_template,
4346
4570
  extensions);
4347
4571
 
@@ -4385,7 +4609,7 @@ void v8::Context::UseDefaultSecurityToken() {
4385
4609
  }
4386
4610
  ENTER_V8(isolate);
4387
4611
  i::Handle<i::Context> env = Utils::OpenHandle(this);
4388
- env->set_security_token(env->global());
4612
+ env->set_security_token(env->global_object());
4389
4613
  }
4390
4614
 
4391
4615
 
@@ -4412,6 +4636,12 @@ bool Context::InContext() {
4412
4636
  }
4413
4637
 
4414
4638
 
4639
+ v8::Isolate* Context::GetIsolate() {
4640
+ i::Handle<i::Context> env = Utils::OpenHandle(this);
4641
+ return reinterpret_cast<Isolate*>(env->GetIsolate());
4642
+ }
4643
+
4644
+
4415
4645
  v8::Local<v8::Context> Context::GetEntered() {
4416
4646
  i::Isolate* isolate = i::Isolate::Current();
4417
4647
  if (!EnsureInitializedForIsolate(isolate, "v8::Context::GetEntered()")) {
@@ -4430,7 +4660,7 @@ v8::Local<v8::Context> Context::GetCurrent() {
4430
4660
  if (IsDeadCheck(isolate, "v8::Context::GetCurrent()")) {
4431
4661
  return Local<Context>();
4432
4662
  }
4433
- i::Handle<i::Object> current = isolate->global_context();
4663
+ i::Handle<i::Object> current = isolate->native_context();
4434
4664
  if (current.is_null()) return Local<Context>();
4435
4665
  i::Handle<i::Context> context = i::Handle<i::Context>::cast(current);
4436
4666
  return Utils::ToLocal(context);
@@ -4443,7 +4673,7 @@ v8::Local<v8::Context> Context::GetCalling() {
4443
4673
  return Local<Context>();
4444
4674
  }
4445
4675
  i::Handle<i::Object> calling =
4446
- isolate->GetCallingGlobalContext();
4676
+ isolate->GetCallingNativeContext();
4447
4677
  if (calling.is_null()) return Local<Context>();
4448
4678
  i::Handle<i::Context> context = i::Handle<i::Context>::cast(calling);
4449
4679
  return Utils::ToLocal(context);
@@ -4451,13 +4681,14 @@ v8::Local<v8::Context> Context::GetCalling() {
4451
4681
 
4452
4682
 
4453
4683
  v8::Local<v8::Object> Context::Global() {
4454
- if (IsDeadCheck(i::Isolate::Current(), "v8::Context::Global()")) {
4684
+ i::Isolate* isolate = i::Isolate::Current();
4685
+ if (IsDeadCheck(isolate, "v8::Context::Global()")) {
4455
4686
  return Local<v8::Object>();
4456
4687
  }
4457
4688
  i::Object** ctx = reinterpret_cast<i::Object**>(this);
4458
4689
  i::Handle<i::Context> context =
4459
4690
  i::Handle<i::Context>::cast(i::Handle<i::Object>(ctx));
4460
- i::Handle<i::Object> global(context->global_proxy());
4691
+ i::Handle<i::Object> global(context->global_proxy(), isolate);
4461
4692
  return Utils::ToLocal(i::Handle<i::JSObject>::cast(global));
4462
4693
  }
4463
4694
 
@@ -4480,9 +4711,9 @@ void Context::ReattachGlobal(Handle<Object> global_object) {
4480
4711
  i::Object** ctx = reinterpret_cast<i::Object**>(this);
4481
4712
  i::Handle<i::Context> context =
4482
4713
  i::Handle<i::Context>::cast(i::Handle<i::Object>(ctx));
4483
- isolate->bootstrapper()->ReattachGlobal(
4484
- context,
4485
- Utils::OpenHandle(*global_object));
4714
+ i::Handle<i::JSGlobalProxy> global_proxy =
4715
+ i::Handle<i::JSGlobalProxy>::cast(Utils::OpenHandle(*global_object));
4716
+ isolate->bootstrapper()->ReattachGlobal(context, global_proxy);
4486
4717
  }
4487
4718
 
4488
4719
 
@@ -4514,8 +4745,19 @@ bool Context::IsCodeGenerationFromStringsAllowed() {
4514
4745
  }
4515
4746
 
4516
4747
 
4517
- void V8::SetWrapperClassId(i::Object** global_handle, uint16_t class_id) {
4518
- i::GlobalHandles::SetWrapperClassId(global_handle, class_id);
4748
+ void Context::SetErrorMessageForCodeGenerationFromStrings(
4749
+ Handle<String> error) {
4750
+ i::Isolate* isolate = i::Isolate::Current();
4751
+ if (IsDeadCheck(isolate,
4752
+ "v8::Context::SetErrorMessageForCodeGenerationFromStrings()")) {
4753
+ return;
4754
+ }
4755
+ ENTER_V8(isolate);
4756
+ i::Object** ctx = reinterpret_cast<i::Object**>(this);
4757
+ i::Handle<i::Context> context =
4758
+ i::Handle<i::Context>::cast(i::Handle<i::Object>(ctx));
4759
+ i::Handle<i::Object> error_handle = Utils::OpenHandle(*error);
4760
+ context->set_error_message_for_code_gen_from_strings(*error_handle);
4519
4761
  }
4520
4762
 
4521
4763
 
@@ -4557,74 +4799,20 @@ bool FunctionTemplate::HasInstance(v8::Handle<v8::Value> value) {
4557
4799
  }
4558
4800
 
4559
4801
 
4560
- static Local<External> ExternalNewImpl(void* data) {
4561
- return Utils::ToLocal(FACTORY->NewForeign(static_cast<i::Address>(data)));
4562
- }
4563
-
4564
- static void* ExternalValueImpl(i::Handle<i::Object> obj) {
4565
- return reinterpret_cast<void*>(i::Foreign::cast(*obj)->foreign_address());
4566
- }
4567
-
4568
-
4569
- Local<Value> v8::External::Wrap(void* data) {
4570
- i::Isolate* isolate = i::Isolate::Current();
4571
- STATIC_ASSERT(sizeof(data) == sizeof(i::Address));
4572
- EnsureInitializedForIsolate(isolate, "v8::External::Wrap()");
4573
- LOG_API(isolate, "External::Wrap");
4574
- ENTER_V8(isolate);
4575
-
4576
- v8::Local<v8::Value> result = CanBeEncodedAsSmi(data)
4577
- ? Utils::ToLocal(i::Handle<i::Object>(EncodeAsSmi(data)))
4578
- : v8::Local<v8::Value>(ExternalNewImpl(data));
4579
-
4580
- ASSERT_EQ(data, Unwrap(result));
4581
- return result;
4582
- }
4583
-
4584
-
4585
- void* v8::Object::SlowGetPointerFromInternalField(int index) {
4586
- i::Handle<i::JSObject> obj = Utils::OpenHandle(this);
4587
- i::Object* value = obj->GetInternalField(index);
4588
- if (value->IsSmi()) {
4589
- return i::Internals::GetExternalPointerFromSmi(value);
4590
- } else if (value->IsForeign()) {
4591
- return reinterpret_cast<void*>(i::Foreign::cast(value)->foreign_address());
4592
- } else {
4593
- return NULL;
4594
- }
4595
- }
4596
-
4597
-
4598
- void* v8::External::FullUnwrap(v8::Handle<v8::Value> wrapper) {
4599
- if (IsDeadCheck(i::Isolate::Current(), "v8::External::Unwrap()")) return 0;
4600
- i::Handle<i::Object> obj = Utils::OpenHandle(*wrapper);
4601
- void* result;
4602
- if (obj->IsSmi()) {
4603
- result = i::Internals::GetExternalPointerFromSmi(*obj);
4604
- } else if (obj->IsForeign()) {
4605
- result = ExternalValueImpl(obj);
4606
- } else {
4607
- result = NULL;
4608
- }
4609
- ASSERT_EQ(result, QuickUnwrap(wrapper));
4610
- return result;
4611
- }
4612
-
4613
-
4614
- Local<External> v8::External::New(void* data) {
4615
- STATIC_ASSERT(sizeof(data) == sizeof(i::Address));
4802
+ Local<External> v8::External::New(void* value) {
4803
+ STATIC_ASSERT(sizeof(value) == sizeof(i::Address));
4616
4804
  i::Isolate* isolate = i::Isolate::Current();
4617
4805
  EnsureInitializedForIsolate(isolate, "v8::External::New()");
4618
4806
  LOG_API(isolate, "External::New");
4619
4807
  ENTER_V8(isolate);
4620
- return ExternalNewImpl(data);
4808
+ i::Handle<i::JSObject> external = isolate->factory()->NewExternal(value);
4809
+ return Utils::ExternalToLocal(external);
4621
4810
  }
4622
4811
 
4623
4812
 
4624
4813
  void* External::Value() const {
4625
- if (IsDeadCheck(i::Isolate::Current(), "v8::External::Value()")) return 0;
4626
- i::Handle<i::Object> obj = Utils::OpenHandle(this);
4627
- return ExternalValueImpl(obj);
4814
+ if (IsDeadCheck(i::Isolate::Current(), "v8::External::Value()")) return NULL;
4815
+ return ExternalValue(*Utils::OpenHandle(this));
4628
4816
  }
4629
4817
 
4630
4818
 
@@ -4736,6 +4924,7 @@ Local<String> v8::String::NewExternal(
4736
4924
  EnsureInitializedForIsolate(isolate, "v8::String::NewExternal()");
4737
4925
  LOG_API(isolate, "String::NewExternal");
4738
4926
  ENTER_V8(isolate);
4927
+ CHECK(resource && resource->data());
4739
4928
  i::Handle<i::String> result = NewExternalStringHandle(isolate, resource);
4740
4929
  isolate->heap()->external_string_table()->AddString(*result);
4741
4930
  return Utils::ToLocal(result);
@@ -4756,6 +4945,7 @@ bool v8::String::MakeExternal(v8::String::ExternalStringResource* resource) {
4756
4945
  if (isolate->heap()->IsInGCPostProcessing()) {
4757
4946
  return false;
4758
4947
  }
4948
+ CHECK(resource && resource->data());
4759
4949
  bool result = obj->MakeExternal(resource);
4760
4950
  if (result && !obj->IsSymbol()) {
4761
4951
  isolate->heap()->external_string_table()->AddString(*obj);
@@ -4770,6 +4960,7 @@ Local<String> v8::String::NewExternal(
4770
4960
  EnsureInitializedForIsolate(isolate, "v8::String::NewExternal()");
4771
4961
  LOG_API(isolate, "String::NewExternal");
4772
4962
  ENTER_V8(isolate);
4963
+ CHECK(resource && resource->data());
4773
4964
  i::Handle<i::String> result = NewExternalAsciiStringHandle(isolate, resource);
4774
4965
  isolate->heap()->external_string_table()->AddString(*result);
4775
4966
  return Utils::ToLocal(result);
@@ -4791,6 +4982,7 @@ bool v8::String::MakeExternal(
4791
4982
  if (isolate->heap()->IsInGCPostProcessing()) {
4792
4983
  return false;
4793
4984
  }
4985
+ CHECK(resource && resource->data());
4794
4986
  bool result = obj->MakeExternal(resource);
4795
4987
  if (result && !obj->IsSymbol()) {
4796
4988
  isolate->heap()->external_string_table()->AddString(*obj);
@@ -4928,8 +5120,8 @@ void v8::Date::DateTimeConfigurationChangeNotification() {
4928
5120
 
4929
5121
  i::HandleScope scope(isolate);
4930
5122
  // Get the function ResetDateCache (defined in date.js).
4931
- i::Handle<i::String> func_name_str =
4932
- isolate->factory()->LookupAsciiSymbol("ResetDateCache");
5123
+ i::Handle<i::String> func_name_str = isolate->factory()->LookupOneByteSymbol(
5124
+ STATIC_ASCII_VECTOR("ResetDateCache"));
4933
5125
  i::MaybeObject* result =
4934
5126
  isolate->js_builtins_object()->GetProperty(*func_name_str);
4935
5127
  i::Object* object_func;
@@ -4953,14 +5145,14 @@ void v8::Date::DateTimeConfigurationChangeNotification() {
4953
5145
 
4954
5146
 
4955
5147
  static i::Handle<i::String> RegExpFlagsToString(RegExp::Flags flags) {
4956
- char flags_buf[3];
5148
+ uint8_t flags_buf[3];
4957
5149
  int num_flags = 0;
4958
5150
  if ((flags & RegExp::kGlobal) != 0) flags_buf[num_flags++] = 'g';
4959
5151
  if ((flags & RegExp::kMultiline) != 0) flags_buf[num_flags++] = 'm';
4960
5152
  if ((flags & RegExp::kIgnoreCase) != 0) flags_buf[num_flags++] = 'i';
4961
5153
  ASSERT(num_flags <= static_cast<int>(ARRAY_SIZE(flags_buf)));
4962
- return FACTORY->LookupSymbol(
4963
- i::Vector<const char>(flags_buf, num_flags));
5154
+ return FACTORY->LookupOneByteSymbol(
5155
+ i::Vector<const uint8_t>(flags_buf, num_flags));
4964
5156
  }
4965
5157
 
4966
5158
 
@@ -5064,8 +5256,8 @@ Local<String> v8::String::NewSymbol(const char* data, int length) {
5064
5256
  LOG_API(isolate, "String::NewSymbol(char)");
5065
5257
  ENTER_V8(isolate);
5066
5258
  if (length == -1) length = i::StrLength(data);
5067
- i::Handle<i::String> result =
5068
- isolate->factory()->LookupSymbol(i::Vector<const char>(data, length));
5259
+ i::Handle<i::String> result = isolate->factory()->LookupUtf8Symbol(
5260
+ i::Vector<const char>(data, length));
5069
5261
  return Utils::ToLocal(result);
5070
5262
  }
5071
5263
 
@@ -5086,24 +5278,39 @@ Local<Number> v8::Number::New(double value) {
5086
5278
  Local<Integer> v8::Integer::New(int32_t value) {
5087
5279
  i::Isolate* isolate = i::Isolate::UncheckedCurrent();
5088
5280
  EnsureInitializedForIsolate(isolate, "v8::Integer::New()");
5281
+ return v8::Integer::New(value, reinterpret_cast<Isolate*>(isolate));
5282
+ }
5283
+
5284
+
5285
+ Local<Integer> Integer::NewFromUnsigned(uint32_t value) {
5286
+ i::Isolate* isolate = i::Isolate::Current();
5287
+ EnsureInitializedForIsolate(isolate, "v8::Integer::NewFromUnsigned()");
5288
+ return Integer::NewFromUnsigned(value, reinterpret_cast<Isolate*>(isolate));
5289
+ }
5290
+
5291
+
5292
+ Local<Integer> v8::Integer::New(int32_t value, Isolate* isolate) {
5293
+ i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
5294
+ ASSERT(internal_isolate->IsInitialized());
5089
5295
  if (i::Smi::IsValid(value)) {
5090
5296
  return Utils::IntegerToLocal(i::Handle<i::Object>(i::Smi::FromInt(value),
5091
- isolate));
5297
+ internal_isolate));
5092
5298
  }
5093
- ENTER_V8(isolate);
5094
- i::Handle<i::Object> result = isolate->factory()->NewNumber(value);
5299
+ ENTER_V8(internal_isolate);
5300
+ i::Handle<i::Object> result = internal_isolate->factory()->NewNumber(value);
5095
5301
  return Utils::IntegerToLocal(result);
5096
5302
  }
5097
5303
 
5098
5304
 
5099
- Local<Integer> Integer::NewFromUnsigned(uint32_t value) {
5305
+ Local<Integer> v8::Integer::NewFromUnsigned(uint32_t value, Isolate* isolate) {
5306
+ i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
5307
+ ASSERT(internal_isolate->IsInitialized());
5100
5308
  bool fits_into_int32_t = (value & (1 << 31)) == 0;
5101
5309
  if (fits_into_int32_t) {
5102
- return Integer::New(static_cast<int32_t>(value));
5310
+ return Integer::New(static_cast<int32_t>(value), isolate);
5103
5311
  }
5104
- i::Isolate* isolate = i::Isolate::Current();
5105
- ENTER_V8(isolate);
5106
- i::Handle<i::Object> result = isolate->factory()->NewNumber(value);
5312
+ ENTER_V8(internal_isolate);
5313
+ i::Handle<i::Object> result = internal_isolate->factory()->NewNumber(value);
5107
5314
  return Utils::IntegerToLocal(result);
5108
5315
  }
5109
5316
 
@@ -5113,19 +5320,14 @@ void V8::IgnoreOutOfMemoryException() {
5113
5320
  }
5114
5321
 
5115
5322
 
5116
- bool V8::AddMessageListener(MessageCallback that, Handle<Value> data) {
5323
+ bool V8::AddMessageListener(MessageCallback that) {
5117
5324
  i::Isolate* isolate = i::Isolate::Current();
5118
5325
  EnsureInitializedForIsolate(isolate, "v8::V8::AddMessageListener()");
5119
5326
  ON_BAILOUT(isolate, "v8::V8::AddMessageListener()", return false);
5120
5327
  ENTER_V8(isolate);
5121
5328
  i::HandleScope scope(isolate);
5122
5329
  NeanderArray listeners(isolate->factory()->message_listeners());
5123
- NeanderObject obj(2);
5124
- obj.set(0, *isolate->factory()->NewForeign(FUNCTION_ADDR(that)));
5125
- obj.set(1, data.IsEmpty() ?
5126
- isolate->heap()->undefined_value() :
5127
- *Utils::OpenHandle(*data));
5128
- listeners.add(obj.value());
5330
+ listeners.add(isolate->factory()->NewForeign(FUNCTION_ADDR(that)));
5129
5331
  return true;
5130
5332
  }
5131
5333
 
@@ -5140,8 +5342,7 @@ void V8::RemoveMessageListeners(MessageCallback that) {
5140
5342
  for (int i = 0; i < listeners.length(); i++) {
5141
5343
  if (listeners.get(i)->IsUndefined()) continue; // skip deleted ones
5142
5344
 
5143
- NeanderObject listener(i::JSObject::cast(listeners.get(i)));
5144
- i::Handle<i::Foreign> callback_obj(i::Foreign::cast(listener.get(0)));
5345
+ i::Handle<i::Foreign> callback_obj(i::Foreign::cast(listeners.get(i)));
5145
5346
  if (callback_obj->foreign_address() == FUNCTION_ADDR(that)) {
5146
5347
  listeners.set(i, isolate->heap()->undefined_value());
5147
5348
  }
@@ -5170,6 +5371,8 @@ void V8::SetCreateHistogramFunction(CreateHistogramCallback callback) {
5170
5371
  i::Isolate* isolate = EnterIsolateIfNeeded();
5171
5372
  if (IsDeadCheck(isolate, "v8::V8::SetCreateHistogramFunction()")) return;
5172
5373
  isolate->stats_table()->SetCreateHistogramFunction(callback);
5374
+ isolate->InitializeLoggingAndCounters();
5375
+ isolate->counters()->ResetHistograms();
5173
5376
  }
5174
5377
 
5175
5378
  void V8::SetAddHistogramSampleFunction(AddHistogramSampleCallback callback) {
@@ -5179,13 +5382,6 @@ void V8::SetAddHistogramSampleFunction(AddHistogramSampleCallback callback) {
5179
5382
  SetAddHistogramSampleFunction(callback);
5180
5383
  }
5181
5384
 
5182
- void V8::EnableSlidingStateWindow() {
5183
- i::Isolate* isolate = i::Isolate::Current();
5184
- if (IsDeadCheck(isolate, "v8::V8::EnableSlidingStateWindow()")) return;
5185
- isolate->logger()->EnableSlidingStateWindow();
5186
- }
5187
-
5188
-
5189
5385
  void V8::SetFailedAccessCheckCallbackFunction(
5190
5386
  FailedAccessCheckCallback callback) {
5191
5387
  i::Isolate* isolate = i::Isolate::Current();
@@ -5195,6 +5391,7 @@ void V8::SetFailedAccessCheckCallbackFunction(
5195
5391
  isolate->SetFailedAccessCheckCallback(callback);
5196
5392
  }
5197
5393
 
5394
+
5198
5395
  void V8::AddObjectGroup(Persistent<Value>* objects,
5199
5396
  size_t length,
5200
5397
  RetainedObjectInfo* info) {
@@ -5206,6 +5403,19 @@ void V8::AddObjectGroup(Persistent<Value>* objects,
5206
5403
  }
5207
5404
 
5208
5405
 
5406
+ void V8::AddObjectGroup(Isolate* exported_isolate,
5407
+ Persistent<Value>* objects,
5408
+ size_t length,
5409
+ RetainedObjectInfo* info) {
5410
+ i::Isolate* isolate = reinterpret_cast<i::Isolate*>(exported_isolate);
5411
+ ASSERT(isolate == i::Isolate::Current());
5412
+ if (IsDeadCheck(isolate, "v8::V8::AddObjectGroup()")) return;
5413
+ STATIC_ASSERT(sizeof(Persistent<Value>) == sizeof(i::Object**));
5414
+ isolate->global_handles()->AddObjectGroup(
5415
+ reinterpret_cast<i::Object***>(objects), length, info);
5416
+ }
5417
+
5418
+
5209
5419
  void V8::AddImplicitReferences(Persistent<Object> parent,
5210
5420
  Persistent<Value>* children,
5211
5421
  size_t length) {
@@ -5219,8 +5429,9 @@ void V8::AddImplicitReferences(Persistent<Object> parent,
5219
5429
 
5220
5430
 
5221
5431
  intptr_t V8::AdjustAmountOfExternalAllocatedMemory(intptr_t change_in_bytes) {
5222
- i::Isolate* isolate = i::Isolate::Current();
5223
- if (IsDeadCheck(isolate, "v8::V8::AdjustAmountOfExternalAllocatedMemory()")) {
5432
+ i::Isolate* isolate = i::Isolate::UncheckedCurrent();
5433
+ if (isolate == NULL || !isolate->IsInitialized() ||
5434
+ IsDeadCheck(isolate, "v8::V8::AdjustAmountOfExternalAllocatedMemory()")) {
5224
5435
  return 0;
5225
5436
  }
5226
5437
  return isolate->heap()->AdjustAmountOfExternalAllocatedMemory(
@@ -5409,7 +5620,7 @@ String::Utf8Value::Utf8Value(v8::Handle<v8::Value> obj)
5409
5620
  Handle<String> str = obj->ToString();
5410
5621
  if (str.IsEmpty()) return;
5411
5622
  i::Handle<i::String> i_str = Utils::OpenHandle(*str);
5412
- length_ = i::Utf8Length(i_str);
5623
+ length_ = v8::Utf8Length(*i_str, isolate);
5413
5624
  str_ = i::NewArray<char>(length_ + 1);
5414
5625
  str->WriteUtf8(str_);
5415
5626
  }
@@ -5572,7 +5783,8 @@ bool Debug::SetDebugEventListener(EventCallback that, Handle<Value> data) {
5572
5783
  foreign =
5573
5784
  isolate->factory()->NewForeign(FUNCTION_ADDR(EventCallbackWrapper));
5574
5785
  }
5575
- isolate->debugger()->SetEventListener(foreign, Utils::OpenHandle(*data));
5786
+ isolate->debugger()->SetEventListener(foreign,
5787
+ Utils::OpenHandle(*data, true));
5576
5788
  return true;
5577
5789
  }
5578
5790
 
@@ -5587,7 +5799,8 @@ bool Debug::SetDebugEventListener2(EventCallback2 that, Handle<Value> data) {
5587
5799
  if (that != NULL) {
5588
5800
  foreign = isolate->factory()->NewForeign(FUNCTION_ADDR(that));
5589
5801
  }
5590
- isolate->debugger()->SetEventListener(foreign, Utils::OpenHandle(*data));
5802
+ isolate->debugger()->SetEventListener(foreign,
5803
+ Utils::OpenHandle(*data, true));
5591
5804
  return true;
5592
5805
  }
5593
5806
 
@@ -5598,7 +5811,7 @@ bool Debug::SetDebugEventListener(v8::Handle<v8::Object> that,
5598
5811
  ON_BAILOUT(isolate, "v8::Debug::SetDebugEventListener()", return false);
5599
5812
  ENTER_V8(isolate);
5600
5813
  isolate->debugger()->SetEventListener(Utils::OpenHandle(*that),
5601
- Utils::OpenHandle(*data));
5814
+ Utils::OpenHandle(*data, true));
5602
5815
  return true;
5603
5816
  }
5604
5817
 
@@ -5737,9 +5950,9 @@ Local<Value> Debug::GetMirror(v8::Handle<v8::Value> obj) {
5737
5950
  v8::HandleScope scope;
5738
5951
  i::Debug* isolate_debug = isolate->debug();
5739
5952
  isolate_debug->Load();
5740
- i::Handle<i::JSObject> debug(isolate_debug->debug_context()->global());
5741
- i::Handle<i::String> name =
5742
- isolate->factory()->LookupAsciiSymbol("MakeMirror");
5953
+ i::Handle<i::JSObject> debug(isolate_debug->debug_context()->global_object());
5954
+ i::Handle<i::String> name = isolate->factory()->LookupOneByteSymbol(
5955
+ STATIC_ASCII_VECTOR("MakeMirror"));
5743
5956
  i::Handle<i::Object> fun_obj = i::GetProperty(debug, name);
5744
5957
  i::Handle<i::JSFunction> fun = i::Handle<i::JSFunction>::cast(fun_obj);
5745
5958
  v8::Handle<v8::Function> v8_fun = Utils::ToLocal(fun);
@@ -5769,6 +5982,7 @@ void Debug::ProcessDebugMessages() {
5769
5982
  i::Execution::ProcessDebugMessages(true);
5770
5983
  }
5771
5984
 
5985
+
5772
5986
  Local<Context> Debug::GetDebugContext() {
5773
5987
  i::Isolate* isolate = i::Isolate::Current();
5774
5988
  EnsureInitializedForIsolate(isolate, "v8::Debug::GetDebugContext()");
@@ -5776,6 +5990,20 @@ Local<Context> Debug::GetDebugContext() {
5776
5990
  return Utils::ToLocal(i::Isolate::Current()->debugger()->GetDebugContext());
5777
5991
  }
5778
5992
 
5993
+
5994
+ void Debug::SetLiveEditEnabled(bool enable, Isolate* isolate) {
5995
+ // If no isolate is supplied, use the default isolate.
5996
+ i::Debugger* debugger;
5997
+ if (isolate != NULL) {
5998
+ i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
5999
+ debugger = internal_isolate->debugger();
6000
+ } else {
6001
+ debugger = i::Isolate::GetDefaultIsolateDebugger();
6002
+ }
6003
+ debugger->set_live_edit_enabled(enable);
6004
+ }
6005
+
6006
+
5779
6007
  #endif // ENABLE_DEBUGGER_SUPPORT
5780
6008
 
5781
6009
 
@@ -5786,11 +6014,11 @@ Handle<String> CpuProfileNode::GetFunctionName() const {
5786
6014
  const i::CodeEntry* entry = node->entry();
5787
6015
  if (!entry->has_name_prefix()) {
5788
6016
  return Handle<String>(ToApi<String>(
5789
- isolate->factory()->LookupAsciiSymbol(entry->name())));
6017
+ isolate->factory()->LookupUtf8Symbol(entry->name())));
5790
6018
  } else {
5791
6019
  return Handle<String>(ToApi<String>(isolate->factory()->NewConsString(
5792
- isolate->factory()->LookupAsciiSymbol(entry->name_prefix()),
5793
- isolate->factory()->LookupAsciiSymbol(entry->name()))));
6020
+ isolate->factory()->LookupUtf8Symbol(entry->name_prefix()),
6021
+ isolate->factory()->LookupUtf8Symbol(entry->name()))));
5794
6022
  }
5795
6023
  }
5796
6024
 
@@ -5799,7 +6027,7 @@ Handle<String> CpuProfileNode::GetScriptResourceName() const {
5799
6027
  i::Isolate* isolate = i::Isolate::Current();
5800
6028
  IsDeadCheck(isolate, "v8::CpuProfileNode::GetScriptResourceName");
5801
6029
  const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this);
5802
- return Handle<String>(ToApi<String>(isolate->factory()->LookupAsciiSymbol(
6030
+ return Handle<String>(ToApi<String>(isolate->factory()->LookupUtf8Symbol(
5803
6031
  node->entry()->resource_name())));
5804
6032
  }
5805
6033
 
@@ -5885,7 +6113,7 @@ Handle<String> CpuProfile::GetTitle() const {
5885
6113
  i::Isolate* isolate = i::Isolate::Current();
5886
6114
  IsDeadCheck(isolate, "v8::CpuProfile::GetTitle");
5887
6115
  const i::CpuProfile* profile = reinterpret_cast<const i::CpuProfile*>(this);
5888
- return Handle<String>(ToApi<String>(isolate->factory()->LookupAsciiSymbol(
6116
+ return Handle<String>(ToApi<String>(isolate->factory()->LookupUtf8Symbol(
5889
6117
  profile->title())));
5890
6118
  }
5891
6119
 
@@ -5982,7 +6210,7 @@ Handle<Value> HeapGraphEdge::GetName() const {
5982
6210
  case i::HeapGraphEdge::kInternal:
5983
6211
  case i::HeapGraphEdge::kProperty:
5984
6212
  case i::HeapGraphEdge::kShortcut:
5985
- return Handle<String>(ToApi<String>(isolate->factory()->LookupAsciiSymbol(
6213
+ return Handle<String>(ToApi<String>(isolate->factory()->LookupUtf8Symbol(
5986
6214
  edge->name())));
5987
6215
  case i::HeapGraphEdge::kElement:
5988
6216
  case i::HeapGraphEdge::kHidden:
@@ -6026,7 +6254,7 @@ HeapGraphNode::Type HeapGraphNode::GetType() const {
6026
6254
  Handle<String> HeapGraphNode::GetName() const {
6027
6255
  i::Isolate* isolate = i::Isolate::Current();
6028
6256
  IsDeadCheck(isolate, "v8::HeapGraphNode::GetName");
6029
- return Handle<String>(ToApi<String>(isolate->factory()->LookupAsciiSymbol(
6257
+ return Handle<String>(ToApi<String>(isolate->factory()->LookupUtf8Symbol(
6030
6258
  ToInternal(this)->name())));
6031
6259
  }
6032
6260
 
@@ -6105,7 +6333,7 @@ unsigned HeapSnapshot::GetUid() const {
6105
6333
  Handle<String> HeapSnapshot::GetTitle() const {
6106
6334
  i::Isolate* isolate = i::Isolate::Current();
6107
6335
  IsDeadCheck(isolate, "v8::HeapSnapshot::GetTitle");
6108
- return Handle<String>(ToApi<String>(isolate->factory()->LookupAsciiSymbol(
6336
+ return Handle<String>(ToApi<String>(isolate->factory()->LookupUtf8Symbol(
6109
6337
  ToInternal(this)->title())));
6110
6338
  }
6111
6339
 
@@ -6198,7 +6426,8 @@ SnapshotObjectId HeapProfiler::GetSnapshotObjectId(Handle<Value> value) {
6198
6426
 
6199
6427
  const HeapSnapshot* HeapProfiler::TakeSnapshot(Handle<String> title,
6200
6428
  HeapSnapshot::Type type,
6201
- ActivityControl* control) {
6429
+ ActivityControl* control,
6430
+ ObjectNameResolver* resolver) {
6202
6431
  i::Isolate* isolate = i::Isolate::Current();
6203
6432
  IsDeadCheck(isolate, "v8::HeapProfiler::TakeSnapshot");
6204
6433
  i::HeapSnapshot::Type internal_type = i::HeapSnapshot::kFull;
@@ -6211,7 +6440,7 @@ const HeapSnapshot* HeapProfiler::TakeSnapshot(Handle<String> title,
6211
6440
  }
6212
6441
  return reinterpret_cast<const HeapSnapshot*>(
6213
6442
  i::HeapProfiler::TakeSnapshot(
6214
- *Utils::OpenHandle(*title), internal_type, control));
6443
+ *Utils::OpenHandle(*title), internal_type, control, resolver));
6215
6444
  }
6216
6445
 
6217
6446
 
@@ -6229,7 +6458,7 @@ void HeapProfiler::StopHeapObjectsTracking() {
6229
6458
  }
6230
6459
 
6231
6460
 
6232
- void HeapProfiler::PushHeapObjectsStats(OutputStream* stream) {
6461
+ SnapshotObjectId HeapProfiler::PushHeapObjectsStats(OutputStream* stream) {
6233
6462
  i::Isolate* isolate = i::Isolate::Current();
6234
6463
  IsDeadCheck(isolate, "v8::HeapProfiler::PushHeapObjectsStats");
6235
6464
  return i::HeapProfiler::PushHeapObjectsStats(stream);
@@ -6256,6 +6485,11 @@ int HeapProfiler::GetPersistentHandleCount() {
6256
6485
  }
6257
6486
 
6258
6487
 
6488
+ size_t HeapProfiler::GetMemorySizeUsedByProfiler() {
6489
+ return i::HeapProfiler::GetMemorySizeUsedByProfiler();
6490
+ }
6491
+
6492
+
6259
6493
  v8::Testing::StressType internal::Testing::stress_type_ =
6260
6494
  v8::Testing::kStressTypeOpt;
6261
6495
 
@@ -6317,6 +6551,7 @@ void Testing::PrepareStressRun(int run) {
6317
6551
 
6318
6552
 
6319
6553
  void Testing::DeoptimizeAll() {
6554
+ i::HandleScope scope;
6320
6555
  internal::Deoptimizer::DeoptimizeAll();
6321
6556
  }
6322
6557
 
@@ -6355,12 +6590,28 @@ char* HandleScopeImplementer::RestoreThread(char* storage) {
6355
6590
 
6356
6591
 
6357
6592
  void HandleScopeImplementer::IterateThis(ObjectVisitor* v) {
6593
+ #ifdef DEBUG
6594
+ bool found_block_before_deferred = false;
6595
+ #endif
6358
6596
  // Iterate over all handles in the blocks except for the last.
6359
6597
  for (int i = blocks()->length() - 2; i >= 0; --i) {
6360
6598
  Object** block = blocks()->at(i);
6361
- v->VisitPointers(block, &block[kHandleBlockSize]);
6599
+ if (last_handle_before_deferred_block_ != NULL &&
6600
+ (last_handle_before_deferred_block_ < &block[kHandleBlockSize]) &&
6601
+ (last_handle_before_deferred_block_ >= block)) {
6602
+ v->VisitPointers(block, last_handle_before_deferred_block_);
6603
+ ASSERT(!found_block_before_deferred);
6604
+ #ifdef DEBUG
6605
+ found_block_before_deferred = true;
6606
+ #endif
6607
+ } else {
6608
+ v->VisitPointers(block, &block[kHandleBlockSize]);
6609
+ }
6362
6610
  }
6363
6611
 
6612
+ ASSERT(last_handle_before_deferred_block_ == NULL ||
6613
+ found_block_before_deferred);
6614
+
6364
6615
  // Iterate over live handles in the last block (if any).
6365
6616
  if (!blocks()->is_empty()) {
6366
6617
  v->VisitPointers(blocks()->last(), handle_scope_data_.next);
@@ -6388,4 +6639,66 @@ char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) {
6388
6639
  return storage + ArchiveSpacePerThread();
6389
6640
  }
6390
6641
 
6642
+
6643
+ DeferredHandles* HandleScopeImplementer::Detach(Object** prev_limit) {
6644
+ DeferredHandles* deferred =
6645
+ new DeferredHandles(isolate()->handle_scope_data()->next, isolate());
6646
+
6647
+ while (!blocks_.is_empty()) {
6648
+ Object** block_start = blocks_.last();
6649
+ Object** block_limit = &block_start[kHandleBlockSize];
6650
+ // We should not need to check for NoHandleAllocation here. Assert
6651
+ // this.
6652
+ ASSERT(prev_limit == block_limit ||
6653
+ !(block_start <= prev_limit && prev_limit <= block_limit));
6654
+ if (prev_limit == block_limit) break;
6655
+ deferred->blocks_.Add(blocks_.last());
6656
+ blocks_.RemoveLast();
6657
+ }
6658
+
6659
+ // deferred->blocks_ now contains the blocks installed on the
6660
+ // HandleScope stack since BeginDeferredScope was called, but in
6661
+ // reverse order.
6662
+
6663
+ ASSERT(prev_limit == NULL || !blocks_.is_empty());
6664
+
6665
+ ASSERT(!blocks_.is_empty() && prev_limit != NULL);
6666
+ ASSERT(last_handle_before_deferred_block_ != NULL);
6667
+ last_handle_before_deferred_block_ = NULL;
6668
+ return deferred;
6669
+ }
6670
+
6671
+
6672
+ void HandleScopeImplementer::BeginDeferredScope() {
6673
+ ASSERT(last_handle_before_deferred_block_ == NULL);
6674
+ last_handle_before_deferred_block_ = isolate()->handle_scope_data()->next;
6675
+ }
6676
+
6677
+
6678
+ DeferredHandles::~DeferredHandles() {
6679
+ isolate_->UnlinkDeferredHandles(this);
6680
+
6681
+ for (int i = 0; i < blocks_.length(); i++) {
6682
+ #ifdef DEBUG
6683
+ HandleScope::ZapRange(blocks_[i], &blocks_[i][kHandleBlockSize]);
6684
+ #endif
6685
+ isolate_->handle_scope_implementer()->ReturnBlock(blocks_[i]);
6686
+ }
6687
+ }
6688
+
6689
+
6690
+ void DeferredHandles::Iterate(ObjectVisitor* v) {
6691
+ ASSERT(!blocks_.is_empty());
6692
+
6693
+ ASSERT((first_block_limit_ >= blocks_.first()) &&
6694
+ (first_block_limit_ <= &(blocks_.first())[kHandleBlockSize]));
6695
+
6696
+ v->VisitPointers(blocks_.first(), first_block_limit_);
6697
+
6698
+ for (int i = 1; i < blocks_.length(); i++) {
6699
+ v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]);
6700
+ }
6701
+ }
6702
+
6703
+
6391
6704
  } } // namespace v8::internal