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

Side by Side Diff: src/objects.cc

Issue 1670813005: Revert of Type Feedback Vector lives in the closure (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 10 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
« no previous file with comments | « src/objects.h ('k') | src/objects-debug.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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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/objects.h" 5 #include "src/objects.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <iomanip> 8 #include <iomanip>
9 #include <sstream> 9 #include <sstream>
10 10
(...skipping 12348 matching lines...) Expand 10 before | Expand all | Expand 10 after
12359 if (FLAG_trace_concurrent_recompilation) { 12359 if (FLAG_trace_concurrent_recompilation) {
12360 PrintF(" ** Marking "); 12360 PrintF(" ** Marking ");
12361 ShortPrint(); 12361 ShortPrint();
12362 PrintF(" for concurrent recompilation.\n"); 12362 PrintF(" for concurrent recompilation.\n");
12363 } 12363 }
12364 set_code_no_write_barrier( 12364 set_code_no_write_barrier(
12365 isolate->builtins()->builtin(Builtins::kCompileOptimizedConcurrent)); 12365 isolate->builtins()->builtin(Builtins::kCompileOptimizedConcurrent));
12366 // No write barrier required, since the builtin is part of the root set. 12366 // No write barrier required, since the builtin is part of the root set.
12367 } 12367 }
12368 12368
12369 // static
12370 Handle<LiteralsArray> SharedFunctionInfo::FindOrCreateLiterals(
12371 Handle<SharedFunctionInfo> shared, Handle<Context> native_context) {
12372 Isolate* isolate = shared->GetIsolate();
12373 CodeAndLiterals result =
12374 shared->SearchOptimizedCodeMap(*native_context, BailoutId::None());
12375 if (result.literals != nullptr) {
12376 return handle(result.literals, isolate);
12377 }
12378 Handle<TypeFeedbackVector> feedback_vector =
12379 TypeFeedbackVector::New(isolate, handle(shared->feedback_metadata()));
12380 Handle<LiteralsArray> literals = LiteralsArray::New(
12381 isolate, feedback_vector, shared->num_literals(), TENURED);
12382 AddLiteralsToOptimizedCodeMap(shared, native_context, literals);
12383 return literals;
12384 }
12385 12369
12386 void SharedFunctionInfo::AddSharedCodeToOptimizedCodeMap( 12370 void SharedFunctionInfo::AddSharedCodeToOptimizedCodeMap(
12387 Handle<SharedFunctionInfo> shared, Handle<Code> code) { 12371 Handle<SharedFunctionInfo> shared, Handle<Code> code) {
12388 Isolate* isolate = shared->GetIsolate(); 12372 Isolate* isolate = shared->GetIsolate();
12389 if (isolate->serializer_enabled()) return; 12373 if (isolate->serializer_enabled()) return;
12390 DCHECK(code->kind() == Code::OPTIMIZED_FUNCTION); 12374 DCHECK(code->kind() == Code::OPTIMIZED_FUNCTION);
12391 // Empty code maps are unsupported. 12375 // Empty code maps are unsupported.
12392 if (!shared->OptimizedCodeMapIsCleared()) { 12376 if (!shared->OptimizedCodeMapIsCleared()) {
12393 Handle<WeakCell> cell = isolate->factory()->NewWeakCell(code); 12377 Handle<WeakCell> cell = isolate->factory()->NewWeakCell(code);
12394 // A collection may have occured and cleared the optimized code map in the 12378 // A collection may have occured and cleared the optimized code map in the
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
12578 DCHECK(shrink_by <= code_map->length() - kEntriesStart); 12562 DCHECK(shrink_by <= code_map->length() - kEntriesStart);
12579 // Always trim even when array is cleared because of heap verifier. 12563 // Always trim even when array is cleared because of heap verifier.
12580 GetHeap()->RightTrimFixedArray<Heap::SEQUENTIAL_TO_SWEEPER>(code_map, 12564 GetHeap()->RightTrimFixedArray<Heap::SEQUENTIAL_TO_SWEEPER>(code_map,
12581 shrink_by); 12565 shrink_by);
12582 if (code_map->length() == kEntriesStart && 12566 if (code_map->length() == kEntriesStart &&
12583 WeakCell::cast(code_map->get(kSharedCodeIndex))->cleared()) { 12567 WeakCell::cast(code_map->get(kSharedCodeIndex))->cleared()) {
12584 ClearOptimizedCodeMap(); 12568 ClearOptimizedCodeMap();
12585 } 12569 }
12586 } 12570 }
12587 12571
12588 // static
12589 void JSFunction::EnsureLiterals(Handle<JSFunction> function) {
12590 Handle<SharedFunctionInfo> shared(function->shared());
12591 Handle<Context> native_context(function->context()->native_context());
12592 Handle<LiteralsArray> literals =
12593 SharedFunctionInfo::FindOrCreateLiterals(shared, native_context);
12594 function->set_literals(*literals);
12595 }
12596 12572
12597 static void GetMinInobjectSlack(Map* map, void* data) { 12573 static void GetMinInobjectSlack(Map* map, void* data) {
12598 int slack = map->unused_property_fields(); 12574 int slack = map->unused_property_fields();
12599 if (*reinterpret_cast<int*>(data) > slack) { 12575 if (*reinterpret_cast<int*>(data) > slack) {
12600 *reinterpret_cast<int*>(data) = slack; 12576 *reinterpret_cast<int*>(data) = slack;
12601 } 12577 }
12602 } 12578 }
12603 12579
12604 12580
12605 static void ShrinkInstanceSize(Map* map, void* data) { 12581 static void ShrinkInstanceSize(Map* map, void* data) {
(...skipping 1257 matching lines...) Expand 10 before | Expand all | Expand 10 after
13863 if (isolate->serializer_enabled()) return; 13839 if (isolate->serializer_enabled()) return;
13864 13840
13865 if (unused_property_fields() == 0) return; 13841 if (unused_property_fields() == 0) return;
13866 13842
13867 set_construction_counter(Map::kSlackTrackingCounterStart); 13843 set_construction_counter(Map::kSlackTrackingCounterStart);
13868 } 13844 }
13869 13845
13870 13846
13871 void SharedFunctionInfo::ResetForNewContext(int new_ic_age) { 13847 void SharedFunctionInfo::ResetForNewContext(int new_ic_age) {
13872 code()->ClearInlineCaches(); 13848 code()->ClearInlineCaches();
13849 // If we clear ICs, we need to clear the type feedback vector too, since
13850 // CallICs are synced with a feedback vector slot.
13851 ClearTypeFeedbackInfo();
13873 set_ic_age(new_ic_age); 13852 set_ic_age(new_ic_age);
13874 if (code()->kind() == Code::FUNCTION) { 13853 if (code()->kind() == Code::FUNCTION) {
13875 code()->set_profiler_ticks(0); 13854 code()->set_profiler_ticks(0);
13876 if (optimization_disabled() && 13855 if (optimization_disabled() &&
13877 opt_count() >= FLAG_max_opt_count) { 13856 opt_count() >= FLAG_max_opt_count) {
13878 // Re-enable optimizations if they were disabled due to opt_count limit. 13857 // Re-enable optimizations if they were disabled due to opt_count limit.
13879 set_optimization_disabled(false); 13858 set_optimization_disabled(false);
13880 } 13859 }
13881 set_opt_count(0); 13860 set_opt_count(0);
13882 set_deopt_count(0); 13861 set_deopt_count(0);
(...skipping 18 matching lines...) Expand all
13901 } 13880 }
13902 Object* shared_code = 13881 Object* shared_code =
13903 WeakCell::cast(optimized_code_map->get(kSharedCodeIndex))->value(); 13882 WeakCell::cast(optimized_code_map->get(kSharedCodeIndex))->value();
13904 if (shared_code->IsCode() && osr_ast_id.IsNone()) { 13883 if (shared_code->IsCode() && osr_ast_id.IsNone()) {
13905 return kSharedCodeIndex; 13884 return kSharedCodeIndex;
13906 } 13885 }
13907 } 13886 }
13908 return -1; 13887 return -1;
13909 } 13888 }
13910 13889
13911 void SharedFunctionInfo::ClearCodeFromOptimizedCodeMap() {
13912 if (!OptimizedCodeMapIsCleared()) {
13913 FixedArray* optimized_code_map = this->optimized_code_map();
13914 int length = optimized_code_map->length();
13915 WeakCell* empty_weak_cell = GetHeap()->empty_weak_cell();
13916 for (int i = kEntriesStart; i < length; i += kEntryLength) {
13917 optimized_code_map->set(i + kCachedCodeOffset, empty_weak_cell,
13918 SKIP_WRITE_BARRIER);
13919 }
13920 optimized_code_map->set(kSharedCodeIndex, empty_weak_cell,
13921 SKIP_WRITE_BARRIER);
13922 }
13923 }
13924 13890
13925 CodeAndLiterals SharedFunctionInfo::SearchOptimizedCodeMap( 13891 CodeAndLiterals SharedFunctionInfo::SearchOptimizedCodeMap(
13926 Context* native_context, BailoutId osr_ast_id) { 13892 Context* native_context, BailoutId osr_ast_id) {
13927 CodeAndLiterals result = {nullptr, nullptr}; 13893 CodeAndLiterals result = {nullptr, nullptr};
13928 int entry = SearchOptimizedCodeMapEntry(native_context, osr_ast_id); 13894 int entry = SearchOptimizedCodeMapEntry(native_context, osr_ast_id);
13929 if (entry != kNotFound) { 13895 if (entry != kNotFound) {
13930 FixedArray* code_map = optimized_code_map(); 13896 FixedArray* code_map = optimized_code_map();
13931 if (entry == kSharedCodeIndex) { 13897 if (entry == kSharedCodeIndex) {
13932 // We know the weak cell isn't cleared because we made sure of it in 13898 // We know the weak cell isn't cleared because we made sure of it in
13933 // SearchOptimizedCodeMapEntry and performed no allocations since that 13899 // SearchOptimizedCodeMapEntry and performed no allocations since that
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
14357 } 14323 }
14358 } 14324 }
14359 } 14325 }
14360 } 14326 }
14361 14327
14362 int AbstractCode::SourcePosition(int offset) { 14328 int AbstractCode::SourcePosition(int offset) {
14363 if (IsBytecodeArray()) return GetBytecodeArray()->SourcePosition(offset); 14329 if (IsBytecodeArray()) return GetBytecodeArray()->SourcePosition(offset);
14364 return GetCode()->SourcePosition(offset); 14330 return GetCode()->SourcePosition(offset);
14365 } 14331 }
14366 14332
14367 void JSFunction::ClearTypeFeedbackInfo() { 14333 void SharedFunctionInfo::ClearTypeFeedbackInfo() {
14368 feedback_vector()->ClearSlots(shared()); 14334 feedback_vector()->ClearSlots(this);
14369 }
14370
14371 void JSFunction::ClearTypeFeedbackInfoAtGCTime() {
14372 feedback_vector()->ClearSlotsAtGCTime(shared());
14373 } 14335 }
14374 14336
14375 14337
14338 void SharedFunctionInfo::ClearTypeFeedbackInfoAtGCTime() {
14339 feedback_vector()->ClearSlotsAtGCTime(this);
14340 }
14341
14342
14376 BailoutId Code::TranslatePcOffsetToAstId(uint32_t pc_offset) { 14343 BailoutId Code::TranslatePcOffsetToAstId(uint32_t pc_offset) {
14377 DisallowHeapAllocation no_gc; 14344 DisallowHeapAllocation no_gc;
14378 DCHECK(kind() == FUNCTION); 14345 DCHECK(kind() == FUNCTION);
14379 BackEdgeTable back_edges(this, &no_gc); 14346 BackEdgeTable back_edges(this, &no_gc);
14380 for (uint32_t i = 0; i < back_edges.length(); i++) { 14347 for (uint32_t i = 0; i < back_edges.length(); i++) {
14381 if (back_edges.pc_offset(i) == pc_offset) return back_edges.ast_id(i); 14348 if (back_edges.pc_offset(i) == pc_offset) return back_edges.ast_id(i);
14382 } 14349 }
14383 return BailoutId::None(); 14350 return BailoutId::None();
14384 } 14351 }
14385 14352
(...skipping 5426 matching lines...) Expand 10 before | Expand all | Expand 10 after
19812 if (cell->value() != *new_value) { 19779 if (cell->value() != *new_value) {
19813 cell->set_value(*new_value); 19780 cell->set_value(*new_value);
19814 Isolate* isolate = cell->GetIsolate(); 19781 Isolate* isolate = cell->GetIsolate();
19815 cell->dependent_code()->DeoptimizeDependentCodeGroup( 19782 cell->dependent_code()->DeoptimizeDependentCodeGroup(
19816 isolate, DependentCode::kPropertyCellChangedGroup); 19783 isolate, DependentCode::kPropertyCellChangedGroup);
19817 } 19784 }
19818 } 19785 }
19819 19786
19820 } // namespace internal 19787 } // namespace internal
19821 } // namespace v8 19788 } // namespace v8
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/objects-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698