Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(603)

Side by Side Diff: src/objects.h

Issue 22861025: Get rid of ConvertFieldToDescriptor and simplify related code. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comment and fixed cornercase Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/objects.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 2481 matching lines...) Expand 10 before | Expand all | Expand 10 after
2492 2492
2493 // Add a constant function property to a fast-case object. 2493 // Add a constant function property to a fast-case object.
2494 // This leaves a CONSTANT_TRANSITION in the old map, and 2494 // This leaves a CONSTANT_TRANSITION in the old map, and
2495 // if it is called on a second object with this map, a 2495 // if it is called on a second object with this map, a
2496 // normal property is added instead, with a map transition. 2496 // normal property is added instead, with a map transition.
2497 // This avoids the creation of many maps with the same constant 2497 // This avoids the creation of many maps with the same constant
2498 // function, all orphaned. 2498 // function, all orphaned.
2499 MUST_USE_RESULT MaybeObject* AddConstantProperty( 2499 MUST_USE_RESULT MaybeObject* AddConstantProperty(
2500 Name* name, 2500 Name* name,
2501 Object* constant, 2501 Object* constant,
2502 PropertyAttributes attributes); 2502 PropertyAttributes attributes,
2503 TransitionFlag flag);
2503 2504
2504 MUST_USE_RESULT MaybeObject* ReplaceSlowProperty( 2505 MUST_USE_RESULT MaybeObject* ReplaceSlowProperty(
2505 Name* name, 2506 Name* name,
2506 Object* value, 2507 Object* value,
2507 PropertyAttributes attributes); 2508 PropertyAttributes attributes);
2508 2509
2509 // Returns a new map with all transitions dropped from the object's current 2510 // Returns a new map with all transitions dropped from the object's current
2510 // map and the ElementsKind set. 2511 // map and the ElementsKind set.
2511 static Handle<Map> GetElementsTransitionMap(Handle<JSObject> object, 2512 static Handle<Map> GetElementsTransitionMap(Handle<JSObject> object,
2512 ElementsKind to_kind); 2513 ElementsKind to_kind);
2513 inline MUST_USE_RESULT MaybeObject* GetElementsTransitionMap( 2514 inline MUST_USE_RESULT MaybeObject* GetElementsTransitionMap(
2514 Isolate* isolate, 2515 Isolate* isolate,
2515 ElementsKind elements_kind); 2516 ElementsKind elements_kind);
2516 MUST_USE_RESULT MaybeObject* GetElementsTransitionMapSlow( 2517 MUST_USE_RESULT MaybeObject* GetElementsTransitionMapSlow(
2517 ElementsKind elements_kind); 2518 ElementsKind elements_kind);
2518 2519
2519 static Handle<Object> TransitionElementsKind(Handle<JSObject> object, 2520 static Handle<Object> TransitionElementsKind(Handle<JSObject> object,
2520 ElementsKind to_kind); 2521 ElementsKind to_kind);
2521 2522
2522 MUST_USE_RESULT MaybeObject* TransitionElementsKind(ElementsKind to_kind); 2523 MUST_USE_RESULT MaybeObject* TransitionElementsKind(ElementsKind to_kind);
2523 MUST_USE_RESULT MaybeObject* UpdateAllocationSite(ElementsKind to_kind); 2524 MUST_USE_RESULT MaybeObject* UpdateAllocationSite(ElementsKind to_kind);
2524 2525
2525 // Converts a descriptor of any other type to a real field, backed by the
2526 // properties array.
2527 MUST_USE_RESULT MaybeObject* ConvertDescriptorToField(
2528 Name* name,
2529 Object* new_value,
2530 PropertyAttributes attributes,
2531 TransitionFlag flag = OMIT_TRANSITION);
2532
2533 MUST_USE_RESULT MaybeObject* MigrateToMap(Map* new_map); 2526 MUST_USE_RESULT MaybeObject* MigrateToMap(Map* new_map);
2534 MUST_USE_RESULT MaybeObject* GeneralizeFieldRepresentation( 2527 MUST_USE_RESULT MaybeObject* GeneralizeFieldRepresentation(
2535 int modify_index, 2528 int modify_index,
2536 Representation new_representation, 2529 Representation new_representation,
2537 StoreMode store_mode); 2530 StoreMode store_mode);
2538 2531
2539 // Add a property to a fast-case object. 2532 // Add a property to a fast-case object.
2540 MUST_USE_RESULT MaybeObject* AddFastProperty( 2533 MUST_USE_RESULT MaybeObject* AddFastProperty(
2541 Name* name, 2534 Name* name,
2542 Object* value, 2535 Object* value,
2543 PropertyAttributes attributes, 2536 PropertyAttributes attributes,
2544 StoreFromKeyed store_mode = MAY_BE_STORE_FROM_KEYED, 2537 StoreFromKeyed store_mode = MAY_BE_STORE_FROM_KEYED,
2545 ValueType value_type = OPTIMAL_REPRESENTATION); 2538 ValueType value_type = OPTIMAL_REPRESENTATION,
2539 TransitionFlag flag = INSERT_TRANSITION);
2546 2540
2547 // Add a property to a slow-case object. 2541 // Add a property to a slow-case object.
2548 MUST_USE_RESULT MaybeObject* AddSlowProperty(Name* name, 2542 MUST_USE_RESULT MaybeObject* AddSlowProperty(Name* name,
2549 Object* value, 2543 Object* value,
2550 PropertyAttributes attributes); 2544 PropertyAttributes attributes);
2551 2545
2552 // Add a property to an object. May cause GC. 2546 // Add a property to an object. May cause GC.
2553 MUST_USE_RESULT MaybeObject* AddProperty( 2547 MUST_USE_RESULT MaybeObject* AddProperty(
2554 Name* name, 2548 Name* name,
2555 Object* value, 2549 Object* value,
2556 PropertyAttributes attributes, 2550 PropertyAttributes attributes,
2557 StrictModeFlag strict_mode, 2551 StrictModeFlag strict_mode,
2558 StoreFromKeyed store_mode = MAY_BE_STORE_FROM_KEYED, 2552 StoreFromKeyed store_mode = MAY_BE_STORE_FROM_KEYED,
2559 ExtensibilityCheck extensibility_check = PERFORM_EXTENSIBILITY_CHECK, 2553 ExtensibilityCheck extensibility_check = PERFORM_EXTENSIBILITY_CHECK,
2560 ValueType value_type = OPTIMAL_REPRESENTATION, 2554 ValueType value_type = OPTIMAL_REPRESENTATION,
2561 StoreMode mode = ALLOW_AS_CONSTANT); 2555 StoreMode mode = ALLOW_AS_CONSTANT,
2556 TransitionFlag flag = INSERT_TRANSITION);
2562 2557
2563 // Convert the object to use the canonical dictionary 2558 // Convert the object to use the canonical dictionary
2564 // representation. If the object is expected to have additional properties 2559 // representation. If the object is expected to have additional properties
2565 // added this number can be indicated to have the backing store allocated to 2560 // added this number can be indicated to have the backing store allocated to
2566 // an initial capacity for holding these properties. 2561 // an initial capacity for holding these properties.
2567 static void NormalizeProperties(Handle<JSObject> object, 2562 static void NormalizeProperties(Handle<JSObject> object,
2568 PropertyNormalizationMode mode, 2563 PropertyNormalizationMode mode,
2569 int expected_additional_properties); 2564 int expected_additional_properties);
2570 2565
2571 MUST_USE_RESULT MaybeObject* NormalizeProperties( 2566 MUST_USE_RESULT MaybeObject* NormalizeProperties(
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
2687 int number_of_slow_unused_elements_; 2682 int number_of_slow_unused_elements_;
2688 }; 2683 };
2689 2684
2690 void IncrementSpillStatistics(SpillInformation* info); 2685 void IncrementSpillStatistics(SpillInformation* info);
2691 #endif 2686 #endif
2692 Object* SlowReverseLookup(Object* value); 2687 Object* SlowReverseLookup(Object* value);
2693 2688
2694 // Maximal number of fast properties for the JSObject. Used to 2689 // Maximal number of fast properties for the JSObject. Used to
2695 // restrict the number of map transitions to avoid an explosion in 2690 // restrict the number of map transitions to avoid an explosion in
2696 // the number of maps for objects used as dictionaries. 2691 // the number of maps for objects used as dictionaries.
2697 inline bool TooManyFastProperties(int properties, StoreFromKeyed store_mode); 2692 inline bool TooManyFastProperties(
2693 StoreFromKeyed store_mode = MAY_BE_STORE_FROM_KEYED);
2698 2694
2699 // Maximal number of elements (numbered 0 .. kMaxElementCount - 1). 2695 // Maximal number of elements (numbered 0 .. kMaxElementCount - 1).
2700 // Also maximal value of JSArray's length property. 2696 // Also maximal value of JSArray's length property.
2701 static const uint32_t kMaxElementCount = 0xffffffffu; 2697 static const uint32_t kMaxElementCount = 0xffffffffu;
2702 2698
2703 // Constants for heuristics controlling conversion of fast elements 2699 // Constants for heuristics controlling conversion of fast elements
2704 // to slow elements. 2700 // to slow elements.
2705 2701
2706 // Maximal gap that can be introduced by adding an element beyond 2702 // Maximal gap that can be introduced by adding an element beyond
2707 // the current elements length. 2703 // the current elements length.
(...skipping 7478 matching lines...) Expand 10 before | Expand all | Expand 10 after
10186 } else { 10182 } else {
10187 value &= ~(1 << bit_position); 10183 value &= ~(1 << bit_position);
10188 } 10184 }
10189 return value; 10185 return value;
10190 } 10186 }
10191 }; 10187 };
10192 10188
10193 } } // namespace v8::internal 10189 } } // namespace v8::internal
10194 10190
10195 #endif // V8_OBJECTS_H_ 10191 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « no previous file | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698