libv8 3.10.8.0 → 3.11.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (215) hide show
  1. data/Rakefile +10 -3
  2. data/ext/libv8/compiler.rb +46 -0
  3. data/ext/libv8/extconf.rb +5 -1
  4. data/ext/libv8/make.rb +13 -0
  5. data/lib/libv8/version.rb +1 -1
  6. data/patches/add-freebsd9-and-freebsd10-to-gyp-GetFlavor.patch +11 -0
  7. data/patches/src_platform-freebsd.cc.patch +10 -0
  8. data/vendor/v8/ChangeLog +124 -0
  9. data/vendor/v8/DEPS +27 -0
  10. data/vendor/v8/Makefile +7 -0
  11. data/vendor/v8/SConstruct +15 -2
  12. data/vendor/v8/build/common.gypi +129 -157
  13. data/vendor/v8/build/gyp_v8 +11 -25
  14. data/vendor/v8/build/standalone.gypi +9 -3
  15. data/vendor/v8/include/v8.h +5 -3
  16. data/vendor/v8/src/SConscript +1 -0
  17. data/vendor/v8/src/api.cc +4 -33
  18. data/vendor/v8/src/api.h +2 -2
  19. data/vendor/v8/src/arm/builtins-arm.cc +5 -4
  20. data/vendor/v8/src/arm/code-stubs-arm.cc +21 -14
  21. data/vendor/v8/src/arm/codegen-arm.cc +2 -2
  22. data/vendor/v8/src/arm/debug-arm.cc +3 -1
  23. data/vendor/v8/src/arm/full-codegen-arm.cc +3 -102
  24. data/vendor/v8/src/arm/ic-arm.cc +30 -33
  25. data/vendor/v8/src/arm/lithium-arm.cc +20 -7
  26. data/vendor/v8/src/arm/lithium-arm.h +10 -4
  27. data/vendor/v8/src/arm/lithium-codegen-arm.cc +106 -60
  28. data/vendor/v8/src/arm/macro-assembler-arm.cc +49 -39
  29. data/vendor/v8/src/arm/macro-assembler-arm.h +5 -4
  30. data/vendor/v8/src/arm/regexp-macro-assembler-arm.cc +115 -55
  31. data/vendor/v8/src/arm/regexp-macro-assembler-arm.h +7 -6
  32. data/vendor/v8/src/arm/simulator-arm.h +6 -6
  33. data/vendor/v8/src/arm/stub-cache-arm.cc +64 -19
  34. data/vendor/v8/src/array.js +7 -3
  35. data/vendor/v8/src/ast.cc +11 -6
  36. data/vendor/v8/src/bootstrapper.cc +9 -11
  37. data/vendor/v8/src/builtins.cc +61 -31
  38. data/vendor/v8/src/code-stubs.cc +23 -9
  39. data/vendor/v8/src/code-stubs.h +1 -0
  40. data/vendor/v8/src/codegen.h +3 -3
  41. data/vendor/v8/src/compiler.cc +1 -1
  42. data/vendor/v8/src/contexts.h +2 -18
  43. data/vendor/v8/src/d8.cc +94 -93
  44. data/vendor/v8/src/d8.h +1 -1
  45. data/vendor/v8/src/debug-agent.cc +3 -3
  46. data/vendor/v8/src/debug.cc +41 -1
  47. data/vendor/v8/src/debug.h +50 -0
  48. data/vendor/v8/src/elements-kind.cc +134 -0
  49. data/vendor/v8/src/elements-kind.h +210 -0
  50. data/vendor/v8/src/elements.cc +356 -190
  51. data/vendor/v8/src/elements.h +36 -28
  52. data/vendor/v8/src/factory.cc +44 -4
  53. data/vendor/v8/src/factory.h +11 -7
  54. data/vendor/v8/src/flag-definitions.h +3 -0
  55. data/vendor/v8/src/frames.h +3 -0
  56. data/vendor/v8/src/full-codegen.cc +2 -1
  57. data/vendor/v8/src/func-name-inferrer.h +2 -0
  58. data/vendor/v8/src/globals.h +3 -0
  59. data/vendor/v8/src/heap-inl.h +16 -4
  60. data/vendor/v8/src/heap.cc +38 -32
  61. data/vendor/v8/src/heap.h +3 -17
  62. data/vendor/v8/src/hydrogen-instructions.cc +28 -5
  63. data/vendor/v8/src/hydrogen-instructions.h +142 -44
  64. data/vendor/v8/src/hydrogen.cc +160 -55
  65. data/vendor/v8/src/hydrogen.h +2 -0
  66. data/vendor/v8/src/ia32/assembler-ia32.h +3 -0
  67. data/vendor/v8/src/ia32/builtins-ia32.cc +5 -4
  68. data/vendor/v8/src/ia32/code-stubs-ia32.cc +22 -16
  69. data/vendor/v8/src/ia32/codegen-ia32.cc +2 -2
  70. data/vendor/v8/src/ia32/debug-ia32.cc +29 -2
  71. data/vendor/v8/src/ia32/full-codegen-ia32.cc +8 -101
  72. data/vendor/v8/src/ia32/ic-ia32.cc +23 -19
  73. data/vendor/v8/src/ia32/lithium-codegen-ia32.cc +126 -80
  74. data/vendor/v8/src/ia32/lithium-codegen-ia32.h +2 -1
  75. data/vendor/v8/src/ia32/lithium-ia32.cc +15 -9
  76. data/vendor/v8/src/ia32/lithium-ia32.h +14 -6
  77. data/vendor/v8/src/ia32/macro-assembler-ia32.cc +50 -40
  78. data/vendor/v8/src/ia32/macro-assembler-ia32.h +5 -4
  79. data/vendor/v8/src/ia32/regexp-macro-assembler-ia32.cc +113 -43
  80. data/vendor/v8/src/ia32/regexp-macro-assembler-ia32.h +9 -4
  81. data/vendor/v8/src/ia32/simulator-ia32.h +4 -4
  82. data/vendor/v8/src/ia32/stub-cache-ia32.cc +52 -14
  83. data/vendor/v8/src/ic.cc +77 -20
  84. data/vendor/v8/src/ic.h +18 -2
  85. data/vendor/v8/src/incremental-marking-inl.h +21 -5
  86. data/vendor/v8/src/incremental-marking.cc +35 -8
  87. data/vendor/v8/src/incremental-marking.h +12 -3
  88. data/vendor/v8/src/isolate.cc +12 -2
  89. data/vendor/v8/src/isolate.h +1 -1
  90. data/vendor/v8/src/jsregexp.cc +66 -26
  91. data/vendor/v8/src/jsregexp.h +60 -31
  92. data/vendor/v8/src/list-inl.h +8 -0
  93. data/vendor/v8/src/list.h +3 -0
  94. data/vendor/v8/src/lithium.cc +5 -2
  95. data/vendor/v8/src/liveedit.cc +57 -5
  96. data/vendor/v8/src/mark-compact-inl.h +17 -11
  97. data/vendor/v8/src/mark-compact.cc +100 -143
  98. data/vendor/v8/src/mark-compact.h +44 -20
  99. data/vendor/v8/src/messages.js +131 -99
  100. data/vendor/v8/src/mips/builtins-mips.cc +5 -4
  101. data/vendor/v8/src/mips/code-stubs-mips.cc +23 -15
  102. data/vendor/v8/src/mips/codegen-mips.cc +2 -2
  103. data/vendor/v8/src/mips/debug-mips.cc +3 -1
  104. data/vendor/v8/src/mips/full-codegen-mips.cc +4 -102
  105. data/vendor/v8/src/mips/ic-mips.cc +34 -36
  106. data/vendor/v8/src/mips/lithium-codegen-mips.cc +116 -68
  107. data/vendor/v8/src/mips/lithium-mips.cc +20 -7
  108. data/vendor/v8/src/mips/lithium-mips.h +11 -4
  109. data/vendor/v8/src/mips/macro-assembler-mips.cc +50 -39
  110. data/vendor/v8/src/mips/macro-assembler-mips.h +5 -4
  111. data/vendor/v8/src/mips/regexp-macro-assembler-mips.cc +110 -50
  112. data/vendor/v8/src/mips/regexp-macro-assembler-mips.h +6 -5
  113. data/vendor/v8/src/mips/simulator-mips.h +5 -5
  114. data/vendor/v8/src/mips/stub-cache-mips.cc +66 -20
  115. data/vendor/v8/src/mksnapshot.cc +5 -1
  116. data/vendor/v8/src/objects-debug.cc +103 -6
  117. data/vendor/v8/src/objects-inl.h +215 -116
  118. data/vendor/v8/src/objects-printer.cc +13 -8
  119. data/vendor/v8/src/objects.cc +608 -331
  120. data/vendor/v8/src/objects.h +129 -94
  121. data/vendor/v8/src/parser.cc +16 -4
  122. data/vendor/v8/src/platform-freebsd.cc +1 -0
  123. data/vendor/v8/src/platform-linux.cc +9 -30
  124. data/vendor/v8/src/platform-posix.cc +28 -7
  125. data/vendor/v8/src/platform-win32.cc +15 -3
  126. data/vendor/v8/src/platform.h +2 -1
  127. data/vendor/v8/src/profile-generator-inl.h +25 -2
  128. data/vendor/v8/src/profile-generator.cc +300 -822
  129. data/vendor/v8/src/profile-generator.h +97 -214
  130. data/vendor/v8/src/regexp-macro-assembler-irregexp.cc +2 -1
  131. data/vendor/v8/src/regexp-macro-assembler-irregexp.h +2 -2
  132. data/vendor/v8/src/regexp-macro-assembler-tracer.cc +6 -5
  133. data/vendor/v8/src/regexp-macro-assembler-tracer.h +1 -1
  134. data/vendor/v8/src/regexp-macro-assembler.cc +7 -3
  135. data/vendor/v8/src/regexp-macro-assembler.h +10 -2
  136. data/vendor/v8/src/regexp.js +6 -0
  137. data/vendor/v8/src/runtime.cc +265 -212
  138. data/vendor/v8/src/runtime.h +6 -5
  139. data/vendor/v8/src/scopes.cc +20 -0
  140. data/vendor/v8/src/scopes.h +6 -3
  141. data/vendor/v8/src/spaces.cc +0 -2
  142. data/vendor/v8/src/string-stream.cc +2 -2
  143. data/vendor/v8/src/v8-counters.h +0 -2
  144. data/vendor/v8/src/v8natives.js +2 -2
  145. data/vendor/v8/src/v8utils.h +6 -3
  146. data/vendor/v8/src/version.cc +1 -1
  147. data/vendor/v8/src/x64/assembler-x64.h +2 -1
  148. data/vendor/v8/src/x64/builtins-x64.cc +5 -4
  149. data/vendor/v8/src/x64/code-stubs-x64.cc +25 -16
  150. data/vendor/v8/src/x64/codegen-x64.cc +2 -2
  151. data/vendor/v8/src/x64/debug-x64.cc +14 -1
  152. data/vendor/v8/src/x64/disasm-x64.cc +1 -1
  153. data/vendor/v8/src/x64/full-codegen-x64.cc +10 -106
  154. data/vendor/v8/src/x64/ic-x64.cc +20 -16
  155. data/vendor/v8/src/x64/lithium-codegen-x64.cc +156 -79
  156. data/vendor/v8/src/x64/lithium-codegen-x64.h +2 -1
  157. data/vendor/v8/src/x64/lithium-x64.cc +18 -8
  158. data/vendor/v8/src/x64/lithium-x64.h +7 -2
  159. data/vendor/v8/src/x64/macro-assembler-x64.cc +50 -40
  160. data/vendor/v8/src/x64/macro-assembler-x64.h +5 -4
  161. data/vendor/v8/src/x64/regexp-macro-assembler-x64.cc +122 -51
  162. data/vendor/v8/src/x64/regexp-macro-assembler-x64.h +17 -8
  163. data/vendor/v8/src/x64/simulator-x64.h +4 -4
  164. data/vendor/v8/src/x64/stub-cache-x64.cc +55 -17
  165. data/vendor/v8/test/cctest/cctest.status +1 -0
  166. data/vendor/v8/test/cctest/test-api.cc +24 -0
  167. data/vendor/v8/test/cctest/test-func-name-inference.cc +38 -0
  168. data/vendor/v8/test/cctest/test-heap-profiler.cc +21 -77
  169. data/vendor/v8/test/cctest/test-heap.cc +164 -3
  170. data/vendor/v8/test/cctest/test-list.cc +12 -0
  171. data/vendor/v8/test/cctest/test-mark-compact.cc +5 -5
  172. data/vendor/v8/test/cctest/test-regexp.cc +14 -8
  173. data/vendor/v8/test/cctest/testcfg.py +2 -0
  174. data/vendor/v8/test/mjsunit/accessor-map-sharing.js +176 -0
  175. data/vendor/v8/test/mjsunit/array-construct-transition.js +3 -3
  176. data/vendor/v8/test/mjsunit/array-literal-transitions.js +10 -10
  177. data/vendor/v8/test/mjsunit/big-array-literal.js +3 -0
  178. data/vendor/v8/test/mjsunit/compiler/inline-construct.js +4 -2
  179. data/vendor/v8/test/mjsunit/debug-liveedit-stack-padding.js +88 -0
  180. data/vendor/v8/test/mjsunit/elements-kind.js +4 -4
  181. data/vendor/v8/test/mjsunit/elements-transition-hoisting.js +2 -2
  182. data/vendor/v8/test/mjsunit/elements-transition.js +5 -5
  183. data/vendor/v8/test/mjsunit/error-constructors.js +68 -33
  184. data/vendor/v8/test/mjsunit/harmony/proxies.js +14 -6
  185. data/vendor/v8/test/mjsunit/mjsunit.status +1 -0
  186. data/vendor/v8/test/mjsunit/packed-elements.js +112 -0
  187. data/vendor/v8/test/mjsunit/regexp-capture-3.js +6 -0
  188. data/vendor/v8/test/mjsunit/regexp-global.js +132 -0
  189. data/vendor/v8/test/mjsunit/regexp.js +11 -0
  190. data/vendor/v8/test/mjsunit/regress/regress-117409.js +52 -0
  191. data/vendor/v8/test/mjsunit/regress/regress-126412.js +33 -0
  192. data/vendor/v8/test/mjsunit/regress/regress-128018.js +35 -0
  193. data/vendor/v8/test/mjsunit/regress/regress-128146.js +33 -0
  194. data/vendor/v8/test/mjsunit/regress/regress-1639-2.js +4 -1
  195. data/vendor/v8/test/mjsunit/regress/regress-1639.js +14 -8
  196. data/vendor/v8/test/mjsunit/regress/regress-1849.js +3 -3
  197. data/vendor/v8/test/mjsunit/regress/regress-1878.js +2 -2
  198. data/vendor/v8/test/mjsunit/regress/regress-2071.js +79 -0
  199. data/vendor/v8/test/mjsunit/regress/regress-2153.js +32 -0
  200. data/vendor/v8/test/mjsunit/regress/regress-crbug-122271.js +4 -4
  201. data/vendor/v8/test/mjsunit/regress/regress-crbug-126414.js +32 -0
  202. data/vendor/v8/test/mjsunit/regress/regress-smi-only-concat.js +2 -2
  203. data/vendor/v8/test/mjsunit/regress/regress-transcendental.js +49 -0
  204. data/vendor/v8/test/mjsunit/stack-traces.js +14 -0
  205. data/vendor/v8/test/mjsunit/unbox-double-arrays.js +4 -3
  206. data/vendor/v8/test/test262/testcfg.py +6 -1
  207. data/vendor/v8/tools/check-static-initializers.sh +11 -3
  208. data/vendor/v8/tools/fuzz-harness.sh +92 -0
  209. data/vendor/v8/tools/grokdump.py +658 -67
  210. data/vendor/v8/tools/gyp/v8.gyp +21 -39
  211. data/vendor/v8/tools/js2c.py +3 -3
  212. data/vendor/v8/tools/jsmin.py +2 -2
  213. data/vendor/v8/tools/presubmit.py +2 -1
  214. data/vendor/v8/tools/test-wrapper-gypbuild.py +25 -11
  215. metadata +624 -612
