Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / v8 / src / heap / heap.h
index 0b87163..956b859 100644 (file)
@@ -11,6 +11,7 @@
 #include "src/assert-scope.h"
 #include "src/counters.h"
 #include "src/globals.h"
+#include "src/heap/gc-idle-time-handler.h"
 #include "src/heap/gc-tracer.h"
 #include "src/heap/incremental-marking.h"
 #include "src/heap/mark-compact.h"
@@ -73,44 +74,41 @@ namespace internal {
   V(Smi, hash_seed, HashSeed)                                                  \
   V(Map, symbol_map, SymbolMap)                                                \
   V(Map, string_map, StringMap)                                                \
-  V(Map, ascii_string_map, AsciiStringMap)                                     \
+  V(Map, one_byte_string_map, OneByteStringMap)                                \
   V(Map, cons_string_map, ConsStringMap)                                       \
-  V(Map, cons_ascii_string_map, ConsAsciiStringMap)                            \
+  V(Map, cons_one_byte_string_map, ConsOneByteStringMap)                       \
   V(Map, sliced_string_map, SlicedStringMap)                                   \
-  V(Map, sliced_ascii_string_map, SlicedAsciiStringMap)                        \
+  V(Map, sliced_one_byte_string_map, SlicedOneByteStringMap)                   \
   V(Map, external_string_map, ExternalStringMap)                               \
   V(Map, external_string_with_one_byte_data_map,                               \
     ExternalStringWithOneByteDataMap)                                          \
-  V(Map, external_ascii_string_map, ExternalAsciiStringMap)                    \
+  V(Map, external_one_byte_string_map, ExternalOneByteStringMap)               \
   V(Map, short_external_string_map, ShortExternalStringMap)                    \
   V(Map, short_external_string_with_one_byte_data_map,                         \
     ShortExternalStringWithOneByteDataMap)                                     \
   V(Map, internalized_string_map, InternalizedStringMap)                       \
-  V(Map, ascii_internalized_string_map, AsciiInternalizedStringMap)            \
+  V(Map, one_byte_internalized_string_map, OneByteInternalizedStringMap)       \
   V(Map, external_internalized_string_map, ExternalInternalizedStringMap)      \
   V(Map, external_internalized_string_with_one_byte_data_map,                  \
     ExternalInternalizedStringWithOneByteDataMap)                              \
-  V(Map, external_ascii_internalized_string_map,                               \
-    ExternalAsciiInternalizedStringMap)                                        \
+  V(Map, external_one_byte_internalized_string_map,                            \
+    ExternalOneByteInternalizedStringMap)                                      \
   V(Map, short_external_internalized_string_map,                               \
     ShortExternalInternalizedStringMap)                                        \
   V(Map, short_external_internalized_string_with_one_byte_data_map,            \
     ShortExternalInternalizedStringWithOneByteDataMap)                         \
-  V(Map, short_external_ascii_internalized_string_map,                         \
-    ShortExternalAsciiInternalizedStringMap)                                   \
-  V(Map, short_external_ascii_string_map, ShortExternalAsciiStringMap)         \
+  V(Map, short_external_one_byte_internalized_string_map,                      \
+    ShortExternalOneByteInternalizedStringMap)                                 \
+  V(Map, short_external_one_byte_string_map, ShortExternalOneByteStringMap)    \
   V(Map, undetectable_string_map, UndetectableStringMap)                       \
-  V(Map, undetectable_ascii_string_map, UndetectableAsciiStringMap)            \
+  V(Map, undetectable_one_byte_string_map, UndetectableOneByteStringMap)       \
   V(Map, external_int8_array_map, ExternalInt8ArrayMap)                        \
   V(Map, external_uint8_array_map, ExternalUint8ArrayMap)                      \
   V(Map, external_int16_array_map, ExternalInt16ArrayMap)                      \
   V(Map, external_uint16_array_map, ExternalUint16ArrayMap)                    \
   V(Map, external_int32_array_map, ExternalInt32ArrayMap)                      \
-  V(Map, external_int32x4_array_map, ExternalInt32x4ArrayMap)                  \
   V(Map, external_uint32_array_map, ExternalUint32ArrayMap)                    \
   V(Map, external_float32_array_map, ExternalFloat32ArrayMap)                  \
-  V(Map, external_float32x4_array_map, ExternalFloat32x4ArrayMap)              \
-  V(Map, external_float64x2_array_map, ExternalFloat64x2ArrayMap)              \
   V(Map, external_float64_array_map, ExternalFloat64ArrayMap)                  \
   V(Map, external_uint8_clamped_array_map, ExternalUint8ClampedArrayMap)       \
   V(ExternalArray, empty_external_int8_array, EmptyExternalInt8Array)          \
@@ -118,11 +116,8 @@ namespace internal {
   V(ExternalArray, empty_external_int16_array, EmptyExternalInt16Array)        \
   V(ExternalArray, empty_external_uint16_array, EmptyExternalUint16Array)      \
   V(ExternalArray, empty_external_int32_array, EmptyExternalInt32Array)        \
-  V(ExternalArray, empty_external_int32x4_array, EmptyExternalInt32x4Array)    \
   V(ExternalArray, empty_external_uint32_array, EmptyExternalUint32Array)      \
   V(ExternalArray, empty_external_float32_array, EmptyExternalFloat32Array)    \
-  V(ExternalArray, empty_external_float32x4_array, EmptyExternalFloat32x4Array)\
-  V(ExternalArray, empty_external_float64x2_array, EmptyExternalFloat64x2Array)\
   V(ExternalArray, empty_external_float64_array, EmptyExternalFloat64Array)    \
   V(ExternalArray, empty_external_uint8_clamped_array,                         \
     EmptyExternalUint8ClampedArray)                                            \
@@ -132,10 +127,7 @@ namespace internal {
   V(Map, fixed_int16_array_map, FixedInt16ArrayMap)                            \
   V(Map, fixed_uint32_array_map, FixedUint32ArrayMap)                          \
   V(Map, fixed_int32_array_map, FixedInt32ArrayMap)                            \
-  V(Map, fixed_int32x4_array_map, FixedInt32x4ArrayMap)                        \
   V(Map, fixed_float32_array_map, FixedFloat32ArrayMap)                        \
-  V(Map, fixed_float32x4_array_map, FixedFloat32x4ArrayMap)                    \
-  V(Map, fixed_float64x2_array_map, FixedFloat64x2ArrayMap)                    \
   V(Map, fixed_float64_array_map, FixedFloat64ArrayMap)                        \
   V(Map, fixed_uint8_clamped_array_map, FixedUint8ClampedArrayMap)             \
   V(FixedTypedArrayBase, empty_fixed_uint8_array, EmptyFixedUint8Array)        \
@@ -145,11 +137,6 @@ namespace internal {
   V(FixedTypedArrayBase, empty_fixed_uint32_array, EmptyFixedUint32Array)      \
   V(FixedTypedArrayBase, empty_fixed_int32_array, EmptyFixedInt32Array)        \
   V(FixedTypedArrayBase, empty_fixed_float32_array, EmptyFixedFloat32Array)    \
-  V(FixedTypedArrayBase, empty_fixed_float32x4_array,                          \
-      EmptyFixedFloat32x4Array)                                                \
-  V(FixedTypedArrayBase, empty_fixed_float64x2_array,                          \
-      EmptyFixedFloat64x2Array)                                                \
-  V(FixedTypedArrayBase, empty_fixed_int32x4_array, EmptyFixedInt32x4Array)    \
   V(FixedTypedArrayBase, empty_fixed_float64_array, EmptyFixedFloat64Array)    \
   V(FixedTypedArrayBase, empty_fixed_uint8_clamped_array,                      \
     EmptyFixedUint8ClampedArray)                                               \
@@ -196,9 +183,12 @@ namespace internal {
   V(Symbol, observed_symbol, ObservedSymbol)                                   \
   V(Symbol, uninitialized_symbol, UninitializedSymbol)                         \
   V(Symbol, megamorphic_symbol, MegamorphicSymbol)                             \
+  V(Symbol, premonomorphic_symbol, PremonomorphicSymbol)                       \
+  V(Symbol, generic_symbol, GenericSymbol)                                     \
   V(Symbol, stack_trace_symbol, StackTraceSymbol)                              \
   V(Symbol, detailed_stack_trace_symbol, DetailedStackTraceSymbol)             \
   V(Symbol, normal_ic_symbol, NormalICSymbol)                                  \
+  V(Symbol, home_object_symbol, HomeObjectSymbol)                              \
   V(FixedArray, materialized_objects, MaterializedObjects)                     \
   V(FixedArray, allocation_sites_scratchpad, AllocationSitesScratchpad)        \
   V(FixedArray, microtask_queue, MicrotaskQueue)
@@ -270,13 +260,10 @@ namespace internal {
   V(neander_map)
 
 #define INTERNALIZED_STRING_LIST(V)                                \
-  V(Array_string, "Array")                                         \
   V(Object_string, "Object")                                       \
   V(proto_string, "__proto__")                                     \
   V(arguments_string, "arguments")                                 \
   V(Arguments_string, "Arguments")                                 \
-  V(call_string, "call")                                           \
-  V(apply_string, "apply")                                         \
   V(caller_string, "caller")                                       \
   V(boolean_string, "boolean")                                     \
   V(Boolean_string, "Boolean")                                     \
@@ -287,62 +274,51 @@ namespace internal {
   V(eval_string, "eval")                                           \
   V(empty_string, "")                                              \
   V(function_string, "function")                                   \
+  V(Function_string, "Function")                                   \
   V(length_string, "length")                                       \
   V(name_string, "name")                                           \
   V(null_string, "null")                                           \
   V(number_string, "number")                                       \
   V(Number_string, "Number")                                       \
-  V(float32x4_string, "float32x4")                                 \
-  V(float64x2_string, "float64x2")                                 \
-  V(int32x4_string, "int32x4")                                     \
   V(nan_string, "NaN")                                             \
-  V(RegExp_string, "RegExp")                                       \
   V(source_string, "source")                                       \
   V(source_url_string, "source_url")                               \
   V(source_mapping_url_string, "source_mapping_url")               \
   V(global_string, "global")                                       \
   V(ignore_case_string, "ignoreCase")                              \
   V(multiline_string, "multiline")                                 \
+  V(sticky_string, "sticky")                                       \
+  V(harmony_regexps_string, "harmony_regexps")                     \
   V(input_string, "input")                                         \
   V(index_string, "index")                                         \
   V(last_index_string, "lastIndex")                                \
   V(object_string, "object")                                       \
-  V(literals_string, "literals")                                   \
   V(prototype_string, "prototype")                                 \
   V(string_string, "string")                                       \
   V(String_string, "String")                                       \
   V(symbol_string, "symbol")                                       \
   V(Symbol_string, "Symbol")                                       \
+  V(Map_string, "Map")                                             \
+  V(Set_string, "Set")                                             \
+  V(WeakMap_string, "WeakMap")                                     \
+  V(WeakSet_string, "WeakSet")                                     \
   V(for_string, "for")                                             \
   V(for_api_string, "for_api")                                     \
   V(for_intern_string, "for_intern")                               \
   V(private_api_string, "private_api")                             \
   V(private_intern_string, "private_intern")                       \
   V(Date_string, "Date")                                           \
-  V(to_string_string, "toString")                                  \
   V(char_at_string, "CharAt")                                      \
   V(undefined_string, "undefined")                                 \
   V(value_of_string, "valueOf")                                    \
   V(stack_string, "stack")                                         \
   V(toJSON_string, "toJSON")                                       \
-  V(InitializeVarGlobal_string, "InitializeVarGlobal")             \
-  V(InitializeConstGlobal_string, "InitializeConstGlobal")         \
   V(KeyedLoadMonomorphic_string, "KeyedLoadMonomorphic")           \
   V(KeyedStoreMonomorphic_string, "KeyedStoreMonomorphic")         \
   V(stack_overflow_string, "kStackOverflowBoilerplate")            \
   V(illegal_access_string, "illegal access")                       \
-  V(get_string, "get")                                             \
-  V(set_string, "set")                                             \
-  V(map_field_string, "%map")                                      \
-  V(elements_field_string, "%elements")                            \
-  V(length_field_string, "%length")                                \
   V(cell_value_string, "%cell_value")                              \
-  V(function_class_string, "Function")                             \
   V(illegal_argument_string, "illegal argument")                   \
-  V(space_string, " ")                                             \
-  V(exec_string, "exec")                                           \
-  V(zero_string, "0")                                              \
-  V(global_eval_string, "GlobalEval")                              \
   V(identity_hash_string, "v8::IdentityHash")                      \
   V(closure_string, "(closure)")                                   \
   V(dot_string, ".")                                               \
@@ -355,20 +331,9 @@ namespace internal {
   V(throw_string, "throw")                                         \
   V(done_string, "done")                                           \
   V(value_string, "value")                                         \
-  V(signMask, "signMask")                                                \
-  V(x, "x")                                                              \
-  V(y, "y")                                                              \
-  V(z, "z")                                                              \
-  V(w, "w")                                                              \
-  V(flagX, "flagX")                                                      \
-  V(flagY, "flagY")                                                      \
-  V(flagZ, "flagZ")                                                      \
-  V(flagW, "flagW")                                                      \
-  V(simd, "SIMD")                                                        \
   V(next_string, "next")                                           \
   V(byte_length_string, "byteLength")                              \
   V(byte_offset_string, "byteOffset")                              \
-  V(buffer_string, "buffer")                                       \
   V(intl_initialized_marker_string, "v8::intl_initialized_marker") \
   V(intl_impl_object_string, "v8::intl_object")
 
@@ -749,14 +714,11 @@ class Heap {
       const GCCallbackFlags gc_callback_flags = kNoGCCallbackFlags);
 
   static const int kNoGCFlags = 0;
-  static const int kSweepPreciselyMask = 1;
-  static const int kReduceMemoryFootprintMask = 2;
-  static const int kAbortIncrementalMarkingMask = 4;
+  static const int kReduceMemoryFootprintMask = 1;
+  static const int kAbortIncrementalMarkingMask = 2;
 
-  // Making the heap iterable requires us to sweep precisely and abort any
-  // incremental marking as well.
-  static const int kMakeHeapIterableMask =
-      kSweepPreciselyMask | kAbortIncrementalMarkingMask;
+  // Making the heap iterable requires us to abort incremental marking.
+  static const int kMakeHeapIterableMask = kAbortIncrementalMarkingMask;
 
   // Performs a full garbage collection.  If (flags & kMakeHeapIterableMask) is
   // non-zero, then the slower precise sweeper is used, which leaves the heap
@@ -978,7 +940,7 @@ class Heap {
 
   // Returns deterministic "time" value in ms. Works only with
   // FLAG_verify_predictable.
-  double synthetic_time() { return allocations_count_ / 100.0; }
+  double synthetic_time() { return allocations_count_ / 2.0; }
 
   // Print short heap statistics.
   void PrintShortHeapStatistics();
@@ -1086,7 +1048,7 @@ class Heap {
   void DisableInlineAllocation();
 
   // Implements the corresponding V8 API function.
-  bool IdleNotification(int hint);
+  bool IdleNotification(int idle_time_in_ms);
 
   // Declare all the root indices.  This defines the root list order.
   enum RootListIndex {
@@ -1432,21 +1394,6 @@ class Heap {
       AllocateHeapNumber(double value, MutableMode mode = IMMUTABLE,
                          PretenureFlag pretenure = NOT_TENURED);
 
-  // Allocated a Float32x4 from value.
-  MUST_USE_RESULT AllocationResult AllocateFloat32x4(
-      float32x4_value_t value,
-      PretenureFlag pretenure = NOT_TENURED);
-
-  // Allocated a Float64x2 from value.
-  MUST_USE_RESULT AllocationResult AllocateFloat64x2(
-      float64x2_value_t value,
-      PretenureFlag pretenure = NOT_TENURED);
-
-  // Allocated a Int32x4 from value.
-  MUST_USE_RESULT AllocationResult AllocateInt32x4(
-      int32x4_value_t value,
-      PretenureFlag pretenure = NOT_TENURED);
-
   // Allocate a byte array of the specified length
   MUST_USE_RESULT AllocationResult
       AllocateByteArray(int length, PretenureFlag pretenure = NOT_TENURED);
@@ -1749,9 +1696,9 @@ class Heap {
                                    Object* filler);
 
   // Allocate and partially initializes a String.  There are two String
-  // encodings: ASCII and two byte.  These functions allocate a string of the
-  // given length and set its map and length fields.  The characters of the
-  // string are uninitialized.
+  // encodings: one-byte and two-byte.  These functions allocate a string of
+  // the given length and set its map and length fields.  The characters of
+  // the string are uninitialized.
   MUST_USE_RESULT AllocationResult
       AllocateRawOneByteString(int length, PretenureFlag pretenure);
   MUST_USE_RESULT AllocationResult
@@ -1803,7 +1750,7 @@ class Heap {
 
 
   // Computes a single character string where the character has code.
-  // A cache is used for ASCII codes.
+  // A cache is used for one-byte (Latin1) codes.
   MUST_USE_RESULT AllocationResult
       LookupSingleCharacterStringFromCode(uint16_t code);
 
@@ -1979,31 +1926,10 @@ class Heap {
 
   void SelectScavengingVisitorsTable();
 
-  void StartIdleRound() { mark_sweeps_since_idle_round_started_ = 0; }
-
-  void FinishIdleRound() {
-    mark_sweeps_since_idle_round_started_ = kMaxMarkSweepsInIdleRound;
-    scavenges_since_last_idle_round_ = 0;
-  }
-
-  bool EnoughGarbageSinceLastIdleRound() {
-    return (scavenges_since_last_idle_round_ >= kIdleScavengeThreshold);
-  }
-
-  // Estimates how many milliseconds a Mark-Sweep would take to complete.
-  // In idle notification handler we assume that this function will return:
-  // - a number less than 10 for small heaps, which are less than 8Mb.
-  // - a number greater than 10 for large heaps, which are greater than 32Mb.
-  int TimeMarkSweepWouldTakeInMs() {
-    // Rough estimate of how many megabytes of heap can be processed in 1 ms.
-    static const int kMbPerMs = 2;
-
-    int heap_size_mb = static_cast<int>(SizeOfObjects() / MB);
-    return heap_size_mb / kMbPerMs;
-  }
-
   void AdvanceIdleIncrementalMarking(intptr_t step_size);
 
+  bool WorthActivatingIncrementalMarking();
+
   void ClearObjectStats(bool clear_last_time_stats = false);
 
   void set_weak_object_to_code_table(Object* value) {
@@ -2055,13 +1981,8 @@ class Heap {
 
   IncrementalMarking incremental_marking_;
 
-  int number_idle_notifications_;
-  unsigned int last_idle_notification_gc_count_;
-  bool last_idle_notification_gc_count_init_;
-
-  int mark_sweeps_since_idle_round_started_;
+  GCIdleTimeHandler gc_idle_time_handler_;
   unsigned int gc_count_at_last_idle_gc_;
-  int scavenges_since_last_idle_round_;
 
   // These two counters are monotomically increasing and never reset.
   size_t full_codegen_bytes_generated_;
@@ -2079,7 +2000,7 @@ class Heap {
   static const int kAllocationSiteScratchpadSize = 256;
   int allocation_sites_scratchpad_length_;
 
-  static const int kMaxMarkSweepsInIdleRound = 7;
+  static const int kMaxMarkCompactsInIdleRound = 7;
   static const int kIdleScavengeThreshold = 5;
 
   // Shared state read by the scavenge collector and set by ScavengeObject.