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

Side by Side Diff: src/objects.h

Issue 23883007: Handlify JSObject::AddProperty method. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments by Toon Verwaest. Created 7 years, 3 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 2127 matching lines...) Expand 10 before | Expand all | Expand 10 after
2138 Name* name, 2138 Name* name,
2139 Object* value, 2139 Object* value,
2140 bool check_prototype, 2140 bool check_prototype,
2141 StrictModeFlag strict_mode); 2141 StrictModeFlag strict_mode);
2142 MUST_USE_RESULT MaybeObject* SetPropertyWithCallback( 2142 MUST_USE_RESULT MaybeObject* SetPropertyWithCallback(
2143 Object* structure, 2143 Object* structure,
2144 Name* name, 2144 Name* name,
2145 Object* value, 2145 Object* value,
2146 JSObject* holder, 2146 JSObject* holder,
2147 StrictModeFlag strict_mode); 2147 StrictModeFlag strict_mode);
2148 MUST_USE_RESULT MaybeObject* SetPropertyWithInterceptor( 2148 static Handle<Object> SetPropertyWithInterceptor(
2149 Name* name, 2149 Handle<JSObject> object,
2150 Object* value, 2150 Handle<Name> name,
2151 Handle<Object> value,
2151 PropertyAttributes attributes, 2152 PropertyAttributes attributes,
2152 StrictModeFlag strict_mode); 2153 StrictModeFlag strict_mode);
2153 MUST_USE_RESULT MaybeObject* SetPropertyPostInterceptor(
2154 Name* name,
2155 Object* value,
2156 PropertyAttributes attributes,
2157 StrictModeFlag strict_mode,
2158 StoreMode mode = ALLOW_AS_CONSTANT);
2159 2154
2160 static Handle<Object> SetLocalPropertyIgnoreAttributes( 2155 static Handle<Object> SetLocalPropertyIgnoreAttributes(
2161 Handle<JSObject> object, 2156 Handle<JSObject> object,
2162 Handle<Name> key, 2157 Handle<Name> key,
2163 Handle<Object> value, 2158 Handle<Object> value,
2164 PropertyAttributes attributes, 2159 PropertyAttributes attributes,
2165 ValueType value_type = OPTIMAL_REPRESENTATION, 2160 ValueType value_type = OPTIMAL_REPRESENTATION,
2166 StoreMode mode = ALLOW_AS_CONSTANT, 2161 StoreMode mode = ALLOW_AS_CONSTANT,
2167 ExtensibilityCheck extensibility_check = PERFORM_EXTENSIBILITY_CHECK); 2162 ExtensibilityCheck extensibility_check = PERFORM_EXTENSIBILITY_CHECK);
2168 2163
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
2476 int GetLocalElementKeys(FixedArray* storage, PropertyAttributes filter); 2471 int GetLocalElementKeys(FixedArray* storage, PropertyAttributes filter);
2477 // Count and fill in the enumerable elements into storage. 2472 // Count and fill in the enumerable elements into storage.
2478 // (storage->length() == NumberOfEnumElements()). 2473 // (storage->length() == NumberOfEnumElements()).
2479 // If storage is NULL, will count the elements without adding 2474 // If storage is NULL, will count the elements without adding
2480 // them to any storage. 2475 // them to any storage.
2481 // Returns the number of enumerable elements. 2476 // Returns the number of enumerable elements.
2482 int GetEnumElementKeys(FixedArray* storage); 2477 int GetEnumElementKeys(FixedArray* storage);
2483 2478
2484 // Add a property to a fast-case object using a map transition to 2479 // Add a property to a fast-case object using a map transition to
2485 // new_map. 2480 // new_map.
2481 // TODO(mstarzinger): Only public because of SetPropertyUsingTransition!
2486 MUST_USE_RESULT MaybeObject* AddFastPropertyUsingMap( 2482 MUST_USE_RESULT MaybeObject* AddFastPropertyUsingMap(
2487 Map* new_map, 2483 Map* new_map,
2488 Name* name, 2484 Name* name,
2489 Object* value, 2485 Object* value,
2490 int field_index, 2486 int field_index,
2491 Representation representation); 2487 Representation representation);
2492 2488
2493 // Add a constant function property to a fast-case object.
2494 // This leaves a CONSTANT_TRANSITION in the old map, and
2495 // if it is called on a second object with this map, a
2496 // normal property is added instead, with a map transition.
2497 // This avoids the creation of many maps with the same constant
2498 // function, all orphaned.
2499 MUST_USE_RESULT MaybeObject* AddConstantProperty(
2500 Name* name,
2501 Object* constant,
2502 PropertyAttributes attributes,
2503 TransitionFlag flag);
2504
2505 MUST_USE_RESULT MaybeObject* ReplaceSlowProperty( 2489 MUST_USE_RESULT MaybeObject* ReplaceSlowProperty(
2506 Name* name, 2490 Name* name,
2507 Object* value, 2491 Object* value,
2508 PropertyAttributes attributes); 2492 PropertyAttributes attributes);
2509 2493
2510 // Returns a new map with all transitions dropped from the object's current 2494 // Returns a new map with all transitions dropped from the object's current
2511 // map and the ElementsKind set. 2495 // map and the ElementsKind set.
2512 static Handle<Map> GetElementsTransitionMap(Handle<JSObject> object, 2496 static Handle<Map> GetElementsTransitionMap(Handle<JSObject> object,
2513 ElementsKind to_kind); 2497 ElementsKind to_kind);
2514 inline MUST_USE_RESULT MaybeObject* GetElementsTransitionMap( 2498 inline MUST_USE_RESULT MaybeObject* GetElementsTransitionMap(
2515 Isolate* isolate, 2499 Isolate* isolate,
2516 ElementsKind elements_kind); 2500 ElementsKind elements_kind);
2517 MUST_USE_RESULT MaybeObject* GetElementsTransitionMapSlow( 2501 MUST_USE_RESULT MaybeObject* GetElementsTransitionMapSlow(
2518 ElementsKind elements_kind); 2502 ElementsKind elements_kind);
2519 2503
2520 static Handle<Object> TransitionElementsKind(Handle<JSObject> object, 2504 static Handle<Object> TransitionElementsKind(Handle<JSObject> object,
2521 ElementsKind to_kind); 2505 ElementsKind to_kind);
2522 2506
2523 MUST_USE_RESULT MaybeObject* TransitionElementsKind(ElementsKind to_kind); 2507 MUST_USE_RESULT MaybeObject* TransitionElementsKind(ElementsKind to_kind);
2524 MUST_USE_RESULT MaybeObject* UpdateAllocationSite(ElementsKind to_kind); 2508 MUST_USE_RESULT MaybeObject* UpdateAllocationSite(ElementsKind to_kind);
2525 2509
2526 MUST_USE_RESULT MaybeObject* MigrateToMap(Map* new_map); 2510 MUST_USE_RESULT MaybeObject* MigrateToMap(Map* new_map);
2527 MUST_USE_RESULT MaybeObject* GeneralizeFieldRepresentation( 2511 MUST_USE_RESULT MaybeObject* GeneralizeFieldRepresentation(
2528 int modify_index, 2512 int modify_index,
2529 Representation new_representation, 2513 Representation new_representation,
2530 StoreMode store_mode); 2514 StoreMode store_mode);
2531 2515
2532 // Add a property to a fast-case object. 2516 // Add a property to an object.
2533 MUST_USE_RESULT MaybeObject* AddFastProperty( 2517 // TODO(mstarzinger): Only public because of SetPropertyUsingTransition!
2534 Name* name, 2518 static Handle<Object> AddProperty(
2535 Object* value, 2519 Handle<JSObject> object,
2536 PropertyAttributes attributes, 2520 Handle<Name> name,
2537 StoreFromKeyed store_mode = MAY_BE_STORE_FROM_KEYED, 2521 Handle<Object> value,
2538 ValueType value_type = OPTIMAL_REPRESENTATION,
2539 TransitionFlag flag = INSERT_TRANSITION);
2540
2541 // Add a property to a slow-case object.
2542 MUST_USE_RESULT MaybeObject* AddSlowProperty(Name* name,
2543 Object* value,
2544 PropertyAttributes attributes);
2545
2546 // Add a property to an object. May cause GC.
2547 MUST_USE_RESULT MaybeObject* AddProperty(
2548 Name* name,
2549 Object* value,
2550 PropertyAttributes attributes, 2522 PropertyAttributes attributes,
2551 StrictModeFlag strict_mode, 2523 StrictModeFlag strict_mode,
2552 StoreFromKeyed store_mode = MAY_BE_STORE_FROM_KEYED, 2524 StoreFromKeyed store_mode = MAY_BE_STORE_FROM_KEYED,
2553 ExtensibilityCheck extensibility_check = PERFORM_EXTENSIBILITY_CHECK, 2525 ExtensibilityCheck extensibility_check = PERFORM_EXTENSIBILITY_CHECK,
2554 ValueType value_type = OPTIMAL_REPRESENTATION, 2526 ValueType value_type = OPTIMAL_REPRESENTATION,
2555 StoreMode mode = ALLOW_AS_CONSTANT, 2527 StoreMode mode = ALLOW_AS_CONSTANT,
2556 TransitionFlag flag = INSERT_TRANSITION); 2528 TransitionFlag flag = INSERT_TRANSITION);
2557 2529
2558 // Convert the object to use the canonical dictionary 2530 // Convert the object to use the canonical dictionary
2559 // representation. If the object is expected to have additional properties 2531 // representation. If the object is expected to have additional properties
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
2765 uint32_t index, 2737 uint32_t index,
2766 Object* value, 2738 Object* value,
2767 PropertyAttributes attributes, 2739 PropertyAttributes attributes,
2768 StrictModeFlag strict_mode, 2740 StrictModeFlag strict_mode,
2769 bool check_prototype, 2741 bool check_prototype,
2770 SetPropertyMode set_mode); 2742 SetPropertyMode set_mode);
2771 2743
2772 // Searches the prototype chain for property 'name'. If it is found and 2744 // Searches the prototype chain for property 'name'. If it is found and
2773 // has a setter, invoke it and set '*done' to true. If it is found and is 2745 // has a setter, invoke it and set '*done' to true. If it is found and is
2774 // read-only, reject and set '*done' to true. Otherwise, set '*done' to 2746 // read-only, reject and set '*done' to true. Otherwise, set '*done' to
2775 // false. Can cause GC and can return a failure result with '*done==true'. 2747 // false. Can throw and return an empty handle with '*done==true'.
2776 MUST_USE_RESULT MaybeObject* SetPropertyViaPrototypes( 2748 static Handle<Object> SetPropertyViaPrototypes(
2749 Handle<JSObject> object,
2750 Handle<Name> name,
2751 Handle<Object> value,
2752 PropertyAttributes attributes,
2753 StrictModeFlag strict_mode,
2754 bool* done);
2755 static Handle<Object> SetPropertyPostInterceptor(
2756 Handle<JSObject> object,
2757 Handle<Name> name,
2758 Handle<Object> value,
2759 PropertyAttributes attributes,
2760 StrictModeFlag strict_mode);
2761
2762 // Add a constant function property to a fast-case object.
2763 // This leaves a CONSTANT_TRANSITION in the old map, and
2764 // if it is called on a second object with this map, a
2765 // normal property is added instead, with a map transition.
2766 // This avoids the creation of many maps with the same constant
2767 // function, all orphaned.
2768 static void AddConstantProperty(Handle<JSObject> object,
2769 Handle<Name> name,
2770 Handle<Object> constant,
2771 PropertyAttributes attributes,
2772 TransitionFlag flag);
2773 MUST_USE_RESULT MaybeObject* AddConstantProperty(
2774 Name* name,
2775 Object* constant,
2776 PropertyAttributes attributes,
2777 TransitionFlag flag);
2778
2779 // Add a property to a fast-case object.
2780 static void AddFastProperty(Handle<JSObject> object,
2781 Handle<Name> name,
2782 Handle<Object> value,
2783 PropertyAttributes attributes,
2784 StoreFromKeyed store_mode,
2785 ValueType value_type,
2786 TransitionFlag flag);
2787 MUST_USE_RESULT MaybeObject* AddFastProperty(
2777 Name* name, 2788 Name* name,
2778 Object* value, 2789 Object* value,
2779 PropertyAttributes attributes, 2790 PropertyAttributes attributes,
2780 StrictModeFlag strict_mode, 2791 StoreFromKeyed store_mode,
2781 bool* done); 2792 ValueType value_type,
2793 TransitionFlag flag);
2794
2795 // Add a property to a slow-case object.
2796 static void AddSlowProperty(Handle<JSObject> object,
2797 Handle<Name> name,
2798 Handle<Object> value,
2799 PropertyAttributes attributes);
2800 MUST_USE_RESULT MaybeObject* AddSlowProperty(Name* name,
2801 Object* value,
2802 PropertyAttributes attributes);
2782 2803
2783 static Handle<Object> DeleteProperty(Handle<JSObject> object, 2804 static Handle<Object> DeleteProperty(Handle<JSObject> object,
2784 Handle<Name> name, 2805 Handle<Name> name,
2785 DeleteMode mode); 2806 DeleteMode mode);
2786 static Handle<Object> DeletePropertyPostInterceptor(Handle<JSObject> object, 2807 static Handle<Object> DeletePropertyPostInterceptor(Handle<JSObject> object,
2787 Handle<Name> name, 2808 Handle<Name> name,
2788 DeleteMode mode); 2809 DeleteMode mode);
2789 static Handle<Object> DeletePropertyWithInterceptor(Handle<JSObject> object, 2810 static Handle<Object> DeletePropertyWithInterceptor(Handle<JSObject> object,
2790 Handle<Name> name); 2811 Handle<Name> name);
2791 2812
(...skipping 7430 matching lines...) Expand 10 before | Expand all | Expand 10 after
10222 } else { 10243 } else {
10223 value &= ~(1 << bit_position); 10244 value &= ~(1 << bit_position);
10224 } 10245 }
10225 return value; 10246 return value;
10226 } 10247 }
10227 }; 10248 };
10228 10249
10229 } } // namespace v8::internal 10250 } } // namespace v8::internal
10230 10251
10231 #endif // V8_OBJECTS_H_ 10252 #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