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

Side by Side Diff: src/heap/heap.cc

Issue 475423003: Implement Function.prototype.toMethod. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Name for the last test Created 6 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 | « src/heap/heap.h ('k') | src/messages.js » ('j') | src/runtime.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 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/api.h" 8 #include "src/api.h"
9 #include "src/base/once.h" 9 #include "src/base/once.h"
10 #include "src/base/utils/random-number-generator.h" 10 #include "src/base/utils/random-number-generator.h"
(...skipping 2859 matching lines...) Expand 10 before | Expand all | Expand 10 after
2870 2870
2871 set_detailed_stack_trace_symbol(*factory->NewPrivateSymbol()); 2871 set_detailed_stack_trace_symbol(*factory->NewPrivateSymbol());
2872 set_elements_transition_symbol(*factory->NewPrivateSymbol()); 2872 set_elements_transition_symbol(*factory->NewPrivateSymbol());
2873 set_frozen_symbol(*factory->NewPrivateSymbol()); 2873 set_frozen_symbol(*factory->NewPrivateSymbol());
2874 set_megamorphic_symbol(*factory->NewPrivateSymbol()); 2874 set_megamorphic_symbol(*factory->NewPrivateSymbol());
2875 set_nonexistent_symbol(*factory->NewPrivateSymbol()); 2875 set_nonexistent_symbol(*factory->NewPrivateSymbol());
2876 set_normal_ic_symbol(*factory->NewPrivateSymbol()); 2876 set_normal_ic_symbol(*factory->NewPrivateSymbol());
2877 set_observed_symbol(*factory->NewPrivateSymbol()); 2877 set_observed_symbol(*factory->NewPrivateSymbol());
2878 set_stack_trace_symbol(*factory->NewPrivateSymbol()); 2878 set_stack_trace_symbol(*factory->NewPrivateSymbol());
2879 set_uninitialized_symbol(*factory->NewPrivateSymbol()); 2879 set_uninitialized_symbol(*factory->NewPrivateSymbol());
2880 set_home_object_symbol(*factory->NewPrivateOwnSymbol());
2880 2881
2881 Handle<SeededNumberDictionary> slow_element_dictionary = 2882 Handle<SeededNumberDictionary> slow_element_dictionary =
2882 SeededNumberDictionary::New(isolate(), 0, TENURED); 2883 SeededNumberDictionary::New(isolate(), 0, TENURED);
2883 slow_element_dictionary->set_requires_slow_elements(); 2884 slow_element_dictionary->set_requires_slow_elements();
2884 set_empty_slow_element_dictionary(*slow_element_dictionary); 2885 set_empty_slow_element_dictionary(*slow_element_dictionary);
2885 2886
2886 set_materialized_objects(*factory->NewFixedArray(0, TENURED)); 2887 set_materialized_objects(*factory->NewFixedArray(0, TENURED));
2887 2888
2888 // Handling of script id generation is in Factory::NewScript. 2889 // Handling of script id generation is in Factory::NewScript.
2889 set_last_script_id(Smi::FromInt(v8::UnboundScript::kNoScriptId)); 2890 set_last_script_id(Smi::FromInt(v8::UnboundScript::kNoScriptId));
(...skipping 782 matching lines...) Expand 10 before | Expand all | Expand 10 after
3672 #ifdef DEBUG 3673 #ifdef DEBUG
3673 // Make sure result is NOT a global object if valid. 3674 // Make sure result is NOT a global object if valid.
3674 HeapObject* obj; 3675 HeapObject* obj;
3675 DCHECK(!allocation.To(&obj) || !obj->IsGlobalObject()); 3676 DCHECK(!allocation.To(&obj) || !obj->IsGlobalObject());
3676 #endif 3677 #endif
3677 return allocation; 3678 return allocation;
3678 } 3679 }
3679 3680
3680 3681
3681 AllocationResult Heap::CopyJSObject(JSObject* source, AllocationSite* site) { 3682 AllocationResult Heap::CopyJSObject(JSObject* source, AllocationSite* site) {
3682 // Never used to copy functions. If functions need to be copied we
3683 // have to be careful to clear the literals array.
3684 SLOW_DCHECK(!source->IsJSFunction());
3685
3686 // Make the clone. 3683 // Make the clone.
3687 Map* map = source->map(); 3684 Map* map = source->map();
3688 int object_size = map->instance_size(); 3685 int object_size = map->instance_size();
3689 HeapObject* clone; 3686 HeapObject* clone;
3690 3687
3691 DCHECK(site == NULL || AllocationSite::CanTrack(map->instance_type())); 3688 DCHECK(site == NULL || AllocationSite::CanTrack(map->instance_type()));
3692 3689
3693 WriteBarrierMode wb_mode = UPDATE_WRITE_BARRIER; 3690 WriteBarrierMode wb_mode = UPDATE_WRITE_BARRIER;
3694 3691
3695 // If we're forced to always allocate, we use the general allocation 3692 // If we're forced to always allocate, we use the general allocation
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
3749 } 3746 }
3750 // Update properties if necessary. 3747 // Update properties if necessary.
3751 if (properties->length() > 0) { 3748 if (properties->length() > 0) {
3752 FixedArray* prop; 3749 FixedArray* prop;
3753 { 3750 {
3754 AllocationResult allocation = CopyFixedArray(properties); 3751 AllocationResult allocation = CopyFixedArray(properties);
3755 if (!allocation.To(&prop)) return allocation; 3752 if (!allocation.To(&prop)) return allocation;
3756 } 3753 }
3757 JSObject::cast(clone)->set_properties(prop, wb_mode); 3754 JSObject::cast(clone)->set_properties(prop, wb_mode);
3758 } 3755 }
3756
3757 // Clean up literals array.
3758 if (source->IsJSFunction()) {
Toon Verwaest 2014/08/18 14:15:35 Are you sure this works? What code object does thi
Dmitry Lomov (no reviews) 2014/08/19 13:47:42 You are quite right, it is easy to write a test th
3759 SLOW_DCHECK(clone->IsJSFunction());
3760 JSFunction* source_fun = JSFunction::cast(source);
3761 JSFunction* clone_fun = JSFunction::cast(clone);
3762 SharedFunctionInfo* info = source_fun->shared();
3763 if (!info->bound()) {
3764 int num_literals = info->num_literals();
3765 HeapObject* obj;
3766 {
3767 AllocationResult allocation = AllocateFixedArrayWithFiller(
3768 num_literals, NOT_TENURED, undefined_value());
3769 if (!allocation.To(&obj)) return allocation;
3770 }
3771 FixedArray* new_literals = FixedArray::cast(obj);
3772 if (num_literals > 0) {
3773 new_literals->set(JSFunction::kLiteralNativeContextIndex,
3774 JSFunction::NativeContextFromLiterals(source_fun->literals()));
3775 }
3776 clone_fun->set_literals(new_literals);
3777 }
3778 }
3759 // Return the new clone. 3779 // Return the new clone.
3760 return clone; 3780 return clone;
3761 } 3781 }
3762 3782
3763 3783
3764 static inline void WriteOneByteData(Vector<const char> vector, uint8_t* chars, 3784 static inline void WriteOneByteData(Vector<const char> vector, uint8_t* chars,
3765 int len) { 3785 int len) {
3766 // Only works for ascii. 3786 // Only works for ascii.
3767 DCHECK(vector.length() == len); 3787 DCHECK(vector.length() == len);
3768 MemCopy(chars, vector.start(), len); 3788 MemCopy(chars, vector.start(), len);
(...skipping 2374 matching lines...) Expand 10 before | Expand all | Expand 10 after
6143 static_cast<int>(object_sizes_last_time_[index])); 6163 static_cast<int>(object_sizes_last_time_[index]));
6144 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) 6164 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT)
6145 #undef ADJUST_LAST_TIME_OBJECT_COUNT 6165 #undef ADJUST_LAST_TIME_OBJECT_COUNT
6146 6166
6147 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); 6167 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_));
6148 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); 6168 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_));
6149 ClearObjectStats(); 6169 ClearObjectStats();
6150 } 6170 }
6151 } 6171 }
6152 } // namespace v8::internal 6172 } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap/heap.h ('k') | src/messages.js » ('j') | src/runtime.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698