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 5624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5635 v->VisitCodeEntry(this->address() + kCodeEntryOffset); | 5635 v->VisitCodeEntry(this->address() + kCodeEntryOffset); |
5636 IteratePointers(v, kCodeEntryOffset + kPointerSize, object_size); | 5636 IteratePointers(v, kCodeEntryOffset + kPointerSize, object_size); |
5637 } | 5637 } |
5638 | 5638 |
5639 | 5639 |
5640 void JSFunction::MarkForLazyRecompilation() { | 5640 void JSFunction::MarkForLazyRecompilation() { |
5641 ASSERT(is_compiled() && !IsOptimized()); | 5641 ASSERT(is_compiled() && !IsOptimized()); |
5642 ASSERT(shared()->allows_lazy_compilation() || | 5642 ASSERT(shared()->allows_lazy_compilation() || |
5643 code()->optimizable()); | 5643 code()->optimizable()); |
5644 Builtins* builtins = GetIsolate()->builtins(); | 5644 Builtins* builtins = GetIsolate()->builtins(); |
5645 ReplaceCode(builtins->builtin(Builtins::LazyRecompile)); | 5645 ReplaceCode(builtins->builtin(Builtins::kLazyRecompile)); |
5646 } | 5646 } |
5647 | 5647 |
5648 | 5648 |
5649 uint32_t JSFunction::SourceHash() { | 5649 uint32_t JSFunction::SourceHash() { |
5650 uint32_t hash = 0; | 5650 uint32_t hash = 0; |
5651 Object* script = shared()->script(); | 5651 Object* script = shared()->script(); |
5652 if (!script->IsUndefined()) { | 5652 if (!script->IsUndefined()) { |
5653 Object* source = Script::cast(script)->source(); | 5653 Object* source = Script::cast(script)->source(); |
5654 if (source->IsUndefined()) hash = String::cast(source)->Hash(); | 5654 if (source->IsUndefined()) hash = String::cast(source)->Hash(); |
5655 } | 5655 } |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6015 | 6015 |
6016 if (map->unused_property_fields() == 0) return; | 6016 if (map->unused_property_fields() == 0) return; |
6017 | 6017 |
6018 // Nonzero counter is a leftover from the previous attempt interrupted | 6018 // Nonzero counter is a leftover from the previous attempt interrupted |
6019 // by GC, keep it. | 6019 // by GC, keep it. |
6020 if (construction_count() == 0) { | 6020 if (construction_count() == 0) { |
6021 set_construction_count(kGenerousAllocationCount); | 6021 set_construction_count(kGenerousAllocationCount); |
6022 } | 6022 } |
6023 set_initial_map(map); | 6023 set_initial_map(map); |
6024 Builtins* builtins = map->heap()->isolate()->builtins(); | 6024 Builtins* builtins = map->heap()->isolate()->builtins(); |
6025 ASSERT_EQ(builtins->builtin(Builtins::JSConstructStubGeneric), | 6025 ASSERT_EQ(builtins->builtin(Builtins::kJSConstructStubGeneric), |
6026 construct_stub()); | 6026 construct_stub()); |
6027 set_construct_stub(builtins->builtin(Builtins::JSConstructStubCountdown)); | 6027 set_construct_stub(builtins->builtin(Builtins::kJSConstructStubCountdown)); |
6028 } | 6028 } |
6029 | 6029 |
6030 | 6030 |
6031 // Called from GC, hence reinterpret_cast and unchecked accessors. | 6031 // Called from GC, hence reinterpret_cast and unchecked accessors. |
6032 void SharedFunctionInfo::DetachInitialMap() { | 6032 void SharedFunctionInfo::DetachInitialMap() { |
6033 Map* map = reinterpret_cast<Map*>(initial_map()); | 6033 Map* map = reinterpret_cast<Map*>(initial_map()); |
6034 | 6034 |
6035 // Make the map remember to restore the link if it survives the GC. | 6035 // Make the map remember to restore the link if it survives the GC. |
6036 map->set_bit_field2( | 6036 map->set_bit_field2( |
6037 map->bit_field2() | (1 << Map::kAttachedToSharedFunctionInfo)); | 6037 map->bit_field2() | (1 << Map::kAttachedToSharedFunctionInfo)); |
6038 | 6038 |
6039 // Undo state changes made by StartInobjectTracking (except the | 6039 // Undo state changes made by StartInobjectTracking (except the |
6040 // construction_count). This way if the initial map does not survive the GC | 6040 // construction_count). This way if the initial map does not survive the GC |
6041 // then StartInobjectTracking will be called again the next time the | 6041 // then StartInobjectTracking will be called again the next time the |
6042 // constructor is called. The countdown will continue and (possibly after | 6042 // constructor is called. The countdown will continue and (possibly after |
6043 // several more GCs) CompleteInobjectSlackTracking will eventually be called. | 6043 // several more GCs) CompleteInobjectSlackTracking will eventually be called. |
6044 set_initial_map(map->heap()->raw_unchecked_undefined_value()); | 6044 set_initial_map(map->heap()->raw_unchecked_undefined_value()); |
6045 Builtins* builtins = map->heap()->isolate()->builtins(); | 6045 Builtins* builtins = map->heap()->isolate()->builtins(); |
6046 ASSERT_EQ(builtins->builtin(Builtins::JSConstructStubCountdown), | 6046 ASSERT_EQ(builtins->builtin(Builtins::kJSConstructStubCountdown), |
6047 *RawField(this, kConstructStubOffset)); | 6047 *RawField(this, kConstructStubOffset)); |
6048 set_construct_stub(builtins->builtin(Builtins::JSConstructStubGeneric)); | 6048 set_construct_stub(builtins->builtin(Builtins::kJSConstructStubGeneric)); |
6049 // It is safe to clear the flag: it will be set again if the map is live. | 6049 // It is safe to clear the flag: it will be set again if the map is live. |
6050 set_live_objects_may_exist(false); | 6050 set_live_objects_may_exist(false); |
6051 } | 6051 } |
6052 | 6052 |
6053 | 6053 |
6054 // Called from GC, hence reinterpret_cast and unchecked accessors. | 6054 // Called from GC, hence reinterpret_cast and unchecked accessors. |
6055 void SharedFunctionInfo::AttachInitialMap(Map* map) { | 6055 void SharedFunctionInfo::AttachInitialMap(Map* map) { |
6056 map->set_bit_field2( | 6056 map->set_bit_field2( |
6057 map->bit_field2() & ~(1 << Map::kAttachedToSharedFunctionInfo)); | 6057 map->bit_field2() & ~(1 << Map::kAttachedToSharedFunctionInfo)); |
6058 | 6058 |
6059 // Resume inobject slack tracking. | 6059 // Resume inobject slack tracking. |
6060 set_initial_map(map); | 6060 set_initial_map(map); |
6061 Builtins* builtins = map->heap()->isolate()->builtins(); | 6061 Builtins* builtins = map->heap()->isolate()->builtins(); |
6062 ASSERT_EQ(builtins->builtin(Builtins::JSConstructStubGeneric), | 6062 ASSERT_EQ(builtins->builtin(Builtins::kJSConstructStubGeneric), |
6063 *RawField(this, kConstructStubOffset)); | 6063 *RawField(this, kConstructStubOffset)); |
6064 set_construct_stub(builtins->builtin(Builtins::JSConstructStubCountdown)); | 6064 set_construct_stub(builtins->builtin(Builtins::kJSConstructStubCountdown)); |
6065 // The map survived the gc, so there may be objects referencing it. | 6065 // The map survived the gc, so there may be objects referencing it. |
6066 set_live_objects_may_exist(true); | 6066 set_live_objects_may_exist(true); |
6067 } | 6067 } |
6068 | 6068 |
6069 | 6069 |
6070 static void GetMinInobjectSlack(Map* map, void* data) { | 6070 static void GetMinInobjectSlack(Map* map, void* data) { |
6071 int slack = map->unused_property_fields(); | 6071 int slack = map->unused_property_fields(); |
6072 if (*reinterpret_cast<int*>(data) > slack) { | 6072 if (*reinterpret_cast<int*>(data) > slack) { |
6073 *reinterpret_cast<int*>(data) = slack; | 6073 *reinterpret_cast<int*>(data) = slack; |
6074 } | 6074 } |
(...skipping 11 matching lines...) Expand all Loading... |
6086 } | 6086 } |
6087 | 6087 |
6088 | 6088 |
6089 void SharedFunctionInfo::CompleteInobjectSlackTracking() { | 6089 void SharedFunctionInfo::CompleteInobjectSlackTracking() { |
6090 ASSERT(live_objects_may_exist() && IsInobjectSlackTrackingInProgress()); | 6090 ASSERT(live_objects_may_exist() && IsInobjectSlackTrackingInProgress()); |
6091 Map* map = Map::cast(initial_map()); | 6091 Map* map = Map::cast(initial_map()); |
6092 | 6092 |
6093 Heap* heap = map->heap(); | 6093 Heap* heap = map->heap(); |
6094 set_initial_map(heap->undefined_value()); | 6094 set_initial_map(heap->undefined_value()); |
6095 Builtins* builtins = heap->isolate()->builtins(); | 6095 Builtins* builtins = heap->isolate()->builtins(); |
6096 ASSERT_EQ(builtins->builtin(Builtins::JSConstructStubCountdown), | 6096 ASSERT_EQ(builtins->builtin(Builtins::kJSConstructStubCountdown), |
6097 construct_stub()); | 6097 construct_stub()); |
6098 set_construct_stub(builtins->builtin(Builtins::JSConstructStubGeneric)); | 6098 set_construct_stub(builtins->builtin(Builtins::kJSConstructStubGeneric)); |
6099 | 6099 |
6100 int slack = map->unused_property_fields(); | 6100 int slack = map->unused_property_fields(); |
6101 map->TraverseTransitionTree(&GetMinInobjectSlack, &slack); | 6101 map->TraverseTransitionTree(&GetMinInobjectSlack, &slack); |
6102 if (slack != 0) { | 6102 if (slack != 0) { |
6103 // Resize the initial map and all maps in its transition tree. | 6103 // Resize the initial map and all maps in its transition tree. |
6104 map->TraverseTransitionTree(&ShrinkInstanceSize, &slack); | 6104 map->TraverseTransitionTree(&ShrinkInstanceSize, &slack); |
6105 // Give the correct expected_nof_properties to initial maps created later. | 6105 // Give the correct expected_nof_properties to initial maps created later. |
6106 ASSERT(expected_nof_properties() >= slack); | 6106 ASSERT(expected_nof_properties() >= slack); |
6107 set_expected_nof_properties(expected_nof_properties() - slack); | 6107 set_expected_nof_properties(expected_nof_properties() - slack); |
6108 } | 6108 } |
(...skipping 4137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10246 if (break_point_objects()->IsUndefined()) return 0; | 10246 if (break_point_objects()->IsUndefined()) return 0; |
10247 // Single beak point. | 10247 // Single beak point. |
10248 if (!break_point_objects()->IsFixedArray()) return 1; | 10248 if (!break_point_objects()->IsFixedArray()) return 1; |
10249 // Multiple break points. | 10249 // Multiple break points. |
10250 return FixedArray::cast(break_point_objects())->length(); | 10250 return FixedArray::cast(break_point_objects())->length(); |
10251 } | 10251 } |
10252 #endif | 10252 #endif |
10253 | 10253 |
10254 | 10254 |
10255 } } // namespace v8::internal | 10255 } } // namespace v8::internal |
OLD | NEW |