@@ -892,6 +892,16 @@ void Debug::Iterate(ObjectVisitor* v) {
892
892
  }
893
893
 
894
894
 
895
+ void Debug::PutValuesOnStackAndDie(int start,
896
+ Address c_entry_fp,
897
+ Address last_fp,
898
+ Address larger_fp,
899
+ int count,
900
+ int end) {
901
+ OS::Abort();
902
+ }
903
+
904
+
895
905
  Object* Debug::Break(Arguments args) {
896
906
  Heap* heap = isolate_->heap();
897
907
  HandleScope scope(isolate_);
@@ -984,11 +994,34 @@ Object* Debug::Break(Arguments args) {
984
994
  // Count frames until target frame
985
995
  int count = 0;
986
996
  JavaScriptFrameIterator it(isolate_);
987
- while (!it.done() && it.frame()->fp() != thread_local_.last_fp_) {
997
+ while (!it.done() && it.frame()->fp() < thread_local_.last_fp_) {
988
998
  count++;
989
999
  it.Advance();
990
1000
  }
991
1001
 
1002
+ // Catch the cases that would lead to crashes and capture
1003
+ // - C entry FP at which to start stack crawl.
1004
+ // - FP of the frame at which we plan to stop stepping out (last FP).
1005
+ // - current FP that's larger than last FP.
1006
+ // - Counter for the number of steps to step out.
1007
+ if (it.done()) {
1008
+ // We crawled the entire stack, never reaching last_fp_.
1009
+ PutValuesOnStackAndDie(0xBEEEEEEE,
1010
+ frame->fp(),
1011
+ thread_local_.last_fp_,
1012
+ NULL,
1013
+ count,
1014
+ 0xFEEEEEEE);
1015
+ } else if (it.frame()->fp() != thread_local_.last_fp_) {
1016
+ // We crawled over last_fp_, without getting a match.
1017
+ PutValuesOnStackAndDie(0xBEEEEEEE,
1018
+ frame->fp(),
1019
+ thread_local_.last_fp_,
1020
+ it.frame()->fp(),
1021
+ count,
1022
+ 0xFEEEEEEE);
1023
+ }
1024
+
992
1025
  // If we found original frame
993
1026
  if (it.frame()->fp() == thread_local_.last_fp_) {
994
1027
  if (step_count > 1) {
@@ -2227,6 +2260,13 @@ void Debug::FramesHaveBeenDropped(StackFrame::Id new_break_frame_id,
2227
2260
  }
2228
2261
 
2229
2262
 
2263
+ const int Debug::FramePaddingLayout::kInitialSize = 1;
2264
+
2265
+
2266
+ // Any even value bigger than kInitialSize as needed for stack scanning.
2267
+ const int Debug::FramePaddingLayout::kPaddingValue = kInitialSize + 1;
2268
+
2269
+
2230
2270
  bool Debug::IsDebugGlobal(GlobalObject* global) {
2231
2271
  return IsLoaded() && global == debug_context()->global();
2232
2272
  }
@@ -232,6 +232,12 @@ class Debug {
232
232
  void PreemptionWhileInDebugger();
233
233
  void Iterate(ObjectVisitor* v);
234
234
 
235
+ NO_INLINE(void PutValuesOnStackAndDie(int start,
236
+ Address c_entry_fp,
237
+ Address last_fp,
238
+ Address larger_fp,
239
+ int count,
240
+ int end));
235
241
  Object* Break(Arguments args);
236
242
  void SetBreakPoint(Handle<SharedFunctionInfo> shared,
237
243
  Handle<Object> break_point_object,
@@ -457,6 +463,50 @@ class Debug {
457
463
  // Architecture-specific constant.
458
464
  static const bool kFrameDropperSupported;
459
465
 
466
+ /**
467
+ * Defines layout of a stack frame that supports padding. This is a regular
468
+ * internal frame that has a flexible stack structure. LiveEdit can shift
469
+ * its lower part up the stack, taking up the 'padding' space when additional
470
+ * stack memory is required.
471
+ * Such frame is expected immediately above the topmost JavaScript frame.
472
+ *
473
+ * Stack Layout:
474
+ * --- Top
475
+ * LiveEdit routine frames
476
+ * ---
477
+ * C frames of debug handler
478
+ * ---
479
+ * ...
480
+ * ---
481
+ * An internal frame that has n padding words:
482
+ * - any number of words as needed by code -- upper part of frame
483
+ * - padding size: a Smi storing n -- current size of padding
484
+ * - padding: n words filled with kPaddingValue in form of Smi
485
+ * - 3 context/type words of a regular InternalFrame
486
+ * - fp
487
+ * ---
488
+ * Topmost JavaScript frame
489
+ * ---
490
+ * ...
491
+ * --- Bottom
492
+ */
493
+ class FramePaddingLayout : public AllStatic {
494
+ public:
495
+ // Architecture-specific constant.
496
+ static const bool kIsSupported;
497
+
498
+ // A size of frame base including fp. Padding words starts right above
499
+ // the base.
500
+ static const int kFrameBaseSize = 4;
501
+
502
+ // A number of words that should be reserved on stack for the LiveEdit use.
503
+ // Normally equals 1. Stored on stack in form of Smi.
504
+ static const int kInitialSize;
505
+ // A value that padding words are filled with (in form of Smi). Going
506
+ // bottom-top, the first word not having this value is a counter word.
507
+ static const int kPaddingValue;
508
+ };
509
+
460
510
  private:
461
511
  explicit Debug(Isolate* isolate);
462
512
  ~Debug();
@@ -0,0 +1,134 @@
1
+ // Copyright 2012 the V8 project authors. All rights reserved.
2
+ // Redistribution and use in source and binary forms, with or without
3
+ // modification, are permitted provided that the following conditions are
4
+ // met:
5
+ //
6
+ // * Redistributions of source code must retain the above copyright
7
+ // notice, this list of conditions and the following disclaimer.
8
+ // * Redistributions in binary form must reproduce the above
9
+ // copyright notice, this list of conditions and the following
10
+ // disclaimer in the documentation and/or other materials provided
11
+ // with the distribution.
12
+ // * Neither the name of Google Inc. nor the names of its
13
+ // contributors may be used to endorse or promote products derived
14
+ // from this software without specific prior written permission.
15
+ //
16
+ // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17
+ // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18
+ // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19
+ // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20
+ // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21
+ // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22
+ // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23
+ // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
+ // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
+ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26
+ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
+
28
+ #include "elements-kind.h"
29
+
30
+ #include "api.h"
31
+ #include "elements.h"
32
+ #include "objects.h"
33
+
34
+ namespace v8 {
35
+ namespace internal {
36
+
37
+
38
+ void PrintElementsKind(FILE* out, ElementsKind kind) {
39
+ ElementsAccessor* accessor = ElementsAccessor::ForKind(kind);
40
+ PrintF(out, "%s", accessor->name());
41
+ }
42
+
43
+
44
+ ElementsKind GetInitialFastElementsKind() {
45
+ if (FLAG_packed_arrays) {
46
+ return FAST_SMI_ELEMENTS;
47
+ } else {
48
+ return FAST_HOLEY_SMI_ELEMENTS;
49
+ }
50
+ }
51
+
52
+
53
+ struct InitializeFastElementsKindSequence {
54
+ static void Construct(
55
+ ElementsKind** fast_elements_kind_sequence_ptr) {
56
+ ElementsKind* fast_elements_kind_sequence =
57
+ new ElementsKind[kFastElementsKindCount];
58
+ *fast_elements_kind_sequence_ptr = fast_elements_kind_sequence;
59
+ STATIC_ASSERT(FAST_SMI_ELEMENTS == FIRST_FAST_ELEMENTS_KIND);
60
+ fast_elements_kind_sequence[0] = FAST_SMI_ELEMENTS;
61
+ fast_elements_kind_sequence[1] = FAST_HOLEY_SMI_ELEMENTS;
62
+ fast_elements_kind_sequence[2] = FAST_DOUBLE_ELEMENTS;
63
+ fast_elements_kind_sequence[3] = FAST_HOLEY_DOUBLE_ELEMENTS;
64
+ fast_elements_kind_sequence[4] = FAST_ELEMENTS;
65
+ fast_elements_kind_sequence[5] = FAST_HOLEY_ELEMENTS;
66
+ }
67
+ };
68
+
69
+
70
+ static LazyInstance<ElementsKind*,
71
+ InitializeFastElementsKindSequence>::type
72
+ fast_elements_kind_sequence = LAZY_INSTANCE_INITIALIZER;
73
+
74
+
75
+ ElementsKind GetFastElementsKindFromSequenceIndex(int sequence_number) {
76
+ ASSERT(sequence_number >= 0 &&
77
+ sequence_number < kFastElementsKindCount);
78
+ return fast_elements_kind_sequence.Get()[sequence_number];
79
+ }
80
+
81
+ int GetSequenceIndexFromFastElementsKind(ElementsKind elements_kind) {
82
+ for (int i = 0; i < kFastElementsKindCount; ++i) {
83
+ if (fast_elements_kind_sequence.Get()[i] == elements_kind) {
84
+ return i;
85
+ }
86
+ }
87
+ UNREACHABLE();
88
+ return 0;
89
+ }
90
+
91
+
92
+ ElementsKind GetNextMoreGeneralFastElementsKind(ElementsKind elements_kind,
93
+ bool allow_only_packed) {
94
+ ASSERT(IsFastElementsKind(elements_kind));
95
+ ASSERT(elements_kind != TERMINAL_FAST_ELEMENTS_KIND);
96
+ while (true) {
97
+ int index =
98
+ GetSequenceIndexFromFastElementsKind(elements_kind) + 1;
99
+ elements_kind = GetFastElementsKindFromSequenceIndex(index);
100
+ if (!IsFastHoleyElementsKind(elements_kind) || !allow_only_packed) {
101
+ return elements_kind;
102
+ }
103
+ }
104
+ UNREACHABLE();
105
+ return TERMINAL_FAST_ELEMENTS_KIND;
106
+ }
107
+
108
+
109
+ bool IsMoreGeneralElementsKindTransition(ElementsKind from_kind,
110
+ ElementsKind to_kind) {
111
+ switch (from_kind) {
112
+ case FAST_SMI_ELEMENTS:
113
+ return to_kind != FAST_SMI_ELEMENTS;
114
+ case FAST_HOLEY_SMI_ELEMENTS:
115
+ return to_kind != FAST_SMI_ELEMENTS &&
116
+ to_kind != FAST_HOLEY_SMI_ELEMENTS;
117
+ case FAST_DOUBLE_ELEMENTS:
118
+ return to_kind != FAST_SMI_ELEMENTS &&
119
+ to_kind != FAST_HOLEY_SMI_ELEMENTS &&
120
+ to_kind != FAST_DOUBLE_ELEMENTS;
121
+ case FAST_HOLEY_DOUBLE_ELEMENTS:
122
+ return to_kind == FAST_ELEMENTS ||
123
+ to_kind == FAST_HOLEY_ELEMENTS;
124
+ case FAST_ELEMENTS:
125
+ return to_kind == FAST_HOLEY_ELEMENTS;
126
+ case FAST_HOLEY_ELEMENTS:
127
+ return false;
128
+ default:
129
+ return false;
130
+ }
131
+ }
132
+
133
+
134
+ } } // namespace v8::internal
@@ -0,0 +1,210 @@
1
+ // Copyright 2012 the V8 project authors. All rights reserved.
2
+ // Redistribution and use in source and binary forms, with or without
3
+ // modification, are permitted provided that the following conditions are
4
+ // met:
5
+ //
6
+ // * Redistributions of source code must retain the above copyright
7
+ // notice, this list of conditions and the following disclaimer.
8
+ // * Redistributions in binary form must reproduce the above
9
+ // copyright notice, this list of conditions and the following
10
+ // disclaimer in the documentation and/or other materials provided
11
+ // with the distribution.
12
+ // * Neither the name of Google Inc. nor the names of its
13
+ // contributors may be used to endorse or promote products derived
14
+ // from this software without specific prior written permission.
15
+ //
16
+ // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17
+ // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18
+ // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19
+ // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20
+ // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21
+ // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22
+ // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23
+ // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
+ // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
+ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26
+ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
+
28
+ #ifndef V8_ELEMENTS_KIND_H_
29
+ #define V8_ELEMENTS_KIND_H_
30
+
31
+ #include "v8checks.h"
32
+
33
+ namespace v8 {
34
+ namespace internal {
35
+
36
+ enum ElementsKind {
37
+ // The "fast" kind for elements that only contain SMI values. Must be first
38
+ // to make it possible to efficiently check maps for this kind.
39
+ FAST_SMI_ELEMENTS,
40
+ FAST_HOLEY_SMI_ELEMENTS,
41
+
42
+ // The "fast" kind for tagged values. Must be second to make it possible to
43
+ // efficiently check maps for this and the FAST_SMI_ONLY_ELEMENTS kind
44
+ // together at once.
45
+ FAST_ELEMENTS,
46
+ FAST_HOLEY_ELEMENTS,
47
+
48
+ // The "fast" kind for unwrapped, non-tagged double values.
49
+ FAST_DOUBLE_ELEMENTS,
50
+ FAST_HOLEY_DOUBLE_ELEMENTS,
51
+
52
+ // The "slow" kind.
53
+ DICTIONARY_ELEMENTS,
54
+ NON_STRICT_ARGUMENTS_ELEMENTS,
55
+ // The "fast" kind for external arrays
56
+ EXTERNAL_BYTE_ELEMENTS,
57
+ EXTERNAL_UNSIGNED_BYTE_ELEMENTS,
58
+ EXTERNAL_SHORT_ELEMENTS,
59
+ EXTERNAL_UNSIGNED_SHORT_ELEMENTS,
60
+ EXTERNAL_INT_ELEMENTS,
61
+ EXTERNAL_UNSIGNED_INT_ELEMENTS,
62
+ EXTERNAL_FLOAT_ELEMENTS,
63
+ EXTERNAL_DOUBLE_ELEMENTS,
64
+ EXTERNAL_PIXEL_ELEMENTS,
65
+
66
+ // Derived constants from ElementsKind
67
+ FIRST_ELEMENTS_KIND = FAST_SMI_ELEMENTS,
68
+ LAST_ELEMENTS_KIND = EXTERNAL_PIXEL_ELEMENTS,
69
+ FIRST_FAST_ELEMENTS_KIND = FAST_SMI_ELEMENTS,
70
+ LAST_FAST_ELEMENTS_KIND = FAST_HOLEY_DOUBLE_ELEMENTS,
71
+ FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND = EXTERNAL_BYTE_ELEMENTS,
72
+ LAST_EXTERNAL_ARRAY_ELEMENTS_KIND = EXTERNAL_PIXEL_ELEMENTS,
73
+ TERMINAL_FAST_ELEMENTS_KIND = FAST_HOLEY_ELEMENTS
74
+ };
75
+
76
+ const int kElementsKindCount = LAST_ELEMENTS_KIND - FIRST_ELEMENTS_KIND + 1;
77
+ const int kFastElementsKindCount = LAST_FAST_ELEMENTS_KIND -
78
+ FIRST_FAST_ELEMENTS_KIND + 1;
79
+
80
+ void PrintElementsKind(FILE* out, ElementsKind kind);
81
+
82
+ ElementsKind GetInitialFastElementsKind();
83
+
84
+ ElementsKind GetFastElementsKindFromSequenceIndex(int sequence_index);
85
+
86
+ int GetSequenceIndexFromFastElementsKind(ElementsKind elements_kind);
87
+
88
+
89
+ inline bool IsFastElementsKind(ElementsKind kind) {
90
+ ASSERT(FIRST_FAST_ELEMENTS_KIND == 0);
91
+ return kind <= FAST_HOLEY_DOUBLE_ELEMENTS;
92
+ }
93
+
94
+
95
+ inline bool IsFastDoubleElementsKind(ElementsKind kind) {
96
+ return kind == FAST_DOUBLE_ELEMENTS ||
97
+ kind == FAST_HOLEY_DOUBLE_ELEMENTS;
98
+ }
99
+
100
+
101
+ inline bool IsFastSmiOrObjectElementsKind(ElementsKind kind) {
102
+ return kind == FAST_SMI_ELEMENTS ||
103
+ kind == FAST_HOLEY_SMI_ELEMENTS ||
104
+ kind == FAST_ELEMENTS ||
105
+ kind == FAST_HOLEY_ELEMENTS;
106
+ }
107
+
108
+
109
+ inline bool IsFastSmiElementsKind(ElementsKind kind) {
110
+ return kind == FAST_SMI_ELEMENTS ||
111
+ kind == FAST_HOLEY_SMI_ELEMENTS;
112
+ }
113
+
114
+
115
+ inline bool IsFastObjectElementsKind(ElementsKind kind) {
116
+ return kind == FAST_ELEMENTS ||
117
+ kind == FAST_HOLEY_ELEMENTS;
118
+ }
119
+
120
+
121
+ inline bool IsFastHoleyElementsKind(ElementsKind kind) {
122
+ return kind == FAST_HOLEY_SMI_ELEMENTS ||
123
+ kind == FAST_HOLEY_DOUBLE_ELEMENTS ||
124
+ kind == FAST_HOLEY_ELEMENTS;
125
+ }
126
+
127
+
128
+ inline bool IsHoleyElementsKind(ElementsKind kind) {
129
+ return IsFastHoleyElementsKind(kind) ||
130
+ kind == DICTIONARY_ELEMENTS;
131
+ }
132
+
133
+
134
+ inline bool IsFastPackedElementsKind(ElementsKind kind) {
135
+ return kind == FAST_SMI_ELEMENTS ||
136
+ kind == FAST_DOUBLE_ELEMENTS ||
137
+ kind == FAST_ELEMENTS;
138
+ }
139
+
140
+
141
+ inline ElementsKind GetPackedElementsKind(ElementsKind holey_kind) {
142
+ if (holey_kind == FAST_HOLEY_SMI_ELEMENTS) {
143
+ return FAST_SMI_ELEMENTS;
144
+ }
145
+ if (holey_kind == FAST_HOLEY_DOUBLE_ELEMENTS) {
146
+ return FAST_DOUBLE_ELEMENTS;
147
+ }
148
+ if (holey_kind == FAST_HOLEY_ELEMENTS) {
149
+ return FAST_ELEMENTS;
150
+ }
151
+ return holey_kind;
152
+ }
153
+
154
+
155
+ inline ElementsKind GetHoleyElementsKind(ElementsKind packed_kind) {
156
+ if (packed_kind == FAST_SMI_ELEMENTS) {
157
+ return FAST_HOLEY_SMI_ELEMENTS;
158
+ }
159
+ if (packed_kind == FAST_DOUBLE_ELEMENTS) {
160
+ return FAST_HOLEY_DOUBLE_ELEMENTS;
161
+ }
162
+ if (packed_kind == FAST_ELEMENTS) {
163
+ return FAST_HOLEY_ELEMENTS;
164
+ }
165
+ return packed_kind;
166
+ }
167
+
168
+
169
+ inline ElementsKind FastSmiToObjectElementsKind(ElementsKind from_kind) {
170
+ ASSERT(IsFastSmiElementsKind(from_kind));
171
+ return (from_kind == FAST_SMI_ELEMENTS)
172
+ ? FAST_ELEMENTS
173
+ : FAST_HOLEY_ELEMENTS;
174
+ }
175
+
176
+
177
+ inline bool IsSimpleMapChangeTransition(ElementsKind from_kind,
178
+ ElementsKind to_kind) {
179
+ return (GetHoleyElementsKind(from_kind) == to_kind) ||
180
+ (IsFastSmiElementsKind(from_kind) &&
181
+ IsFastObjectElementsKind(to_kind));
182
+ }
183
+
184
+
185
+ bool IsMoreGeneralElementsKindTransition(ElementsKind from_kind,
186
+ ElementsKind to_kind);
187
+
188
+
189
+ inline bool IsTransitionableFastElementsKind(ElementsKind from_kind) {
190
+ return IsFastElementsKind(from_kind) &&
191
+ from_kind != TERMINAL_FAST_ELEMENTS_KIND;
192
+ }
193
+
194
+
195
+ ElementsKind GetNextMoreGeneralFastElementsKind(ElementsKind elements_kind,
196
+ bool allow_only_packed);
197
+
198
+
199
+ inline bool CanTransitionToMoreGeneralFastElementsKind(
200
+ ElementsKind elements_kind,
201
+ bool allow_only_packed) {
202
+ return IsFastElementsKind(elements_kind) &&
203
+ (elements_kind != TERMINAL_FAST_ELEMENTS_KIND &&
204
+ (!allow_only_packed || elements_kind != FAST_ELEMENTS));
205
+ }
206
+
207
+
208
+ } } // namespace v8::internal
209
+
210
+ #endif // V8_ELEMENTS_KIND_H_