Revision f230a1cf deps/v8/src/objects.h

View differences:

deps/v8/src/objects.h
333 333
// NOTE: Everything following JS_VALUE_TYPE is considered a
334 334
// JSObject for GC purposes. The first four entries here have typeof
335 335
// 'object', whereas JS_FUNCTION_TYPE has typeof 'function'.
336
#define INSTANCE_TYPE_LIST_ALL(V)                                              \
336
#define INSTANCE_TYPE_LIST(V)                                                  \
337 337
  V(STRING_TYPE)                                                               \
338 338
  V(ASCII_STRING_TYPE)                                                         \
339 339
  V(CONS_STRING_TYPE)                                                          \
......
405 405
                                                                               \
406 406
  V(FIXED_ARRAY_TYPE)                                                          \
407 407
  V(FIXED_DOUBLE_ARRAY_TYPE)                                                   \
408
  V(CONSTANT_POOL_ARRAY_TYPE)                                                  \
408 409
  V(SHARED_FUNCTION_INFO_TYPE)                                                 \
409 410
                                                                               \
410 411
  V(JS_MESSAGE_OBJECT_TYPE)                                                    \
......
431 432
                                                                               \
432 433
  V(JS_FUNCTION_TYPE)                                                          \
433 434
  V(JS_FUNCTION_PROXY_TYPE)                                                    \
434

  
435
#ifdef ENABLE_DEBUGGER_SUPPORT
436
#define INSTANCE_TYPE_LIST_DEBUGGER(V)                                         \
437 435
  V(DEBUG_INFO_TYPE)                                                           \
438 436
  V(BREAK_POINT_INFO_TYPE)
439
#else
440
#define INSTANCE_TYPE_LIST_DEBUGGER(V)
441
#endif
442

  
443
#define INSTANCE_TYPE_LIST(V)                                                  \
444
  INSTANCE_TYPE_LIST_ALL(V)                                                    \
445
  INSTANCE_TYPE_LIST_DEBUGGER(V)
446 437

  
447 438

  
448 439
// Since string types are not consecutive, this macro is used to
......
725 716
  EXTERNAL_DOUBLE_ARRAY_TYPE,
726 717
  EXTERNAL_PIXEL_ARRAY_TYPE,  // LAST_EXTERNAL_ARRAY_TYPE
727 718
  FIXED_DOUBLE_ARRAY_TYPE,
719
  CONSTANT_POOL_ARRAY_TYPE,
728 720
  FILLER_TYPE,  // LAST_DATA_TYPE
729 721

  
730 722
  // Structs.
......
873 865
  inline void set_##name(type* value,                                   \
874 866
                         WriteBarrierMode mode = UPDATE_WRITE_BARRIER); \
875 867

  
876

  
877 868
class AccessorPair;
869
class AllocationSite;
870
class AllocationSiteContext;
878 871
class DictionaryElementsAccessor;
879 872
class ElementsAccessor;
880 873
class Failure;
......
1010 1003
  V(TypeFeedbackCells)                         \
1011 1004
  V(FixedArray)                                \
1012 1005
  V(FixedDoubleArray)                          \
1006
  V(ConstantPoolArray)                         \
1013 1007
  V(Context)                                   \
1014 1008
  V(NativeContext)                             \
1015 1009
  V(ScopeInfo)                                 \
......
1054 1048
  V(AccessCheckNeeded)                         \
1055 1049
  V(Cell)                                      \
1056 1050
  V(PropertyCell)                              \
1057
  V(ObjectHashTable)
1051
  V(ObjectHashTable)                           \
1052
  V(WeakHashTable)
1058 1053

  
1059 1054

  
1060 1055
#define ERROR_MESSAGES_LIST(V) \
......
1206 1201
  V(kModuleStatement, "Module statement")                                     \
1207 1202
  V(kModuleVariable, "Module variable")                                       \
1208 1203
  V(kModuleUrl, "Module url")                                                 \
1204
  V(kNativeFunctionLiteral, "Native function literal")                        \
1209 1205
  V(kNoCasesLeft, "no cases left")                                            \
1210 1206
  V(kNoEmptyArraysHereInEmitFastAsciiArrayJoin,                               \
1211 1207
    "No empty arrays here in EmitFastAsciiArrayJoin")                         \
......
1249 1245
  V(kRegisterDidNotMatchExpectedRoot, "Register did not match expected root") \
1250 1246
  V(kRegisterWasClobbered, "register was clobbered")                          \
1251 1247
  V(kScopedBlock, "ScopedBlock")                                              \
1252
  V(kSharedFunctionInfoLiteral, "Shared function info literal")               \
1253 1248
  V(kSmiAdditionOverflow, "Smi addition overflow")                            \
1254 1249
  V(kSmiSubtractionOverflow, "Smi subtraction overflow")                      \
1255 1250
  V(kStackFrameTypesMustMatch, "stack frame types must match")                \
......
1440 1435
  }
1441 1436

  
1442 1437
  inline MaybeObject* AllocateNewStorageFor(Heap* heap,
1443
                                            Representation representation,
1444
                                            PretenureFlag tenure = NOT_TENURED);
1438
                                            Representation representation);
1445 1439

  
1446 1440
  // Returns true if the object is of the correct type to be used as a
1447 1441
  // implementation of a JSObject's elements.
......
1467 1461
  MUST_USE_RESULT inline MaybeObject* GetProperty(
1468 1462
      Name* key,
1469 1463
      PropertyAttributes* attributes);
1464

  
1465
  // TODO(yangguo): this should eventually replace the non-handlified version.
1466
  static Handle<Object> GetPropertyWithReceiver(Handle<Object> object,
1467
                                                Handle<Object> receiver,
1468
                                                Handle<Name> name,
1469
                                                PropertyAttributes* attributes);
1470 1470
  MUST_USE_RESULT MaybeObject* GetPropertyWithReceiver(
1471 1471
      Object* receiver,
1472 1472
      Name* key,
......
1950 1950
  // Casting.
1951 1951
  static inline JSReceiver* cast(Object* obj);
1952 1952

  
1953
  // Implementation of [[Put]], ECMA-262 5th edition, section 8.12.5.
1953 1954
  static Handle<Object> SetProperty(Handle<JSReceiver> object,
1954 1955
                                    Handle<Name> key,
1955 1956
                                    Handle<Object> value,
1956 1957
                                    PropertyAttributes attributes,
1957
                                    StrictModeFlag strict_mode);
1958
                                    StrictModeFlag strict_mode,
1959
                                    StoreFromKeyed store_mode =
1960
                                        MAY_BE_STORE_FROM_KEYED);
1958 1961
  static Handle<Object> SetElement(Handle<JSReceiver> object,
1959 1962
                                   uint32_t index,
1960 1963
                                   Handle<Object> value,
1961 1964
                                   PropertyAttributes attributes,
1962 1965
                                   StrictModeFlag strict_mode);
1963 1966

  
1964
  MUST_USE_RESULT static MaybeObject* SetPropertyOrFail(
1965
      Handle<JSReceiver> object,
1966
      Handle<Name> key,
1967
      Handle<Object> value,
1968
      PropertyAttributes attributes,
1969
      StrictModeFlag strict_mode,
1970
      StoreFromKeyed store_from_keyed = MAY_BE_STORE_FROM_KEYED);
1971

  
1972
  // Can cause GC.
1973
  MUST_USE_RESULT MaybeObject* SetProperty(
1974
      Name* key,
1975
      Object* value,
1976
      PropertyAttributes attributes,
1977
      StrictModeFlag strict_mode,
1978
      StoreFromKeyed store_from_keyed = MAY_BE_STORE_FROM_KEYED);
1979
  MUST_USE_RESULT MaybeObject* SetProperty(
1980
      LookupResult* result,
1981
      Name* key,
1982
      Object* value,
1983
      PropertyAttributes attributes,
1984
      StrictModeFlag strict_mode,
1985
      StoreFromKeyed store_from_keyed = MAY_BE_STORE_FROM_KEYED);
1986
  MUST_USE_RESULT MaybeObject* SetPropertyWithDefinedSetter(JSReceiver* setter,
1987
                                                            Object* value);
1967
  // Implementation of [[HasProperty]], ECMA-262 5th edition, section 8.12.6.
1968
  static inline bool HasProperty(Handle<JSReceiver> object, Handle<Name> name);
1969
  static inline bool HasLocalProperty(Handle<JSReceiver>, Handle<Name> name);
1970
  static inline bool HasElement(Handle<JSReceiver> object, uint32_t index);
1971
  static inline bool HasLocalElement(Handle<JSReceiver> object, uint32_t index);
1988 1972

  
1973
  // Implementation of [[Delete]], ECMA-262 5th edition, section 8.12.7.
