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

Side by Side Diff: src/objects.h

Issue 23857009: Handlify JSObject::AddProperty helpers. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: 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') | src/objects.cc » ('J')
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 2451 matching lines...) Expand 10 before | Expand all | Expand 10 after
2462 // Returns the number of elements on this object filtering out elements 2462 // Returns the number of elements on this object filtering out elements
2463 // with the specified attributes (ignoring interceptors). 2463 // with the specified attributes (ignoring interceptors).
2464 int GetLocalElementKeys(FixedArray* storage, PropertyAttributes filter); 2464 int GetLocalElementKeys(FixedArray* storage, PropertyAttributes filter);
2465 // Count and fill in the enumerable elements into storage. 2465 // Count and fill in the enumerable elements into storage.
2466 // (storage->length() == NumberOfEnumElements()). 2466 // (storage->length() == NumberOfEnumElements()).
2467 // If storage is NULL, will count the elements without adding 2467 // If storage is NULL, will count the elements without adding
2468 // them to any storage. 2468 // them to any storage.
2469 // Returns the number of enumerable elements. 2469 // Returns the number of enumerable elements.
2470 int GetEnumElementKeys(FixedArray* storage); 2470 int GetEnumElementKeys(FixedArray* storage);
2471 2471
2472 // Add a property to a fast-case object using a map transition to
2473 // new_map.
2474 // TODO(mstarzinger): Only public because of SetPropertyUsingTransition!
2475 MUST_USE_RESULT MaybeObject* AddFastPropertyUsingMap(
2476 Map* new_map,
2477 Name* name,
2478 Object* value,
2479 int field_index,
2480 Representation representation);
2481
2482 MUST_USE_RESULT MaybeObject* ReplaceSlowProperty( 2472 MUST_USE_RESULT MaybeObject* ReplaceSlowProperty(
2483 Name* name, 2473 Name* name,
2484 Object* value, 2474 Object* value,
2485 PropertyAttributes attributes); 2475 PropertyAttributes attributes);
2486 2476
2487 // Returns a new map with all transitions dropped from the object's current 2477 // Returns a new map with all transitions dropped from the object's current
2488 // map and the ElementsKind set. 2478 // map and the ElementsKind set.
2489 static Handle<Map> GetElementsTransitionMap(Handle<JSObject> object, 2479 static Handle<Map> GetElementsTransitionMap(Handle<JSObject> object,
2490 ElementsKind to_kind); 2480 ElementsKind to_kind);
2491 inline MUST_USE_RESULT MaybeObject* GetElementsTransitionMap( 2481 inline MUST_USE_RESULT MaybeObject* GetElementsTransitionMap(
2492 Isolate* isolate, 2482 Isolate* isolate,
2493 ElementsKind elements_kind); 2483 ElementsKind elements_kind);
2494 MUST_USE_RESULT MaybeObject* GetElementsTransitionMapSlow( 2484 MUST_USE_RESULT MaybeObject* GetElementsTransitionMapSlow(
2495 ElementsKind elements_kind); 2485 ElementsKind elements_kind);
2496 2486
2497 static Handle<Object> TransitionElementsKind(Handle<JSObject> object, 2487 static Handle<Object> TransitionElementsKind(Handle<JSObject> object,
2498 ElementsKind to_kind); 2488 ElementsKind to_kind);
2499 2489
2500 MUST_USE_RESULT MaybeObject* TransitionElementsKind(ElementsKind to_kind); 2490 MUST_USE_RESULT MaybeObject* TransitionElementsKind(ElementsKind to_kind);
2501 MUST_USE_RESULT MaybeObject* UpdateAllocationSite(ElementsKind to_kind); 2491 MUST_USE_RESULT MaybeObject* UpdateAllocationSite(ElementsKind to_kind);
2502 2492
2503 MUST_USE_RESULT MaybeObject* MigrateToMap(Map* new_map); 2493 MUST_USE_RESULT MaybeObject* MigrateToMap(Map* new_map);
2504 MUST_USE_RESULT MaybeObject* GeneralizeFieldRepresentation( 2494 MUST_USE_RESULT MaybeObject* GeneralizeFieldRepresentation(
2505 int modify_index, 2495 int modify_index,
2506 Representation new_representation, 2496 Representation new_representation,
2507 StoreMode store_mode); 2497 StoreMode store_mode);
2508 2498
2509 // Add a property to an object.
2510 // TODO(mstarzinger): Only public because of SetPropertyUsingTransition!
2511 static Handle<Object> AddProperty(
2512 Handle<JSObject> object,
2513 Handle<Name> name,
2514 Handle<Object> value,
2515 PropertyAttributes attributes,
2516 StrictModeFlag strict_mode,
2517 StoreFromKeyed store_mode = MAY_BE_STORE_FROM_KEYED,
2518 ExtensibilityCheck extensibility_check = PERFORM_EXTENSIBILITY_CHECK,
2519 ValueType value_type = OPTIMAL_REPRESENTATION,
2520 StoreMode mode = ALLOW_AS_CONSTANT,
2521 TransitionFlag flag = INSERT_TRANSITION);
2522
2523 // Convert the object to use the canonical dictionary 2499 // Convert the object to use the canonical dictionary
2524 // representation. If the object is expected to have additional properties 2500 // representation. If the object is expected to have additional properties
2525 // added this number can be indicated to have the backing store allocated to 2501 // added this number can be indicated to have the backing store allocated to
2526 // an initial capacity for holding these properties. 2502 // an initial capacity for holding these properties.
2527 static void NormalizeProperties(Handle<JSObject> object, 2503 static void NormalizeProperties(Handle<JSObject> object,
2528 PropertyNormalizationMode mode, 2504 PropertyNormalizationMode mode,
2529 int expected_additional_properties); 2505 int expected_additional_properties);
2530 2506
2531 MUST_USE_RESULT MaybeObject* NormalizeProperties( 2507 MUST_USE_RESULT MaybeObject* NormalizeProperties(
2532 PropertyNormalizationMode mode, 2508 PropertyNormalizationMode mode,
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
2753 Handle<Object> value, 2729 Handle<Object> value,
2754 PropertyAttributes attributes, 2730 PropertyAttributes attributes,
2755 StrictModeFlag strict_mode, 2731 StrictModeFlag strict_mode,
2756 bool* done); 2732 bool* done);
2757 static Handle<Object> SetPropertyPostInterceptor( 2733 static Handle<Object> SetPropertyPostInterceptor(
2758 Handle<JSObject> object, 2734 Handle<JSObject> object,
2759 Handle<Name> name, 2735 Handle<Name> name,
2760 Handle<Object> value, 2736 Handle<Object> value,
2761 PropertyAttributes attributes, 2737 PropertyAttributes attributes,
2762 StrictModeFlag strict_mode); 2738 StrictModeFlag strict_mode);
2739 // TODO(mstarzinger): Fully handlify this one!
2740 static MaybeObject* SetPropertyUsingTransition(LookupResult* lookup,
2741 Handle<Name> name,
2742 Handle<Object> value,
2743 PropertyAttributes attributes);
2744
2745 // Add a property to an object.
2746 static Handle<Object> AddProperty(
2747 Handle<JSObject> object,
2748 Handle<Name> name,
2749 Handle<Object> value,
2750 PropertyAttributes attributes,
2751 StrictModeFlag strict_mode,
2752 StoreFromKeyed store_mode = MAY_BE_STORE_FROM_KEYED,
2753 ExtensibilityCheck extensibility_check = PERFORM_EXTENSIBILITY_CHECK,
2754 ValueType value_type = OPTIMAL_REPRESENTATION,
2755 StoreMode mode = ALLOW_AS_CONSTANT,
2756 TransitionFlag flag = INSERT_TRANSITION);
2763 2757
2764 // Add a constant function property to a fast-case object. 2758 // Add a constant function property to a fast-case object.
2765 // This leaves a CONSTANT_TRANSITION in the old map, and 2759 // This leaves a CONSTANT_TRANSITION in the old map, and
2766 // if it is called on a second object with this map, a 2760 // if it is called on a second object with this map, a
2767 // normal property is added instead, with a map transition. 2761 // normal property is added instead, with a map transition.
2768 // This avoids the creation of many maps with the same constant 2762 // This avoids the creation of many maps with the same constant
2769 // function, all orphaned. 2763 // function, all orphaned.
2770 static void AddConstantProperty(Handle<JSObject> object, 2764 static void AddConstantProperty(Handle<JSObject> object,
2771 Handle<Name> name, 2765 Handle<Name> name,
2772 Handle<Object> constant, 2766 Handle<Object> constant,
2773 PropertyAttributes attributes, 2767 PropertyAttributes attributes,
2774 TransitionFlag flag); 2768 TransitionFlag flag);
2775 MUST_USE_RESULT MaybeObject* AddConstantProperty(
2776 Name* name,
2777 Object* constant,
2778 PropertyAttributes attributes,
2779 TransitionFlag flag);
2780 2769
2781 // Add a property to a fast-case object. 2770 // Add a property to a fast-case object.
2782 static void AddFastProperty(Handle<JSObject> object, 2771 static void AddFastProperty(Handle<JSObject> object,
2783 Handle<Name> name, 2772 Handle<Name> name,
2784 Handle<Object> value, 2773 Handle<Object> value,
2785 PropertyAttributes attributes, 2774 PropertyAttributes attributes,
2786 StoreFromKeyed store_mode, 2775 StoreFromKeyed store_mode,
2787 ValueType value_type, 2776 ValueType value_type,
2788 TransitionFlag flag); 2777 TransitionFlag flag);
2789 MUST_USE_RESULT MaybeObject* AddFastProperty( 2778
2779 // Add a property to a fast-case object using a map transition to
2780 // new_map.
2781 MUST_USE_RESULT MaybeObject* AddFastPropertyUsingMap(
2782 Map* new_map,
2790 Name* name, 2783 Name* name,
2791 Object* value, 2784 Object* value,
2792 PropertyAttributes attributes, 2785 int field_index,
2793 StoreFromKeyed store_mode, 2786 Representation representation);
2794 ValueType value_type,
2795 TransitionFlag flag);
2796 2787
2797 // Add a property to a slow-case object. 2788 // Add a property to a slow-case object.
2798 static void AddSlowProperty(Handle<JSObject> object, 2789 static void AddSlowProperty(Handle<JSObject> object,
2799 Handle<Name> name, 2790 Handle<Name> name,
2800 Handle<Object> value, 2791 Handle<Object> value,
2801 PropertyAttributes attributes); 2792 PropertyAttributes attributes);
2802 MUST_USE_RESULT MaybeObject* AddSlowProperty(Name* name,
2803 Object* value,
2804 PropertyAttributes attributes);
2805 2793
2806 static Handle<Object> DeleteProperty(Handle<JSObject> object, 2794 static Handle<Object> DeleteProperty(Handle<JSObject> object,
2807 Handle<Name> name, 2795 Handle<Name> name,
2808 DeleteMode mode); 2796 DeleteMode mode);
2809 static Handle<Object> DeletePropertyPostInterceptor(Handle<JSObject> object, 2797 static Handle<Object> DeletePropertyPostInterceptor(Handle<JSObject> object,
2810 Handle<Name> name, 2798 Handle<Name> name,
2811 DeleteMode mode); 2799 DeleteMode mode);
2812 static Handle<Object> DeletePropertyWithInterceptor(Handle<JSObject> object, 2800 static Handle<Object> DeletePropertyWithInterceptor(Handle<JSObject> object,
2813 Handle<Name> name); 2801 Handle<Name> name);
2814 2802
(...skipping 6200 matching lines...) Expand 10 before | Expand all | Expand 10 after
9015 void set_type(Type* value, WriteBarrierMode mode = UPDATE_WRITE_BARRIER); 9003 void set_type(Type* value, WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
9016 9004
9017 // [dependent_code]: dependent code that depends on the type of the global 9005 // [dependent_code]: dependent code that depends on the type of the global
9018 // property. 9006 // property.
9019 DECL_ACCESSORS(dependent_code, DependentCode) 9007 DECL_ACCESSORS(dependent_code, DependentCode)
9020 9008
9021 // Sets the value of the cell and updates the type field to be the union 9009 // Sets the value of the cell and updates the type field to be the union
9022 // of the cell's current type and the value's type. If the change causes 9010 // of the cell's current type and the value's type. If the change causes
9023 // a change of the type of the cell's contents, code dependent on the cell 9011 // a change of the type of the cell's contents, code dependent on the cell
9024 // will be deoptimized. 9012 // will be deoptimized.
9013 static void SetValueInferType(Handle<PropertyCell> cell,
9014 Handle<Object> value,
9015 WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
9025 MUST_USE_RESULT MaybeObject* SetValueInferType( 9016 MUST_USE_RESULT MaybeObject* SetValueInferType(
9026 Object* value, 9017 Object* value,
9027 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); 9018 WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
9028 9019
9029 // Casting. 9020 // Casting.
9030 static inline PropertyCell* cast(Object* obj); 9021 static inline PropertyCell* cast(Object* obj);
9031 9022
9032 inline Address TypeAddress() { 9023 inline Address TypeAddress() {
9033 return address() + kTypeOffset; 9024 return address() + kTypeOffset;
9034 } 9025 }
(...skipping 1212 matching lines...) Expand 10 before | Expand all | Expand 10 after
10247 } else { 10238 } else {
10248 value &= ~(1 << bit_position); 10239 value &= ~(1 << bit_position);
10249 } 10240 }
10250 return value; 10241 return value;
10251 } 10242 }
10252 }; 10243 };
10253 10244
10254 } } // namespace v8::internal 10245 } } // namespace v8::internal
10255 10246
10256 #endif // V8_OBJECTS_H_ 10247 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « no previous file | src/objects.cc » ('j') | src/objects.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698