OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 5541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5552 v->VisitCodeEntry(this->address() + kCodeEntryOffset); | 5552 v->VisitCodeEntry(this->address() + kCodeEntryOffset); |
5553 IteratePointers(v, kCodeEntryOffset + kPointerSize, object_size); | 5553 IteratePointers(v, kCodeEntryOffset + kPointerSize, object_size); |
5554 } | 5554 } |
5555 | 5555 |
5556 | 5556 |
5557 void JSFunction::MarkForLazyRecompilation() { | 5557 void JSFunction::MarkForLazyRecompilation() { |
5558 ASSERT(is_compiled() && !IsOptimized()); | 5558 ASSERT(is_compiled() && !IsOptimized()); |
5559 ASSERT(shared()->allows_lazy_compilation() || | 5559 ASSERT(shared()->allows_lazy_compilation() || |
5560 code()->optimizable()); | 5560 code()->optimizable()); |
5561 Builtins* builtins = GetIsolate()->builtins(); | 5561 Builtins* builtins = GetIsolate()->builtins(); |
5562 ReplaceCode(builtins->builtin(Builtins::LazyRecompile)); | 5562 ReplaceCode(builtins->builtin(Builtins::kLazyRecompile)); |
5563 } | 5563 } |
5564 | 5564 |
5565 | 5565 |
5566 uint32_t JSFunction::SourceHash() { | 5566 uint32_t JSFunction::SourceHash() { |
5567 uint32_t hash = 0; | 5567 uint32_t hash = 0; |
5568 Object* script = shared()->script(); | 5568 Object* script = shared()->script(); |
5569 if (!script->IsUndefined()) { | 5569 if (!script->IsUndefined()) { |
5570 Object* source = Script::cast(script)->source(); | 5570 Object* source = Script::cast(script)->source(); |
5571 if (source->IsUndefined()) hash = String::cast(source)->Hash(); | 5571 if (source->IsUndefined()) hash = String::cast(source)->Hash(); |
5572 } | 5572 } |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5932 | 5932 |
5933 if (map->unused_property_fields() == 0) return; | 5933 if (map->unused_property_fields() == 0) return; |
5934 | 5934 |
5935 // Nonzero counter is a leftover from the previous attempt interrupted | 5935 // Nonzero counter is a leftover from the previous attempt interrupted |
5936 // by GC, keep it. | 5936 // by GC, keep it. |
5937 if (construction_count() == 0) { | 5937 if (construction_count() == 0) { |
5938 set_construction_count(kGenerousAllocationCount); | 5938 set_construction_count(kGenerousAllocationCount); |
5939 } | 5939 } |
5940 set_initial_map(map); | 5940 set_initial_map(map); |
5941 Builtins* builtins = map->heap()->isolate()->builtins(); | 5941 Builtins* builtins = map->heap()->isolate()->builtins(); |
5942 ASSERT_EQ(builtins->builtin(Builtins::JSConstructStubGeneric), | 5942 ASSERT_EQ(builtins->builtin(Builtins::kJSConstructStubGeneric), |
5943 construct_stub()); | 5943 construct_stub()); |
5944 set_construct_stub(builtins->builtin(Builtins::JSConstructStubCountdown)); | 5944 set_construct_stub(builtins->builtin(Builtins::kJSConstructStubCountdown)); |
5945 } | 5945 } |
5946 | 5946 |
5947 | 5947 |
5948 // Called from GC, hence reinterpret_cast and unchecked accessors. | 5948 // Called from GC, hence reinterpret_cast and unchecked accessors. |
5949 void SharedFunctionInfo::DetachInitialMap() { | 5949 void SharedFunctionInfo::DetachInitialMap() { |
5950 Map* map = reinterpret_cast<Map*>(initial_map()); | 5950 Map* map = reinterpret_cast<Map*>(initial_map()); |
5951 | 5951 |
5952 // Make the map remember to restore the link if it survives the GC. | 5952 // Make the map remember to restore the link if it survives the GC. |
5953 map->set_bit_field2( | 5953 map->set_bit_field2( |
5954 map->bit_field2() | (1 << Map::kAttachedToSharedFunctionInfo)); | 5954 map->bit_field2() | (1 << Map::kAttachedToSharedFunctionInfo)); |
5955 | 5955 |
5956 // Undo state changes made by StartInobjectTracking (except the | 5956 // Undo state changes made by StartInobjectTracking (except the |
5957 // construction_count). This way if the initial map does not survive the GC | 5957 // construction_count). This way if the initial map does not survive the GC |
5958 // then StartInobjectTracking will be called again the next time the | 5958 // then StartInobjectTracking will be called again the next time the |
5959 // constructor is called. The countdown will continue and (possibly after | 5959 // constructor is called. The countdown will continue and (possibly after |
5960 // several more GCs) CompleteInobjectSlackTracking will eventually be called. | 5960 // several more GCs) CompleteInobjectSlackTracking will eventually be called. |
5961 set_initial_map(map->heap()->raw_unchecked_undefined_value()); | 5961 set_initial_map(map->heap()->raw_unchecked_undefined_value()); |
5962 Builtins* builtins = map->heap()->isolate()->builtins(); | 5962 Builtins* builtins = map->heap()->isolate()->builtins(); |
5963 ASSERT_EQ(builtins->builtin(Builtins::JSConstructStubCountdown), | 5963 ASSERT_EQ(builtins->builtin(Builtins::kJSConstructStubCountdown), |
5964 *RawField(this, kConstructStubOffset)); | 5964 *RawField(this, kConstructStubOffset)); |
5965 set_construct_stub(builtins->builtin(Builtins::JSConstructStubGeneric)); | 5965 set_construct_stub(builtins->builtin(Builtins::kJSConstructStubGeneric)); |
5966 // It is safe to clear the flag: it will be set again if the map is live. | 5966 // It is safe to clear the flag: it will be set again if the map is live. |
5967 set_live_objects_may_exist(false); | 5967 set_live_objects_may_exist(false); |
5968 } | 5968 } |
5969 | 5969 |
5970 | 5970 |
5971 // Called from GC, hence reinterpret_cast and unchecked accessors. | 5971 // Called from GC, hence reinterpret_cast and unchecked accessors. |
5972 void SharedFunctionInfo::AttachInitialMap(Map* map) { | 5972 void SharedFunctionInfo::AttachInitialMap(Map* map) { |
5973 map->set_bit_field2( | 5973 map->set_bit_field2( |
5974 map->bit_field2() & ~(1 << Map::kAttachedToSharedFunctionInfo)); | 5974 map->bit_field2() & ~(1 << Map::kAttachedToSharedFunctionInfo)); |
5975 | 5975 |
5976 // Resume inobject slack tracking. | 5976 // Resume inobject slack tracking. |
5977 set_initial_map(map); | 5977 set_initial_map(map); |
5978 Builtins* builtins = map->heap()->isolate()->builtins(); | 5978 Builtins* builtins = map->heap()->isolate()->builtins(); |
5979 ASSERT_EQ(builtins->builtin(Builtins::JSConstructStubGeneric), | 5979 ASSERT_EQ(builtins->builtin(Builtins::kJSConstructStubGeneric), |
5980 *RawField(this, kConstructStubOffset)); | 5980 *RawField(this, kConstructStubOffset)); |
5981 set_construct_stub(builtins->builtin(Builtins::JSConstructStubCountdown)); | 5981 set_construct_stub(builtins->builtin(Builtins::kJSConstructStubCountdown)); |
5982 // The map survived the gc, so there may be objects referencing it. | 5982 // The map survived the gc, so there may be objects referencing it. |
5983 set_live_objects_may_exist(true); | 5983 set_live_objects_may_exist(true); |
5984 } | 5984 } |
5985 | 5985 |
5986 | 5986 |
5987 static void GetMinInobjectSlack(Map* map, void* data) { | 5987 static void GetMinInobjectSlack(Map* map, void* data) { |
5988 int slack = map->unused_property_fields(); | 5988 int slack = map->unused_property_fields(); |
5989 if (*reinterpret_cast<int*>(data) > slack) { | 5989 if (*reinterpret_cast<int*>(data) > slack) { |
5990 *reinterpret_cast<int*>(data) = slack; | 5990 *reinterpret_cast<int*>(data) = slack; |
5991 } | 5991 } |
(...skipping 11 matching lines...) Expand all Loading... |
6003 } | 6003 } |
6004 | 6004 |
6005 | 6005 |
6006 void SharedFunctionInfo::CompleteInobjectSlackTracking() { | 6006 void SharedFunctionInfo::CompleteInobjectSlackTracking() { |
6007 ASSERT(live_objects_may_exist() && IsInobjectSlackTrackingInProgress()); | 6007 ASSERT(live_objects_may_exist() && IsInobjectSlackTrackingInProgress()); |
6008 Map* map = Map::cast(initial_map()); | 6008 Map* map = Map::cast(initial_map()); |
6009 | 6009 |
6010 Heap* heap = map->heap(); | 6010 Heap* heap = map->heap(); |
6011 set_initial_map(heap->undefined_value()); | 6011 set_initial_map(heap->undefined_value()); |
6012 Builtins* builtins = heap->isolate()->builtins(); | 6012 Builtins* builtins = heap->isolate()->builtins(); |
6013 ASSERT_EQ(builtins->builtin(Builtins::JSConstructStubCountdown), | 6013 ASSERT_EQ(builtins->builtin(Builtins::kJSConstructStubCountdown), |
6014 construct_stub()); | 6014 construct_stub()); |
6015 set_construct_stub(builtins->builtin(Builtins::JSConstructStubGeneric)); | 6015 set_construct_stub(builtins->builtin(Builtins::kJSConstructStubGeneric)); |
6016 | 6016 |
6017 int slack = map->unused_property_fields(); | 6017 int slack = map->unused_property_fields(); |
6018 map->TraverseTransitionTree(&GetMinInobjectSlack, &slack); | 6018 map->TraverseTransitionTree(&GetMinInobjectSlack, &slack); |
6019 if (slack != 0) { | 6019 if (slack != 0) { |
6020 // Resize the initial map and all maps in its transition tree. | 6020 // Resize the initial map and all maps in its transition tree. |
6021 map->TraverseTransitionTree(&ShrinkInstanceSize, &slack); | 6021 map->TraverseTransitionTree(&ShrinkInstanceSize, &slack); |
6022 // Give the correct expected_nof_properties to initial maps created later. | 6022 // Give the correct expected_nof_properties to initial maps created later. |
6023 ASSERT(expected_nof_properties() >= slack); | 6023 ASSERT(expected_nof_properties() >= slack); |
6024 set_expected_nof_properties(expected_nof_properties() - slack); | 6024 set_expected_nof_properties(expected_nof_properties() - slack); |
6025 } | 6025 } |
(...skipping 4136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10162 if (break_point_objects()->IsUndefined()) return 0; | 10162 if (break_point_objects()->IsUndefined()) return 0; |
10163 // Single beak point. | 10163 // Single beak point. |
10164 if (!break_point_objects()->IsFixedArray()) return 1; | 10164 if (!break_point_objects()->IsFixedArray()) return 1; |
10165 // Multiple break points. | 10165 // Multiple break points. |
10166 return FixedArray::cast(break_point_objects())->length(); | 10166 return FixedArray::cast(break_point_objects())->length(); |
10167 } | 10167 } |
10168 #endif | 10168 #endif |
10169 | 10169 |
10170 | 10170 |
10171 } } // namespace v8::internal | 10171 } } // namespace v8::internal |
OLD | NEW |