1989 1974
  static Handle<Object> DeleteProperty(Handle<JSReceiver> object,
1990 1975
                                       Handle<Name> name,
1991 1976
                                       DeleteMode mode = NORMAL_DELETION);
......
2011 1996
  inline PropertyAttributes GetElementAttribute(uint32_t index);
2012 1997
  inline PropertyAttributes GetLocalElementAttribute(uint32_t index);
2013 1998

  
2014
  // Can cause a GC.
2015
  inline bool HasProperty(Name* name);
2016
  inline bool HasLocalProperty(Name* name);
2017
  inline bool HasElement(uint32_t index);
2018
  inline bool HasLocalElement(uint32_t index);
2019

  
2020 1999
  // Return the object's prototype (might be Heap::null_value()).
2021 2000
  inline Object* GetPrototype();
2022 2001

  
......
2036 2015
 protected:
2037 2016
  Smi* GenerateIdentityHash();
2038 2017

  
2018
  static Handle<Object> SetPropertyWithDefinedSetter(Handle<JSReceiver> object,
2019
                                                     Handle<JSReceiver> setter,
2020
                                                     Handle<Object> value);
2021

  
2039 2022
 private:
2040 2023
  PropertyAttributes GetPropertyAttributeForResult(JSReceiver* receiver,
2041 2024
                                                   LookupResult* result,
2042 2025
                                                   Name* name,
2043 2026
                                                   bool continue_search);
2044 2027

  
2028
  static Handle<Object> SetProperty(Handle<JSReceiver> receiver,
2029
                                    LookupResult* result,
2030
                                    Handle<Name> key,
2031
                                    Handle<Object> value,
2032
                                    PropertyAttributes attributes,
2033
                                    StrictModeFlag strict_mode,
2034
                                    StoreFromKeyed store_from_keyed);
2035

  
2045 2036
  DISALLOW_IMPLICIT_CONSTRUCTORS(JSReceiver);
2046 2037
};
2047 2038

  
......
2121 2112
      WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
2122 2113

  
2123 2114
  // Requires: HasFastElements().
2115
  static Handle<FixedArray> EnsureWritableFastElements(
2116
      Handle<JSObject> object);
2124 2117
  MUST_USE_RESULT inline MaybeObject* EnsureWritableFastElements();
2125 2118

  
2126 2119
  // Collects elements starting at index 0.
2127 2120
  // Undefined values are placed after non-undefined values.
2128 2121
  // Returns the number of non-undefined values.
2129
  MUST_USE_RESULT MaybeObject* PrepareElementsForSort(uint32_t limit);
2122
  static Handle<Object> PrepareElementsForSort(Handle<JSObject> object,
2123
                                               uint32_t limit);
2130 2124
  // As PrepareElementsForSort, but only on objects where elements is
2131 2125
  // a dictionary, and it will stay a dictionary.
2126
  static Handle<Object> PrepareSlowElementsForSort(Handle<JSObject> object,
2127
                                                   uint32_t limit);
2132 2128
  MUST_USE_RESULT MaybeObject* PrepareSlowElementsForSort(uint32_t limit);
2133 2129

  
2134
  MUST_USE_RESULT MaybeObject* GetPropertyWithCallback(Object* receiver,
2135
                                                       Object* structure,
2136
                                                       Name* name);
2130
  static Handle<Object> GetPropertyWithCallback(Handle<JSObject> object,
2131
                                                Handle<Object> receiver,
2132
                                                Handle<Object> structure,
2133
                                                Handle<Name> name);
2137 2134

  
2138
  // Can cause GC.
2139
  MUST_USE_RESULT MaybeObject* SetPropertyForResult(LookupResult* result,
2140
                                           Name* key,
2141
                                           Object* value,
2142
                                           PropertyAttributes attributes,
2143
                                           StrictModeFlag strict_mode,
2144
                                           StoreFromKeyed store_mode);
2145
  MUST_USE_RESULT MaybeObject* SetPropertyWithFailedAccessCheck(
2146
      LookupResult* result,
2147
      Name* name,
2148
      Object* value,
2149
      bool check_prototype,
2150
      StrictModeFlag strict_mode);
