OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |