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

Side by Side Diff: src/x64/full-codegen-x64.cc

Issue 16128004: Reorder switch clauses using newly-introduced execution counters in (Closed) Base URL: gh:v8/v8.git@master
Patch Set: tweak heuristic Created 7 years, 6 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/typing.cc ('k') | src/x64/lithium-codegen-x64.h » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 1008 matching lines...) Expand 10 before | Expand all | Expand 10 after
1019 __ bind(&next_test); 1019 __ bind(&next_test);
1020 __ Drop(1); // Switch value is no longer needed. 1020 __ Drop(1); // Switch value is no longer needed.
1021 if (default_clause == NULL) { 1021 if (default_clause == NULL) {
1022 __ jmp(nested_statement.break_label()); 1022 __ jmp(nested_statement.break_label());
1023 } else { 1023 } else {
1024 __ jmp(default_clause->body_target()); 1024 __ jmp(default_clause->body_target());
1025 } 1025 }
1026 1026
1027 // Compile all the case bodies. 1027 // Compile all the case bodies.
1028 for (int i = 0; i < clauses->length(); i++) { 1028 for (int i = 0; i < clauses->length(); i++) {
1029 Comment cmnt(masm_, "[ Case body");
1030 CaseClause* clause = clauses->at(i); 1029 CaseClause* clause = clauses->at(i);
1031 __ bind(clause->body_target()); 1030 __ bind(clause->body_target());
1032 PrepareForBailoutForId(clause->EntryId(), NO_REGISTERS); 1031 PrepareForBailoutForId(clause->EntryId(), NO_REGISTERS);
1032
1033 // Initialize counter
1034 { Comment cmnt(masm_, "[ Case hit counter");
1035 Handle<JSGlobalPropertyCell> cell =
1036 isolate()->factory()->NewJSGlobalPropertyCell(
1037 Handle<Object>(Smi::FromInt(0), isolate()));
1038 RecordTypeFeedbackCell(clause->CounterId(), cell);
1039
1040 // Increment counter
1041 Label ok;
1042 Operand counter = FieldOperand(rbx, JSGlobalPropertyCell::kValueOffset);
1043
1044 __ LoadHeapObject(rbx, cell);
1045 __ movq(rcx, counter);
1046 __ AssertSmi(rcx);
1047 __ SmiAddConstant(rcx, rcx, Smi::FromInt(1));
1048 __ j(no_overflow, &ok, Label::kNear);
1049
1050 // Decrement on overflow
1051 __ SmiAddConstant(rcx, rcx, Smi::FromInt(-1));
1052 __ bind(&ok);
1053 __ movq(counter, rcx);
1054 }
1055
1056 Comment cmnt(masm_, "[ Case body");
1033 VisitStatements(clause->statements()); 1057 VisitStatements(clause->statements());
1034 } 1058 }
1035 1059
1036 __ bind(nested_statement.break_label()); 1060 __ bind(nested_statement.break_label());
1037 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); 1061 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS);
1038 } 1062 }
1039 1063
1040 1064
1041 void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) { 1065 void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) {
1042 Comment cmnt(masm_, "[ ForInStatement"); 1066 Comment cmnt(masm_, "[ ForInStatement");
(...skipping 3816 matching lines...) Expand 10 before | Expand all | Expand 10 after
4859 *context_length = 0; 4883 *context_length = 0;
4860 return previous_; 4884 return previous_;
4861 } 4885 }
4862 4886
4863 4887
4864 #undef __ 4888 #undef __
4865 4889
4866 } } // namespace v8::internal 4890 } } // namespace v8::internal
4867 4891
4868 #endif // V8_TARGET_ARCH_X64 4892 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/typing.cc ('k') | src/x64/lithium-codegen-x64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698