2151
  MUST_USE_RESULT MaybeObject* SetPropertyWithCallback(
2152
      Object* structure,
2153
      Name* name,
2154
      Object* value,
2155
      JSObject* holder,
2135
  static Handle<Object> SetPropertyWithCallback(
2136
      Handle<JSObject> object,
2137
      Handle<Object> structure,
2138
      Handle<Name> name,
2139
      Handle<Object> value,
2140
      Handle<JSObject> holder,
2156 2141
      StrictModeFlag strict_mode);
2157
  MUST_USE_RESULT MaybeObject* SetPropertyWithInterceptor(
2158
      Name* name,
2159
      Object* value,
2142

  
2143
  static Handle<Object> SetPropertyWithInterceptor(
2144
      Handle<JSObject> object,
2145
      Handle<Name> name,
2146
      Handle<Object> value,
2160 2147
      PropertyAttributes attributes,
2161 2148
      StrictModeFlag strict_mode);
2162
  MUST_USE_RESULT MaybeObject* SetPropertyPostInterceptor(
2163
      Name* name,
2164
      Object* value,
2149

  
2150
  static Handle<Object> SetPropertyForResult(
2151
      Handle<JSObject> object,
2152
      LookupResult* result,
2153
      Handle<Name> name,
2154
      Handle<Object> value,
2165 2155
      PropertyAttributes attributes,
2166 2156
      StrictModeFlag strict_mode,
2167
      StoreMode mode = ALLOW_AS_CONSTANT);
2157
      StoreFromKeyed store_mode = MAY_BE_STORE_FROM_KEYED);
2168 2158

  
2169 2159
  static Handle<Object> SetLocalPropertyIgnoreAttributes(
2170 2160
      Handle<JSObject> object,
......
2183 2173
  static inline Handle<Map> FindTransitionToField(Handle<Map> map,
2184 2174
                                                  Handle<Name> key);
2185 2175

  
2186
  inline int LastAddedFieldIndex();
2187

  
2188 2176
  // Extend the receiver with a single fast property appeared first in the
2189 2177
  // passed map. This also extends the property backing store if necessary.
2190 2178
  static void AllocateStorageForMap(Handle<JSObject> object, Handle<Map> map);
2191
  inline MUST_USE_RESULT MaybeObject* AllocateStorageForMap(Map* map);
2192 2179

  
2180
  // Migrates the given object to a map whose field representations are the
2181
  // lowest upper bound of all known representations for that field.
2193 2182
  static void MigrateInstance(Handle<JSObject> instance);
2194
  inline MUST_USE_RESULT MaybeObject* MigrateInstance();
2195 2183

  
2184
  // Migrates the given object only if the target map is already available,
2185
  // or returns an empty handle if such a map is not yet available.
2196 2186
  static Handle<Object> TryMigrateInstance(Handle<JSObject> instance);
2197
  inline MUST_USE_RESULT MaybeObject* TryMigrateInstance();
2198 2187

  
2199 2188
  // Can cause GC.
2200 2189
  MUST_USE_RESULT MaybeObject* SetLocalPropertyIgnoreAttributesTrampoline(
......
2209 2198
  // Handles the special representation of JS global objects.
2210 2199
  Object* GetNormalizedProperty(LookupResult* result);
2211 2200

  
2212
  // Sets the property value in a normalized object given (key, value).
2213
  // Handles the special representation of JS global objects.
2214
  static Handle<Object> SetNormalizedProperty(Handle<JSObject> object,
2215
                                              LookupResult* result,
2216
                                              Handle<Object> value);
2217

  
2218 2201
  // Sets the property value in a normalized object given a lookup result.
2219 2202
  // Handles the special representation of JS global objects.
2220
  MUST_USE_RESULT MaybeObject* SetNormalizedProperty(LookupResult* result,
2221
                                                     Object* value);
2203
  static void SetNormalizedProperty(Handle<JSObject> object,
2204
                                    LookupResult* result,
2205
                                    Handle<Object> value);
2222 2206

  
2223 2207
  // Sets the property value in a normalized object given (key, value, details).
2224 2208
  // Handles the special representation of JS global objects.
2225
  static Handle<Object> SetNormalizedProperty(Handle<JSObject> object,
2226
                                              Handle<Name> key,
2227
                                              Handle<Object> value,
2228
                                              PropertyDetails details);
2229

  
2230
  MUST_USE_RESULT MaybeObject* SetNormalizedProperty(Name* name,
2231
                                                     Object* value,
2232
                                                     PropertyDetails details);
2209
  static void SetNormalizedProperty(Handle<JSObject> object,
2210
                                    Handle<Name> key,
2211
                                    Handle<Object> value,
2212
                                    PropertyDetails details);
2233 2213

  
2234 2214
  static void OptimizeAsPrototype(Handle<JSObject> object);
2235 2215

  
......
2253 2233
                                                     uint32_t index,
2254 2234
                                                     bool continue_search);
2255 2235

  
2236
  // Retrieves an AccessorPair property from the given object. Might return
2237
  // undefined if the property doesn't exist or is of a different kind.
2238
  static Handle<Object> GetAccessor(Handle<JSObject> object,
2239
                                    Handle<Name> name,
2240
                                    AccessorComponent component);
2241

  
2242
  // Defines an AccessorPair property on the given object.
2243
  // TODO(mstarzinger): Rename to SetAccessor() and return empty handle on
2244
  // exception instead of letting callers check for scheduled exception.
2256 2245
  static void DefineAccessor(Handle<JSObject> object,
2257 2246
                             Handle<Name> name,
2258 2247
                             Handle<Object> getter,
......
2260 2249
                             PropertyAttributes attributes,
2261 2250
                             v8::AccessControl access_control = v8::DEFAULT);
2262 2251

  
2263
  MaybeObject* LookupAccessor(Name* name, AccessorComponent component);
2264

  
2252
  // Defines an AccessorInfo property on the given object.
2265 2253
  static Handle<Object> SetAccessor(Handle<JSObject> object,
2266 2254
                                    Handle<AccessorInfo> info);
2267 2255

  
2268
  // Used from Object::GetProperty().
2269
  MUST_USE_RESULT MaybeObject* GetPropertyWithFailedAccessCheck(
2270
      Object* receiver,
2271
      LookupResult* result,
2272
      Name* name,
2273
      PropertyAttributes* attributes);
2274
  MUST_USE_RESULT MaybeObject* GetPropertyWithInterceptor(
2275
      Object* receiver,
2276
      Name* name,
2256
  static Handle<Object> GetPropertyWithInterceptor(
2257
      Handle<JSObject> object,
2258
      Handle<Object> receiver,
2259
      Handle<Name> name,
2277 2260
      PropertyAttributes* attributes);
2278
  MUST_USE_RESULT MaybeObject* GetPropertyPostInterceptor(
2279
      Object* receiver,
2280
      Name* name,
2261
  static Handle<Object> GetPropertyPostInterceptor(
2262
      Handle<JSObject> object,
2263
      Handle<Object> receiver,
2264
      Handle<Name> name,
2281 2265
      PropertyAttributes* attributes);
2282 2266
  MUST_USE_RESULT MaybeObject* GetLocalPropertyPostInterceptor(
2283 2267
      Object* receiver,
......
2361 2345
    return old_capacity + (old_capacity >> 1) + 16;
2362 2346
  }
2363 2347

  
2364
  PropertyType GetLocalPropertyType(Name* name);
2365
  PropertyType GetLocalElementType(uint32_t index);
2366

  
2367 2348
  // These methods do not perform access checks!
2368 2349
  AccessorPair* GetLocalPropertyAccessorPair(Name* name);
2369 2350
  AccessorPair* GetLocalElementAccessorPair(uint32_t index);
......
2438 2419
  inline bool HasIndexedInterceptor();
2439 2420

  
2440 2421
  // Support functions for v8 api (needed for correct interceptor behavior).
2441
  bool HasRealNamedProperty(Isolate* isolate, Name* key);
2442
  bool HasRealElementProperty(Isolate* isolate, uint32_t index);
2443
  bool HasRealNamedCallbackProperty(Isolate* isolate, Name* key);
2422
  static bool HasRealNamedProperty(Handle<JSObject> object,
2423
                                   Handle<Name> key);
2424
  static bool HasRealElementProperty(Handle<JSObject> object, uint32_t index);
2425
  static bool HasRealNamedCallbackProperty(Handle<JSObject> object,
2426
                                           Handle<Name> key);
2444 2427

  
2445 2428
  // Get the header size for a JSObject.  Used to compute the index of
2446 2429
  // internal fields as well as the number of internal fields.
......
2456 2439
  void LocalLookupRealNamedProperty(Name* name, LookupResult* result);
2457 2440
  void LookupRealNamedProperty(Name* name, LookupResult* result);
2458 2441
  void LookupRealNamedPropertyInPrototypes(Name* name, LookupResult* result);
2459
  MUST_USE_RESULT MaybeObject* SetElementWithCallbackSetterInPrototypes(
2460
      uint32_t index, Object* value, bool* found, StrictModeFlag strict_mode);
2461 2442
  void LookupCallbackProperty(Name* name, LookupResult* result);
2462 2443

  
2463 2444
  // Returns the number of properties on this object filtering out properties
......
2483 2464
  // Returns the number of enumerable elements.
2484 2465
  int GetEnumElementKeys(FixedArray* storage);
2485 2466

  
2486
  // Add a property to a fast-case object using a map transition to
2487
  // new_map.
2488
  MUST_USE_RESULT MaybeObject* AddFastPropertyUsingMap(
2489
      Map* new_map,
2490
      Name* name,
2491
      Object* value,
2492
      int field_index,
2493
      Representation representation);
2494

  
2495
  // Add a constant function property to a fast-case object.
2496
  // This leaves a CONSTANT_TRANSITION in the old map, and
2497
  // if it is called on a second object with this map, a
2498
  // normal property is added instead, with a map transition.
2499
  // This avoids the creation of many maps with the same constant
2500
  // function, all orphaned.
2501
  MUST_USE_RESULT MaybeObject* AddConstantProperty(
2502
      Name* name,
2503
      Object* constant,
2504
      PropertyAttributes attributes,
2505
      TransitionFlag flag);
2506

  
2507
  MUST_USE_RESULT MaybeObject* ReplaceSlowProperty(
2508
      Name* name,
2509
      Object* value,
2510
      PropertyAttributes attributes);
2511

  
2512 2467
  // Returns a new map with all transitions dropped from the object's current
2513 2468
  // map and the ElementsKind set.
2514 2469
  static Handle<Map> GetElementsTransitionMap(Handle<JSObject> object,
......
2519 2474
  MUST_USE_RESULT MaybeObject* GetElementsTransitionMapSlow(
2520 2475
      ElementsKind elements_kind);
2521 2476

  
2522
  static Handle<Object> TransitionElementsKind(Handle<JSObject> object,
2523
                                               ElementsKind to_kind);
2477
  static void TransitionElementsKind(Handle<JSObject> object,
2478
                                     ElementsKind to_kind);
2524 2479

  
2525 2480
  MUST_USE_RESULT MaybeObject* TransitionElementsKind(ElementsKind to_kind);
2526 2481
  MUST_USE_RESULT MaybeObject* UpdateAllocationSite(ElementsKind to_kind);
2527 2482

  
2528
  MUST_USE_RESULT MaybeObject* MigrateToMap(Map* new_map);
2529
  MUST_USE_RESULT MaybeObject* GeneralizeFieldRepresentation(
2530
      int modify_index,
2531
      Representation new_representation,
2532
      StoreMode store_mode);
2533

  
2534
  // Add a property to a fast-case object.
2535
  MUST_USE_RESULT MaybeObject* AddFastProperty(
2536
      Name* name,
2537
      Object* value,
2538
      PropertyAttributes attributes,
2539
      StoreFromKeyed store_mode = MAY_BE_STORE_FROM_KEYED,
2540
      ValueType value_type = OPTIMAL_REPRESENTATION,
2541
      TransitionFlag flag = INSERT_TRANSITION);
2542

  
2543
  // Add a property to a slow-case object.
2544
  MUST_USE_RESULT MaybeObject* AddSlowProperty(Name* name,
2545
                                               Object* value,
2546
                                               PropertyAttributes attributes);
2547

  
2548
  // Add a property to an object. May cause GC.
2549
  MUST_USE_RESULT MaybeObject* AddProperty(
2550
      Name* name,
2551
      Object* value,
2552
      PropertyAttributes attributes,
2553
      StrictModeFlag strict_mode,
2554
      StoreFromKeyed store_mode = MAY_BE_STORE_FROM_KEYED,
2555
      ExtensibilityCheck extensibility_check = PERFORM_EXTENSIBILITY_CHECK,
2556
      ValueType value_type = OPTIMAL_REPRESENTATION,
2557
      StoreMode mode = ALLOW_AS_CONSTANT,
2558
      TransitionFlag flag = INSERT_TRANSITION);
2483
  // TODO(mstarzinger): Both public because of ConvertAnsSetLocalProperty().
2484
  static void MigrateToMap(Handle<JSObject> object, Handle<Map> new_map);
2485
  static void GeneralizeFieldRepresentation(Handle<JSObject> object,
2486
                                            int modify_index,
2487
                                            Representation new_representation,
2488
                                            StoreMode store_mode);
2559 2489

  
2560 2490
  // Convert the object to use the canonical dictionary
2561 2491
  // representation. If the object is expected to have additional properties
......
2565 2495
                                  PropertyNormalizationMode mode,
2566 2496
                                  int expected_additional_properties);
2567 2497

  
2568
  MUST_USE_RESULT MaybeObject* NormalizeProperties(
2569
      PropertyNormalizationMode mode,
2570
      int expected_additional_properties);
2571

  
2572 2498
  // Convert and update the elements backing store to be a
2573 2499
  // SeededNumberDictionary dictionary.  Returns the backing after conversion.
2574 2500
  static Handle<SeededNumberDictionary> NormalizeElements(
......
2577 2503
  MUST_USE_RESULT MaybeObject* NormalizeElements();
2578 2504

  
2579 2505
  // Transform slow named properties to fast variants.
2580
  // Returns failure if allocation failed.
2581 2506
  static void TransformToFastProperties(Handle<JSObject> object,
2582 2507
                                        int unused_property_fields);
2583 2508

  
2584
  MUST_USE_RESULT MaybeObject* TransformToFastProperties(
2585
      int unused_property_fields);
2586

  
2587 2509
  // Access fast-case object properties at index.
2588 2510
  MUST_USE_RESULT inline MaybeObject* FastPropertyAt(
2589 2511
      Representation representation,
......
2616 2538
  // Check whether this object references another object
2617 2539
  bool ReferencesObject(Object* obj);
2618 2540

  
2619
  // Casting.
2620
  static inline JSObject* cast(Object* obj);
2621

  
2622 2541
  // Disalow further properties to be added to the object.
2623 2542
  static Handle<Object> PreventExtensions(Handle<JSObject> object);
2624
  MUST_USE_RESULT MaybeObject* PreventExtensions();
2625 2543

  
2626 2544
  // ES5 Object.freeze
2627
  MUST_USE_RESULT MaybeObject* Freeze(Isolate* isolate);
2628

  
2545
  static Handle<Object> Freeze(Handle<JSObject> object);
2629 2546

  
2630 2547
  // Called the first time an object is observed with ES7 Object.observe.
2631
  MUST_USE_RESULT MaybeObject* SetObserved(Isolate* isolate);
2548
  static void SetObserved(Handle<JSObject> object);
2632 2549

  
2633
  // Copy object
2634
  MUST_USE_RESULT MaybeObject* DeepCopy(Isolate* isolate);
2550
  // Copy object.
2551
  static Handle<JSObject> Copy(Handle<JSObject> object,
2552
                               Handle<AllocationSite> site);
2553
  static Handle<JSObject> Copy(Handle<JSObject> object);
2554
  static Handle<JSObject> DeepCopy(Handle<JSObject> object,
2555
                                   AllocationSiteContext* site_context);
2556
  static Handle<JSObject> DeepWalk(Handle<JSObject> object,
2557
                                   AllocationSiteContext* site_context);
2558

  
2559
  // Casting.
2560
  static inline JSObject* cast(Object* obj);
2635 2561

  
2636 2562
  // Dispatched behavior.
2637 2563
  void JSObjectShortPrint(StringStream* accumulator);
......
2670 2596

  
2671 2597
  void IncrementSpillStatistics(SpillInformation* info);
2672 2598
#endif
2599

  
2600
#ifdef VERIFY_HEAP
2601
  // If a GC was caused while constructing this object, the elements pointer
2602
  // may point to a one pointer filler map. The object won't be rooted, but
2603
  // our heap verification code could stumble across it.
2604
  bool ElementsAreSafeToExamine();
2605
#endif
2606

  
2673 2607
  Object* SlowReverseLookup(Object* value);
2674 2608

  
2675 2609
  // Maximal number of fast properties for the JSObject. Used to
......
2733 2667
 private:
2734 2668
  friend class DictionaryElementsAccessor;
2735 2669
  friend class JSReceiver;
2670
  friend class Object;
2736 2671

  
2737
  // TODO(mstarzinger): Soon to be handlified.
2738
  MUST_USE_RESULT MaybeObject* SetLocalPropertyIgnoreAttributes(
2739
      Name* key,
2740
      Object* value,
2741
      PropertyAttributes attributes,
2742
      ValueType value_type = OPTIMAL_REPRESENTATION,
2743
      StoreMode mode = ALLOW_AS_CONSTANT,
2744
      ExtensibilityCheck extensibility_check = PERFORM_EXTENSIBILITY_CHECK);
2672
  // Used from Object::GetProperty().
2673
  static Handle<Object> GetPropertyWithFailedAccessCheck(
2674
      Handle<JSObject> object,
2675
      Handle<Object> receiver,
2676
      LookupResult* result,
2677
      Handle<Name> name,
2678
      PropertyAttributes* attributes);
2745 2679

  
2746 2680
  MUST_USE_RESULT MaybeObject* GetElementWithCallback(Object* receiver,
2747 2681
                                                      Object* structure,
......
2755 2689
      JSReceiver* receiver,
2756 2690
      uint32_t index,
2757 2691
      bool continue_search);
2758
  MUST_USE_RESULT MaybeObject* SetElementWithCallback(
2759
      Object* structure,
2692
  static Handle<Object> SetElementWithCallback(
2693
      Handle<JSObject> object,
2694
      Handle<Object> structure,
2760 2695
      uint32_t index,
2761
      Object* value,
2762
      JSObject* holder,
2696
      Handle<Object> value,
2697
      Handle<JSObject> holder,
2763 2698
      StrictModeFlag strict_mode);
2764 2699
  MUST_USE_RESULT MaybeObject* SetElementWithInterceptor(
2765 2700
      uint32_t index,
......
2775 2710
      StrictModeFlag strict_mode,
2776 2711
      bool check_prototype,
2777 2712
      SetPropertyMode set_mode);
2713
  MUST_USE_RESULT MaybeObject* SetElementWithCallbackSetterInPrototypes(
2714
      uint32_t index,
2715
      Object* value,
2716
      bool* found,
2717
      StrictModeFlag strict_mode);
2778 2718

  
2779 2719
  // Searches the prototype chain for property 'name'. If it is found and
2780 2720
  // has a setter, invoke it and set '*done' to true. If it is found and is
2781 2721
  // read-only, reject and set '*done' to true. Otherwise, set '*done' to
2782
  // false. Can cause GC and can return a failure result with '*done==true'.
2783
  MUST_USE_RESULT MaybeObject* SetPropertyViaPrototypes(
2784
      Name* name,
2785
      Object* value,
2722
  // false. Can throw and return an empty handle with '*done==true'.
2723
  static Handle<Object> SetPropertyViaPrototypes(
2724
      Handle<JSObject> object,
2725
      Handle<Name> name,
2726
      Handle<Object> value,
2786 2727
      PropertyAttributes attributes,
2787 2728
      StrictModeFlag strict_mode,
2788 2729
      bool* done);
2730
  static Handle<Object> SetPropertyPostInterceptor(
2731
      Handle<JSObject> object,
2732
      Handle<Name> name,
2733
      Handle<Object> value,
2734
      PropertyAttributes attributes,
2735
      StrictModeFlag strict_mode);
2736
  static Handle<Object> SetPropertyUsingTransition(
2737
      Handle<JSObject> object,
2738
      LookupResult* lookup,
2739
      Handle<Name> name,
2740
      Handle<Object> value,
2741
      PropertyAttributes attributes);
2742
  static Handle<Object> SetPropertyWithFailedAccessCheck(
2743
      Handle<JSObject> object,
2744
      LookupResult* result,
2745
      Handle<Name> name,
2746
      Handle<Object> value,
2747
      bool check_prototype,
2748
      StrictModeFlag strict_mode);
2749

  
2750
  // Add a property to an object.
2751
  static Handle<Object> AddProperty(
2752
      Handle<JSObject> object,
2753
      Handle<Name> name,
2754
      Handle<Object> value,
2755
      PropertyAttributes attributes,
2756
      StrictModeFlag strict_mode,
2757
      StoreFromKeyed store_mode = MAY_BE_STORE_FROM_KEYED,
2758
      ExtensibilityCheck extensibility_check = PERFORM_EXTENSIBILITY_CHECK,
2759
      ValueType value_type = OPTIMAL_REPRESENTATION,
2760
      StoreMode mode = ALLOW_AS_CONSTANT,
2761
      TransitionFlag flag = INSERT_TRANSITION);
2762

  
2763
  // Add a constant function property to a fast-case object.
2764
  // This leaves a CONSTANT_TRANSITION in the old map, and
2765
  // if it is called on a second object with this map, a
2766
  // normal property is added instead, with a map transition.
2767
  // This avoids the creation of many maps with the same constant
2768
  // function, all orphaned.
2769
  static void AddConstantProperty(Handle<JSObject> object,
2770
                                  Handle<Name> name,
2771
                                  Handle<Object> constant,
2772
                                  PropertyAttributes attributes,
2773
                                  TransitionFlag flag);
2774

  
2775
  // Add a property to a fast-case object.
2776
  static void AddFastProperty(Handle<JSObject> object,
2777
                              Handle<Name> name,
2778
                              Handle<Object> value,
2779
                              PropertyAttributes attributes,
2780
                              StoreFromKeyed store_mode,
2781
                              ValueType value_type,
2782
                              TransitionFlag flag);
2783

  
2784
  // Add a property to a fast-case object using a map transition to
2785
  // new_map.
2786
  static void AddFastPropertyUsingMap(Handle<JSObject> object,
2787
                                      Handle<Map> new_map,
2788
                                      Handle<Name> name,
2789
                                      Handle<Object> value,
2790
                                      int field_index,
2791
                                      Representation representation);
2792

  
2793
  // Add a property to a slow-case object.
2794
  static void AddSlowProperty(Handle<JSObject> object,
2795
                              Handle<Name> name,
2796
                              Handle<Object> value,
2797
                              PropertyAttributes attributes);
2789 2798

  
2790 2799
  static Handle<Object> DeleteProperty(Handle<JSObject> object,
2791 2800
                                       Handle<Name> name,
......
2919 2928

  
2920 2929
  // Copy operations.
2921 2930
  MUST_USE_RESULT inline MaybeObject* Copy();
2922
  MUST_USE_RESULT MaybeObject* CopySize(int new_length);
2931
  MUST_USE_RESULT MaybeObject* CopySize(int new_length,
2932
                                        PretenureFlag pretenure = NOT_TENURED);
2923 2933

  
2924 2934
  // Add the elements of a JSArray to this FixedArray.
2925 2935
  MUST_USE_RESULT MaybeObject* AddKeysFromJSArray(JSArray* array);
......
3042 3052
};
3043 3053

  
3044 3054

  
3055
// ConstantPoolArray describes a fixed-sized array containing constant pool
3056
// entires.
3057
// The format of the pool is:
3058
//   [0]: Field holding the first index which is a pointer entry
3059
//   [1]: Field holding the first index which is a int32 entry
3060
//   [2] ... [first_ptr_index() - 1]: 64 bit entries
3061
//   [first_ptr_index()] ... [first_int32_index() - 1]: pointer entries
3062
//   [first_int32_index()] ... [length - 1]: 32 bit entries
3063
class ConstantPoolArray: public FixedArrayBase {
3064
 public:
3065
  // Getters for the field storing the first index for different type entries.
3066
  inline int first_ptr_index();
3067
  inline int first_int64_index();
3068
  inline int first_int32_index();
3069

  
3070
  // Getters for counts of different type entries.
3071
  inline int count_of_ptr_entries();
3072
  inline int count_of_int64_entries();
3073
  inline int count_of_int32_entries();
3074

  
3075
  // Setter and getter for pool elements.
3076
  inline Object* get_ptr_entry(int index);
3077
  inline int64_t get_int64_entry(int index);
3078
  inline int32_t get_int32_entry(int index);
3079
  inline double get_int64_entry_as_double(int index);
3080

  
3081
  inline void set(int index, Object* value);
3082
  inline void set(int index, int64_t value);
3083
  inline void set(int index, double value);
3084
  inline void set(int index, int32_t value);
3085

  
3086
  // Set up initial state.
3087
  inline void SetEntryCounts(int number_of_int64_entries,
3088
                             int number_of_ptr_entries,
3089
                             int number_of_int32_entries);
3090

  
3091
  // Copy operations
3092
  MUST_USE_RESULT inline MaybeObject* Copy();
3093

  
3094
  // Garbage collection support.
3095
  inline static int SizeFor(int number_of_int64_entries,
3096
                            int number_of_ptr_entries,
3097
                            int number_of_int32_entries) {
3098
    return RoundUp(OffsetAt(number_of_int64_entries,
3099
                            number_of_ptr_entries,
3100
                            number_of_int32_entries),
3101
                   kPointerSize);
3102
  }
3103

  
3104
  // Code Generation support.
3105
  inline int OffsetOfElementAt(int index) {
3106
    ASSERT(index < length());
3107
    if (index >= first_int32_index()) {
3108
      return OffsetAt(count_of_int64_entries(), count_of_ptr_entries(),
3109
                      index - first_int32_index());
3110
    } else if (index >= first_ptr_index()) {
3111
      return OffsetAt(count_of_int64_entries(), index - first_ptr_index(), 0);
3112
    } else {
3113
      return OffsetAt(index, 0, 0);
3114
    }
3115
  }
3116

  
3117
  // Casting.
3118
  static inline ConstantPoolArray* cast(Object* obj);
3119

  
3120
  // Layout description.
3121
  static const int kFirstPointerIndexOffset = FixedArray::kHeaderSize;
3122
  static const int kFirstInt32IndexOffset =
3123
      kFirstPointerIndexOffset + kPointerSize;
3124
  static const int kFirstOffset = kFirstInt32IndexOffset + kPointerSize;
3125

  
3126
  // Dispatched behavior.
3127
  void ConstantPoolIterateBody(ObjectVisitor* v);
3128

  
3129
  DECLARE_PRINTER(ConstantPoolArray)
3130
  DECLARE_VERIFIER(ConstantPoolArray)
3131

  
3132
 private:
3133
  inline void set_first_ptr_index(int value);
3134
  inline void set_first_int32_index(int value);
3135

  
3136
  inline static int OffsetAt(int number_of_int64_entries,
3137
                             int number_of_ptr_entries,
3138
                             int number_of_int32_entries) {
3139
    return kFirstOffset
3140
        + (number_of_int64_entries * kInt64Size)
3141
        + (number_of_ptr_entries * kPointerSize)
3142
        + (number_of_int32_entries * kInt32Size);
3143
  }
3144

  
3145
  DISALLOW_IMPLICIT_CONSTRUCTORS(ConstantPoolArray);
3146
};
3147

  
3148

  
3045 3149
// DescriptorArrays are fixed arrays used to hold instance descriptors.
3046 3150
// The format of the these objects is:
3047 3151
//   [0]: Number of descriptors
......
3175 3279
                DescriptorArray* src,
3176 3280
                int src_index,
3177 3281
                const WhitenessWitness&);
3282
  static Handle<DescriptorArray> Merge(Handle<DescriptorArray> desc,
3283
                                       int verbatim,
3284
                                       int valid,
3285
                                       int new_size,
3286
                                       int modify_index,
3287
                                       StoreMode store_mode,
3288
                                       Handle<DescriptorArray> other);
3178 3289
  MUST_USE_RESULT MaybeObject* Merge(int verbatim,
3179 3290
                                     int valid,
3180 3291
                                     int new_size,
......
3191 3302
    return CopyUpToAddAttributes(enumeration_index, NONE);
3192 3303
  }
3193 3304

  
3305
  static Handle<DescriptorArray> CopyUpToAddAttributes(
3306
      Handle<DescriptorArray> desc,
3307
      int enumeration_index,
3308
      PropertyAttributes attributes);
3194 3309
  MUST_USE_RESULT MaybeObject* CopyUpToAddAttributes(
3195 3310
      int enumeration_index,
3196 3311
      PropertyAttributes attributes);
......
3543 3658
  MUST_USE_RESULT MaybeObject* Shrink(Key key);
3544 3659

  
3545 3660
  // Ensure enough space for n additional elements.
3546
  MUST_USE_RESULT MaybeObject* EnsureCapacity(int n, Key key);
3661
  MUST_USE_RESULT MaybeObject* EnsureCapacity(
3662
      int n,
3663
      Key key,
3664
      PretenureFlag pretenure = NOT_TENURED);
3547 3665
};
3548 3666

  
3549 3667

  
......
3982 4100
};
3983 4101

  
3984 4102

  
4103
template <int entrysize>
4104
class WeakHashTableShape : public BaseShape<Object*> {
4105
 public:
4106
  static inline bool IsMatch(Object* key, Object* other);
4107
  static inline uint32_t Hash(Object* key);
4108
  static inline uint32_t HashForObject(Object* key, Object* object);
4109
  MUST_USE_RESULT static inline MaybeObject* AsObject(Heap* heap,
4110
                                                      Object* key);
4111
  static const int kPrefixSize = 0;
4112
  static const int kEntrySize = entrysize;
4113
};
4114

  
4115

  
4116
// WeakHashTable maps keys that are arbitrary objects to object values.
4117
// It is used for the global weak hash table that maps objects
4118
// embedded in optimized code to dependent code lists.
4119
class WeakHashTable: public HashTable<WeakHashTableShape<2>, Object*> {
4120
 public:
4121
  static inline WeakHashTable* cast(Object* obj) {
4122
    ASSERT(obj->IsHashTable());
4123
    return reinterpret_cast<WeakHashTable*>(obj);
4124
  }
4125

  
4126
  // Looks up the value associated with the given key. The hole value is
4127
  // returned in case the key is not present.
4128
  Object* Lookup(Object* key);
4129

  
4130
  // Adds (or overwrites) the value associated with the given key. Mapping a
4131
  // key to the hole value causes removal of the whole entry.
4132
  MUST_USE_RESULT MaybeObject* Put(Object* key, Object* value);
4133

  
4134
  // This function is called when heap verification is turned on.
4135
  void Zap(Object* value) {
4136
    int capacity = Capacity();
4137
    for (int i = 0; i < capacity; i++) {
4138
      set(EntryToIndex(i), value);
4139
      set(EntryToValueIndex(i), value);
4140
    }
4141
  }
4142

  
4143
 private:
4144
  friend class MarkCompactCollector;
4145

  
4146
  void AddEntry(int entry, Object* key, Object* value);
4147

  
4148
  // Returns the index to the value of an entry.
4149
  static inline int EntryToValueIndex(int entry) {
4150
    return EntryToIndex(entry) + 1;
4151
  }
4152
};
4153

  
4154

  
3985 4155
// JSFunctionResultCache caches results of some JSFunction invocation.
3986 4156
// It is a fixed array with fixed structure:
3987 4157
//   [0]: factory function
......
4120 4290

  
4121 4291

  
4122 4292
  // Copies all the context locals into an object used to materialize a scope.
4123
  bool CopyContextLocalsToScopeObject(Isolate* isolate,
4124
                                      Handle<Context> context,
4125
                                      Handle<JSObject> scope_object);
4293
  static bool CopyContextLocalsToScopeObject(Handle<ScopeInfo> scope_info,
4294
                                             Handle<Context> context,
4295
                                             Handle<JSObject> scope_object);
4126 4296

  
4127 4297

  
4128 4298
  static Handle<ScopeInfo> Create(Scope* scope, Zone* zone);
......
4233 4403
 public:
4234 4404
  static const int kEntries = 64;
4235 4405

  
4236
  MUST_USE_RESULT MaybeObject* Get(JSObject* object,
4237
                                   PropertyNormalizationMode mode);
4406
  static Handle<Map> Get(Handle<NormalizedMapCache> cache,
4407
                         Handle<JSObject> object,
4408
                         PropertyNormalizationMode mode);
4238 4409

  
4239 4410
  void Clear();
4240 4411

  
......
4772 4943
  V(FUNCTION)               \
4773 4944
  V(OPTIMIZED_FUNCTION)     \
4774 4945
  V(STUB)                   \
4946
  V(HANDLER)                \
4775 4947
  V(BUILTIN)                \
4776 4948
  V(REGEXP)
4777 4949

  
......
4811 4983
    CONSTANT,
4812 4984
    CALLBACKS,
4813 4985
    INTERCEPTOR,
4814
    MAP_TRANSITION,
4986
    TRANSITION,
4815 4987
    NONEXISTENT
4816 4988
  };
4817 4989

  
4818
  enum StubHolder {
4819
    OWN_STUB,
4820
    PROTOTYPE_STUB
4821
  };
4822

  
4823 4990
  typedef int ExtraICState;
4824 4991

  
4825 4992
  static const ExtraICState kNoExtraICState = 0;
4826 4993

  
4994
  static const int kPrologueOffsetNotSet = -1;
4995

  
4827 4996
#ifdef ENABLE_DISASSEMBLER
4828 4997
  // Printing
4829 4998
  static const char* ICState2String(InlineCacheState state);
......
4886 5055

  
4887 5056
  // [flags]: Access to specific code flags.
4888 5057
  inline Kind kind();
5058
  inline Kind handler_kind() {
5059
    return static_cast<Kind>(arguments_count());
5060
  }
4889 5061
  inline InlineCacheState ic_state();  // Only valid for IC stubs.
4890 5062
  inline ExtraICState extra_ic_state();  // Only valid for IC stubs.
4891 5063

  
......
4895 5067
    // TODO(danno): This is a bit of a hack right now since there are still
4896 5068
    // clients of this API that pass "extra" values in for argc. These clients
4897 5069
    // should be retrofitted to used ExtendedExtraICState.
4898
    return kind == COMPARE_NIL_IC || kind == TO_BOOLEAN_IC;
5070
    return kind == COMPARE_NIL_IC || kind == TO_BOOLEAN_IC ||
5071
           kind == BINARY_OP_IC;
4899 5072
  }
4900 5073

  
4901 5074
  inline StubType type();  // Only valid for monomorphic IC stubs.
......
4904 5077
  // Testers for IC stub kinds.
4905 5078
  inline bool is_inline_cache_stub();
4906 5079
  inline bool is_debug_stub();
5080
  inline bool is_handler() { return kind() == HANDLER; }
4907 5081
  inline bool is_load_stub() { return kind() == LOAD_IC; }
4908 5082
  inline bool is_keyed_load_stub() { return kind() == KEYED_LOAD_IC; }
4909 5083
  inline bool is_store_stub() { return kind() == STORE_IC; }
......
4914 5088
  inline bool is_compare_ic_stub() { return kind() == COMPARE_IC; }
4915 5089
  inline bool is_compare_nil_ic_stub() { return kind() == COMPARE_NIL_IC; }
4916 5090
  inline bool is_to_boolean_ic_stub() { return kind() == TO_BOOLEAN_IC; }
5091
  inline bool is_keyed_stub();
4917 5092

  
4918 5093
  // [major_key]: For kind STUB or BINARY_OP_IC, the major key.
4919 5094
  inline int major_key();
......
4997 5172
  inline bool marked_for_deoptimization();
4998 5173
  inline void set_marked_for_deoptimization(bool flag);
4999 5174

  
5000
  bool allowed_in_shared_map_code_cache();
5001

  
5002 5175
  // Get the safepoint entry for the given pc.
5003 5176
  SafepointEntry GetSafepointEntry(Address pc);
5004 5177

  
......
5011 5184
  void FindAllMaps(MapHandleList* maps);
5012 5185
  void ReplaceFirstMap(Map* replace);
5013 5186

  
5014
  // Find the first code in an IC stub.
5015
  Code* FindFirstCode();
5016
  void FindAllCode(CodeHandleList* code_list, int length);
5187
  // Find the first handler in an IC stub.
5188
  Code* FindFirstHandler();
5189

  
5190
  // Find |length| handlers and put them into |code_list|. Returns false if not
5191
  // enough handlers can be found.
5192
  bool FindHandlers(CodeHandleList* code_list, int length = -1);
5017 5193

  
5018 5194
  // Find the first name in an IC stub.
5019 5195
  Name* FindFirstName();
......
5024 5200
  class ExtraICStateKeyedAccessStoreMode:
5025 5201
      public BitField<KeyedAccessStoreMode, 1, 4> {};  // NOLINT
5026 5202

  
5027
  class ExtraICStateStubHolder: public BitField<StubHolder, 0, 1> {};
5028

  
5029 5203
  static inline StrictModeFlag GetStrictMode(ExtraICState extra_ic_state) {
5030 5204
    return ExtraICStateStrictMode::decode(extra_ic_state);
5031 5205
  }
......
5042 5216
        ExtraICStateStrictMode::encode(strict_mode);
5043 5217
  }
5044 5218

  
5045
  static inline ExtraICState ComputeExtraICState(StubHolder stub_holder) {
5046
    return ExtraICStateStubHolder::encode(stub_holder);
5047
  }
5048

  
5049 5219
  // Flags operations.
5050 5220
  static inline Flags ComputeFlags(
5051 5221
      Kind kind,
......
5142 5312

  
5143 5313
#define DECLARE_CODE_AGE_ENUM(X) k##X##CodeAge,
5144 5314
  enum Age {
5145
    kNoAge = 0,
5315
    kNotExecutedCodeAge = -2,
5316
    kExecutedOnceCodeAge = -1,
5317
    kNoAgeCodeAge = 0,
5146 5318
    CODE_AGE_LIST(DECLARE_CODE_AGE_ENUM)
5147 5319
    kAfterLastCodeAge,
5148 5320
    kLastCodeAge = kAfterLastCodeAge - 1,
5149
    kCodeAgeCount = kAfterLastCodeAge - 1
5321
    kCodeAgeCount = kAfterLastCodeAge - 1,
5322
    kIsOldCodeAge = kSexagenarianCodeAge,
5323
    kPreAgedCodeAge = kIsOldCodeAge - 1
5150 5324
  };
5151 5325
#undef DECLARE_CODE_AGE_ENUM
5152 5326

  
......
5154 5328
  // being entered through the prologue.  Used to determine when it is
5155 5329
  // relatively safe to flush this code object and replace it with the lazy
5156 5330
  // compilation stub.
5157
  static void MakeCodeAgeSequenceYoung(byte* sequence);
5331
  static void MakeCodeAgeSequenceYoung(byte* sequence, Isolate* isolate);
5332
  static void MarkCodeAsExecuted(byte* sequence, Isolate* isolate);
5158 5333
  void MakeOlder(MarkingParity);
5159 5334
  static bool IsYoungSequence(byte* sequence);
5160 5335
  bool IsOld();
5161
  int GetAge();
5336
  Age GetAge();
5337
  static inline Code* GetPreAgedCodeAgeStub(Isolate* isolate) {
5338
    return GetCodeAgeStub(isolate, kNotExecutedCodeAge, NO_MARKING_PARITY);
5339
  }
5162 5340

  
5163 5341
  void PrintDeoptLocation(int bailout_id);
5164 5342
  bool CanDeoptAt(Address pc);
5165 5343

  
5166 5344
#ifdef VERIFY_HEAP
5167
  void VerifyEmbeddedMapsDependency();
5345
  void VerifyEmbeddedObjectsDependency();
5168 5346
#endif
5169 5347

  
5348
  static bool IsWeakEmbeddedObject(Kind kind, Object* object);
5349

  
5170 5350
  // Max loop nesting marker used to postpose OSR. We don't take loop
5171 5351
  // nesting that is deeper than 5 levels into account.
5172 5352
  static const int kMaxLoopNestingMarker = 6;
......
5300 5480
                                  MarkingParity* parity);
5301 5481
  static void GetCodeAgeAndParity(byte* sequence, Age* age,
5302 5482
                                  MarkingParity* parity);
5303
  static Code* GetCodeAgeStub(Age age, MarkingParity parity);
5483
  static Code* GetCodeAgeStub(Isolate* isolate, Age age, MarkingParity parity);
5304 5484

  
5305 5485
  // Code aging -- platform-specific
5306
  static void PatchPlatformCodeAge(byte* sequence, Age age,
5486
  static void PatchPlatformCodeAge(Isolate* isolate,
5487
                                   byte* sequence, Age age,
5307 5488
                                   MarkingParity parity);
5308 5489

  
5309 5490
  DISALLOW_IMPLICIT_CONSTRUCTORS(Code);
......
5591 5772
      Map* transitioned_map);
5592 5773
  inline void SetTransition(int transition_index, Map* target);
5593 5774
  inline Map* GetTransition(int transition_index);
5775

  
5776
  static Handle<TransitionArray> AddTransition(Handle<Map> map,
5777
                                               Handle<Name> key,
5778
                                               Handle<Map> target,
5779
                                               SimpleTransitionFlag flag);
5780

  
5594 5781
  MUST_USE_RESULT inline MaybeObject* AddTransition(Name* key,
5595 5782
                                                    Map* target,
5596 5783
                                                    SimpleTransitionFlag flag);
......
5611 5798
                              int target_number_of_fields,
5612 5799
                              int target_inobject,
5613 5800
                              int target_unused);
5801
  static Handle<Map> GeneralizeAllFieldRepresentations(
5802
      Handle<Map> map,
5803
      Representation new_representation);
5614 5804
  static Handle<Map> GeneralizeRepresentation(
5615 5805
      Handle<Map> map,
5616 5806
      int modify_index,
5617 5807
      Representation new_representation,
5618 5808
      StoreMode store_mode);
5619
  MUST_USE_RESULT MaybeObject* GeneralizeRepresentation(
5620
      int modify_index,
5621
      Representation representation,
5622
      StoreMode store_mode);
5623
  MUST_USE_RESULT MaybeObject* CopyGeneralizeAllRepresentations(
5809
  static Handle<Map> CopyGeneralizeAllRepresentations(
5810
      Handle<Map> map,
5624 5811
      int modify_index,
5625 5812
      StoreMode store_mode,
5626 5813
      PropertyAttributes attributes,
......
5791 5978
  // descriptor array of the map. Returns NULL if no updated map is found.
5792 5979
  Map* CurrentMapForDeprecated();
5793 5980

  
5981
  static Handle<Map> RawCopy(Handle<Map> map, int instance_size);
5794 5982
  MUST_USE_RESULT MaybeObject* RawCopy(int instance_size);
5795 5983
  MUST_USE_RESULT MaybeObject* CopyWithPreallocatedFieldDescriptors();
5796 5984
  static Handle<Map> CopyDropDescriptors(Handle<Map> map);
5797 5985
  MUST_USE_RESULT MaybeObject* CopyDropDescriptors();
5986
  static Handle<Map> CopyReplaceDescriptors(Handle<Map> map,
5987
                                            Handle<DescriptorArray> descriptors,
5988
                                            TransitionFlag flag,
5989
                                            Handle<Name> name);
5798 5990
  MUST_USE_RESULT MaybeObject* CopyReplaceDescriptors(
5799 5991
      DescriptorArray* descriptors,
5800 5992
      TransitionFlag flag,
5801 5993
      Name* name = NULL,
5802 5994
      SimpleTransitionFlag simple_flag = FULL_TRANSITION);
5803
  MUST_USE_RESULT MaybeObject* CopyInstallDescriptors(
5995
  static Handle<Map> CopyInstallDescriptors(
5996
      Handle<Map> map,
5804 5997
      int new_descriptor,
5805
      DescriptorArray* descriptors);
5998
      Handle<DescriptorArray> descriptors);
5806 5999
  MUST_USE_RESULT MaybeObject* ShareDescriptor(DescriptorArray* descriptors,
5807 6000
                                               Descriptor* descriptor);
5808 6001
  MUST_USE_RESULT MaybeObject* CopyAddDescriptor(Descriptor* descriptor,
......
5818 6011

  
5819 6012
  MUST_USE_RESULT MaybeObject* CopyAsElementsKind(ElementsKind kind,
5820 6013
                                                  TransitionFlag flag);
5821
  MUST_USE_RESULT MaybeObject* CopyForObserved();
6014

  
6015
  static Handle<Map> CopyForObserved(Handle<Map> map);
5822 6016

  
5823 6017
  static Handle<Map> CopyNormalized(Handle<Map> map,
5824 6018
                                    PropertyNormalizationMode mode,
5825 6019
                                    NormalizedMapSharingMode sharing);
5826
  MUST_USE_RESULT MaybeObject* CopyNormalized(PropertyNormalizationMode mode,
5827
                                              NormalizedMapSharingMode sharing);
5828 6020

  
5829 6021
  inline void AppendDescriptor(Descriptor* desc,
5830 6022
                               const DescriptorArray::WhitenessWitness&);
......
6221 6413
//
6222 6414
// Installation of ids for the selected builtin functions is handled
6223 6415
// by the bootstrapper.
6224
//
6225
// NOTE: Order is important: math functions should be at the end of
6226
// the list and MathFloor should be the first math function.
6227 6416
#define FUNCTIONS_WITH_ID_LIST(V)                   \
6228 6417
  V(Array.prototype, push, ArrayPush)               \
6229 6418
  V(Array.prototype, pop, ArrayPop)                 \
......
6258 6447
#undef DECLARE_FUNCTION_ID
6259 6448
  // Fake id for a special case of Math.pow. Note, it continues the
6260 6449
  // list of math functions.
6261
  kMathPowHalf,
6262
  kFirstMathFunctionId = kMathFloor
6450
  kMathPowHalf
6263 6451
};
6264 6452

  
6265 6453

  
......
7841 8029
  static const uint32_t kMaximumArrayBytesToPretransition = 8 * 1024;
7842 8030

  
7843 8031
  DECL_ACCESSORS(transition_info, Object)
8032
  // nested_site threads a list of sites that represent nested literals
8033
  // walked in a particular order. So [[1, 2], 1, 2] will have one
8034
  // nested_site, but [[1, 2], 3, [4]] will have a list of two.
8035
  DECL_ACCESSORS(nested_site, Object)
8036
  DECL_ACCESSORS(dependent_code, DependentCode)
7844 8037
  DECL_ACCESSORS(weak_next, Object)
7845 8038

  
7846
  void Initialize() {
7847
    SetElementsKind(GetInitialFastElementsKind());
8039
  inline void Initialize();
8040

  
8041
  bool HasNestedSites() {
8042
    return nested_site()->IsAllocationSite();
7848 8043
  }
7849 8044

  
8045
  // This method is expensive, it should only be called for reporting.
8046
  bool IsNestedSite();
8047

  
7850 8048
  ElementsKind GetElementsKind() {
7851
    ASSERT(!IsLiteralSite());
8049
    ASSERT(!SitePointsToLiteral());
7852 8050
    return static_cast<ElementsKind>(Smi::cast(transition_info())->value());
7853 8051
  }
7854 8052

  
......
7856 8054
    set_transition_info(Smi::FromInt(static_cast<int>(kind)));
7857 8055
  }
7858 8056

  
7859
  bool IsLiteralSite() {
8057
  bool SitePointsToLiteral() {
7860 8058
    // If transition_info is a smi, then it represents an ElementsKind
7861 8059
    // for a constructed array. Otherwise, it must be a boilerplate
7862
    // for an array literal
7863
    return transition_info()->IsJSArray();
8060
    // for an object or array literal.
8061
    return transition_info()->IsJSArray() || transition_info()->IsJSObject();
7864 8062
  }
7865 8063

  
7866 8064
  DECLARE_PRINTER(AllocationSite)
......
7873 8071
  static inline bool CanTrack(InstanceType type);
7874 8072

  
7875 8073
  static const int kTransitionInfoOffset = HeapObject::kHeaderSize;
7876
  static const int kWeakNextOffset = kTransitionInfoOffset + kPointerSize;
8074
  static const int kNestedSiteOffset = kTransitionInfoOffset + kPointerSize;
8075
  static const int kDependentCodeOffset = kNestedSiteOffset + kPointerSize;
8076
  static const int kWeakNextOffset = kDependentCodeOffset + kPointerSize;
7877 8077
  static const int kSize = kWeakNextOffset + kPointerSize;
7878 8078

  
7879 8079
  typedef FixedBodyDescriptor<HeapObject::kHeaderSize,
7880
                              kTransitionInfoOffset + kPointerSize,
8080
                              kDependentCodeOffset + kPointerSize,
7881 8081
                              kSize> BodyDescriptor;
7882 8082

  
7883 8083
 private:
......
7902 8102
  DECLARE_VERIFIER(AllocationMemento)
7903 8103

  
7904 8104
  // Returns NULL if no AllocationMemento is available for object.
7905
  static AllocationMemento* FindForJSObject(JSObject* object);
8105
  static AllocationMemento* FindForJSObject(JSObject* object,
8106
                                            bool in_GC = false);
7906 8107
  static inline AllocationMemento* cast(Object* obj);
7907 8108

  
7908 8109
 private:
......
9018 9219
  // of the cell's current type and the value's type. If the change causes
9019 9220
  // a change of the type of the cell's contents, code dependent on the cell
9020 9221
  // will be deoptimized.
9021
  MUST_USE_RESULT MaybeObject* SetValueInferType(
9022
      Object* value,
9023
      WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
9222
  static void SetValueInferType(Handle<PropertyCell> cell,
9223
                                Handle<Object> value);
9224

  
9225
  // Computes the new type of the cell's contents for the given value, but
9226
  // without actually modifying the 'type' field.
9227
  static Handle<Type> UpdatedType(Handle<PropertyCell> cell,
9228
                                  Handle<Object> value);
9229

  
9230
  void AddDependentCompilationInfo(CompilationInfo* info);
9231

  
9232
  void AddDependentCode(Handle<Code> code);
9024 9233

  
9025 9234
  // Casting.
9026 9235
  static inline PropertyCell* cast(Object* obj);
......
9045 9254
                              kSize,
9046 9255
                              kSize> BodyDescriptor;
9047 9256

  
9048
  void AddDependentCompilationInfo(CompilationInfo* info);
9049

  
9050
  void AddDependentCode(Handle<Code> code);
9051

  
9052
  static Type* UpdateType(Handle<PropertyCell> cell,
9053
                          Handle<Object> value);
9054

  
9055 9257
 private:
9056 9258
  DECL_ACCESSORS(type_raw, Object)
9057 9259
  DISALLOW_IMPLICIT_CONSTRUCTORS(PropertyCell);
......
9070 9272
  // Casting.
9071 9273
  static inline JSProxy* cast(Object* obj);
9072 9274

  
9073
  bool HasPropertyWithHandler(Name* name);
9074
  bool HasElementWithHandler(uint32_t index);
9075

  
9076 9275
  MUST_USE_RESULT MaybeObject* GetPropertyWithHandler(
9077 9276
      Object* receiver,
9078 9277
      Name* name);
......
9080 9279
      Object* receiver,
9081 9280
      uint32_t index);
9082 9281

  
9083
  MUST_USE_RESULT MaybeObject* SetPropertyWithHandler(
9084
      JSReceiver* receiver,
9085
      Name* name,
9086
      Object* value,
9087
      PropertyAttributes attributes,
9088
      StrictModeFlag strict_mode);
9089

  
9090 9282
  // If the handler defines an accessor property with a setter, invoke it.
9091 9283
  // If it defines an accessor property without a setter, or a data property
9092 9284
  // that is read-only, throw. In all these cases set '*done' to true,
9093 9285
  // otherwise set it to false.
9094
  MUST_USE_RESULT MaybeObject* SetPropertyViaPrototypesWithHandler(
9095
      JSReceiver* receiver,
9096
      Name* name,
9097
      Object* value,
9286
  static Handle<Object> SetPropertyViaPrototypesWithHandler(
9287
      Handle<JSProxy> proxy,
9288
      Handle<JSReceiver> receiver,
9289
      Handle<Name> name,
9290
      Handle<Object> value,
9098 9291
      PropertyAttributes attributes,
9099 9292
      StrictModeFlag strict_mode,
9100 9293
      bool* done);
......
9142 9335
 private:
9143 9336
  friend class JSReceiver;
9144 9337

  
9338
  static Handle<Object> SetPropertyWithHandler(Handle<JSProxy> proxy,
9339
                                               Handle<JSReceiver> receiver,
9340
                                               Handle<Name> name,
9341
                                               Handle<Object> value,
9342
                                               PropertyAttributes attributes,
9343
                                               StrictModeFlag strict_mode);
9145 9344
  static Handle<Object> SetElementWithHandler(Handle<JSProxy> proxy,
9146 9345
                                              Handle<JSReceiver> receiver,
9147 9346
                                              uint32_t index,
9148 9347
                                              Handle<Object> value,
9149 9348
                                              StrictModeFlag strict_mode);
9150 9349

  
9350
  static bool HasPropertyWithHandler(Handle<JSProxy> proxy, Handle<Name> name);
9351
  static bool HasElementWithHandler(Handle<JSProxy> proxy, uint32_t index);
9352

  
9151 9353
  static Handle<Object> DeletePropertyWithHandler(Handle<JSProxy> proxy,
9152 9354
                                                  Handle<Name> name,
9153 9355
                                                  DeleteMode mode);
......
10157 10359
  // [start, end). Any or all of the values may be modified on return.
10158 10360
  virtual void VisitPointers(Object** start, Object** end) = 0;
10159 10361

  
10362
  // Handy shorthand for visiting a single pointer.
10363
  virtual void VisitPointer(Object** p) { VisitPointers(p, p + 1); }
10364

  
10160 10365
  // To allow lazy clearing of inline caches the visitor has
10161 10366
  // a rich interface for iterating over Code objects..
10162 10367

  
......
10185 10390
  // about the code's age.
10186 10391
  virtual void VisitCodeAgeSequence(RelocInfo* rinfo);
10187 10392

  
10188
  // Handy shorthand for visiting a single pointer.
10189
  virtual void VisitPointer(Object** p) { VisitPointers(p, p + 1); }
10190

  
10191 10393
  // Visit pointer embedded into a code object.
10192 10394
  virtual void VisitEmbeddedPointer(RelocInfo* rinfo);
10193 10395

  
10194
  // Visits a contiguous arrays of external references (references to the C++
10195
  // heap) in the half-open range [start, end). Any or all of the values
10196
  // may be modified on return.
10197
  virtual void VisitExternalReferences(Address* start, Address* end) {}
10198

  
10396
  // Visits an external reference embedded into a code object.
10199 10397
  virtual void VisitExternalReference(RelocInfo* rinfo);
10200 10398

  
10201
  inline void VisitExternalReference(Address* p) {
10202
    VisitExternalReferences(p, p + 1);
10203
  }
10399
  // Visits an external reference. The value may be modified on return.
10400
  virtual void VisitExternalReference(Address* p) {}
10204 10401

  
10205 10402
  // Visits a handle that has an embedder-assigned class ID.
10206 10403
  virtual void VisitEmbedderReference(Object** p, uint16_t class_id) {}

Also available in: Unified diff