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

Side by Side Diff: src/objects.cc

Issue 159783002: Re-optimize faster after making a pretenuring decision. Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 9889 matching lines...) Expand 10 before | Expand all | Expand 10 after
9900 return true; 9900 return true;
9901 } 9901 }
9902 if (filter[filter.length() - 1] == '*' && 9902 if (filter[filter.length() - 1] == '*' &&
9903 name->IsUtf8EqualTo(filter.SubVector(0, filter.length() - 1), true)) { 9903 name->IsUtf8EqualTo(filter.SubVector(0, filter.length() - 1), true)) {
9904 return true; 9904 return true;
9905 } 9905 }
9906 return false; 9906 return false;
9907 } 9907 }
9908 9908
9909 9909
9910 void JSFunction::Optimize(const char* reason) {
titzer 2014/02/18 09:24:48 Looks like you copied this right out of the compil
Hannes Payer (out of office) 2014/05/12 09:37:08 This code was part of runtime-profiler. It should
9911 ASSERT(IsOptimizable());
9912
9913 if (FLAG_trace_opt && PassesFilter(FLAG_hydrogen_filter)) {
9914 PrintF("[marking ");
9915 ShortPrint();
9916 PrintF(" for recompilation, reason: %s", reason);
9917 if (FLAG_type_info_threshold > 0) {
9918 int typeinfo, total, percentage;
9919 Code* code = shared()->code();
9920 code->GetICCounts(&typeinfo, &total, &percentage);
9921 PrintF(", ICs with typeinfo: %d/%d (%d%%)", typeinfo, total, percentage);
9922 }
9923 PrintF("]\n");
9924 }
9925
9926 Isolate* isolate = GetIsolate();
9927
9928 if (isolate->concurrent_recompilation_enabled() &&
9929 !isolate->bootstrapper()->IsActive()) {
9930 if (isolate->concurrent_osr_enabled() &&
9931 isolate->optimizing_compiler_thread()->IsQueuedForOSR(this)) {
9932 // Do not attempt regular recompilation if we already queued this for OSR.
9933 // TODO(yangguo): This is necessary so that we don't install optimized
9934 // code on a function that is already optimized, since OSR and regular
9935 // recompilation race. This goes away as soon as OSR becomes one-shot.
9936 return;
9937 }
9938 ASSERT(!IsInOptimizationQueue());
9939 MarkForConcurrentOptimization();
9940 } else {
9941 // The next call to the function will trigger optimization.
9942 MarkForOptimization();
9943 }
9944 }
9945
9946
9910 MaybeObject* Oddball::Initialize(Heap* heap, 9947 MaybeObject* Oddball::Initialize(Heap* heap,
9911 const char* to_string, 9948 const char* to_string,
9912 Object* to_number, 9949 Object* to_number,
9913 byte kind) { 9950 byte kind) {
9914 String* internalized_to_string; 9951 String* internalized_to_string;
9915 { MaybeObject* maybe_string = 9952 { MaybeObject* maybe_string =
9916 heap->InternalizeUtf8String( 9953 heap->InternalizeUtf8String(
9917 CStrVector(to_string)); 9954 CStrVector(to_string));
9918 if (!maybe_string->To(&internalized_to_string)) return maybe_string; 9955 if (!maybe_string->To(&internalized_to_string)) return maybe_string;
9919 } 9956 }
(...skipping 1341 matching lines...) Expand 10 before | Expand all | Expand 10 after
11261 GetElementsKind(), new_elements); 11298 GetElementsKind(), new_elements);
11262 } 11299 }
11263 11300
11264 if (IsJSArray()) { 11301 if (IsJSArray()) {
11265 JSArray::cast(this)->set_length(Smi::FromInt(length)); 11302 JSArray::cast(this)->set_length(Smi::FromInt(length));
11266 } 11303 }
11267 return new_elements; 11304 return new_elements;
11268 } 11305 }
11269 11306
11270 11307
11308 void Code::GetICCounts(int* ic_with_type_info_count,
11309 int* ic_total_count,
11310 int* percentage) {
11311 *ic_total_count = 0;
11312 *ic_with_type_info_count = 0;
11313 Object* raw_info = type_feedback_info();
11314 if (raw_info->IsTypeFeedbackInfo()) {
11315 TypeFeedbackInfo* info = TypeFeedbackInfo::cast(raw_info);
11316 *ic_with_type_info_count = info->ic_with_type_info_count();
11317 *ic_total_count = info->ic_total_count();
11318 }
11319 *percentage = *ic_total_count > 0
11320 ? 100 * *ic_with_type_info_count / *ic_total_count
11321 : 100;
11322 }
11323
11324
11271 bool Code::IsWeakEmbeddedObject(Kind kind, Object* object) { 11325 bool Code::IsWeakEmbeddedObject(Kind kind, Object* object) {
11272 if (kind != Code::OPTIMIZED_FUNCTION) return false; 11326 if (kind != Code::OPTIMIZED_FUNCTION) return false;
11273 11327
11274 if (object->IsMap()) { 11328 if (object->IsMap()) {
11275 return Map::cast(object)->CanTransition() && 11329 return Map::cast(object)->CanTransition() &&
11276 FLAG_collect_maps && 11330 FLAG_collect_maps &&
11277 FLAG_weak_embedded_maps_in_optimized_code; 11331 FLAG_weak_embedded_maps_in_optimized_code;
11278 } 11332 }
11279 11333
11280 if (object->IsJSObject() || 11334 if (object->IsJSObject() ||
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after
11746 int end = starts.at(group + 1); 11800 int end = starts.at(group + 1);
11747 for (int i = start; i < end; i++) { 11801 for (int i = start; i < end; i++) {
11748 if (object_at(i) == code) return true; 11802 if (object_at(i) == code) return true;
11749 } 11803 }
11750 return false; 11804 return false;
11751 } 11805 }
11752 11806
11753 11807
11754 bool DependentCode::MarkCodeForDeoptimization( 11808 bool DependentCode::MarkCodeForDeoptimization(
11755 Isolate* isolate, 11809 Isolate* isolate,
11756 DependentCode::DependencyGroup group) { 11810 DependentCode::DependencyGroup group,
11811 bool reoptimize) {
11757 DisallowHeapAllocation no_allocation_scope; 11812 DisallowHeapAllocation no_allocation_scope;
11758 DependentCode::GroupStartIndexes starts(this); 11813 DependentCode::GroupStartIndexes starts(this);
11759 int start = starts.at(group); 11814 int start = starts.at(group);
11760 int end = starts.at(group + 1); 11815 int end = starts.at(group + 1);
11761 int code_entries = starts.number_of_entries(); 11816 int code_entries = starts.number_of_entries();
11762 if (start == end) return false; 11817 if (start == end) return false;
11763 11818
11764 // Mark all the code that needs to be deoptimized. 11819 // Mark all the code that needs to be deoptimized.
11765 bool marked = false; 11820 bool marked = false;
11766 for (int i = start; i < end; i++) { 11821 for (int i = start; i < end; i++) {
11767 if (is_code_at(i)) { 11822 if (is_code_at(i)) {
11768 Code* code = code_at(i); 11823 Code* code = code_at(i);
11769 if (!code->marked_for_deoptimization()) { 11824 if (!code->marked_for_deoptimization()) {
11770 code->set_marked_for_deoptimization(true); 11825 code->set_marked_for_deoptimization(true);
11771 marked = true; 11826 marked = true;
11827 if (reoptimize) code->set_marked_for_reoptimization(true);
11772 } 11828 }
11773 } else { 11829 } else {
11774 CompilationInfo* info = compilation_info_at(i); 11830 CompilationInfo* info = compilation_info_at(i);
11775 info->AbortDueToDependencyChange(); 11831 info->AbortDueToDependencyChange();
11776 } 11832 }
11777 } 11833 }
11778 // Compact the array by moving all subsequent groups to fill in the new holes. 11834 // Compact the array by moving all subsequent groups to fill in the new holes.
11779 for (int src = end, dst = start; src < code_entries; src++, dst++) { 11835 for (int src = end, dst = start; src < code_entries; src++, dst++) {
11780 copy(src, dst); 11836 copy(src, dst);
11781 } 11837 }
(...skipping 950 matching lines...) Expand 10 before | Expand all | Expand 10 after
12732 } 12788 }
12733 12789
12734 12790
12735 void JSObject::TransitionElementsKind(Handle<JSObject> object, 12791 void JSObject::TransitionElementsKind(Handle<JSObject> object,
12736 ElementsKind to_kind) { 12792 ElementsKind to_kind) {
12737 CALL_HEAP_FUNCTION_VOID(object->GetIsolate(), 12793 CALL_HEAP_FUNCTION_VOID(object->GetIsolate(),
12738 object->TransitionElementsKind(to_kind)); 12794 object->TransitionElementsKind(to_kind));
12739 } 12795 }
12740 12796
12741 12797
12742 const double AllocationSite::kPretenureRatio = 0.60; 12798 const double AllocationSite::kPretenureRatio = 0.50;
12743 12799
12744 12800
12745 void AllocationSite::ResetPretenureDecision() { 12801 void AllocationSite::ResetPretenureDecision() {
12746 set_pretenure_decision(kUndecided); 12802 set_pretenure_decision(kUndecided);
12747 set_memento_found_count(0); 12803 set_memento_found_count(0);
12748 set_memento_create_count(0); 12804 set_memento_create_count(0);
12749 } 12805 }
12750 12806
12751 12807
12752 PretenureFlag AllocationSite::GetPretenureMode() { 12808 PretenureFlag AllocationSite::GetPretenureMode() {
(...skipping 3744 matching lines...) Expand 10 before | Expand all | Expand 10 after
16497 #define ERROR_MESSAGES_TEXTS(C, T) T, 16553 #define ERROR_MESSAGES_TEXTS(C, T) T,
16498 static const char* error_messages_[] = { 16554 static const char* error_messages_[] = {
16499 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) 16555 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS)
16500 }; 16556 };
16501 #undef ERROR_MESSAGES_TEXTS 16557 #undef ERROR_MESSAGES_TEXTS
16502 return error_messages_[reason]; 16558 return error_messages_[reason];
16503 } 16559 }
16504 16560
16505 16561
16506 } } // namespace v8::internal 16562 } } // namespace v8::internal
OLDNEW
« src/objects.h ('K') | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698