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

Side by Side Diff: src/ia32/lithium-codegen-ia32.cc

Issue 20843012: Extract hardcoded error strings into a single place and replace them with enum. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: styles fixed Created 7 years, 4 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 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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 RegisterDependentCodeForEmbeddedMaps(code); 106 RegisterDependentCodeForEmbeddedMaps(code);
107 } 107 }
108 PopulateDeoptimizationData(code); 108 PopulateDeoptimizationData(code);
109 if (!info()->IsStub()) { 109 if (!info()->IsStub()) {
110 Deoptimizer::EnsureRelocSpaceForLazyDeoptimization(code); 110 Deoptimizer::EnsureRelocSpaceForLazyDeoptimization(code);
111 } 111 }
112 info()->CommitDependencies(code); 112 info()->CommitDependencies(code);
113 } 113 }
114 114
115 115
116 void LCodeGen::Abort(const char* reason) { 116 void LCodeGen::Abort(BailoutReason reason) {
117 info()->set_bailout_reason(reason); 117 info()->set_bailout_reason(reason);
118 status_ = ABORTED; 118 status_ = ABORTED;
119 } 119 }
120 120
121 121
122 void LCodeGen::Comment(const char* format, ...) { 122 void LCodeGen::Comment(const char* format, ...) {
123 if (!FLAG_code_comments) return; 123 if (!FLAG_code_comments) return;
124 char buffer[4 * KB]; 124 char buffer[4 * KB];
125 StringBuilder builder(buffer, ARRAY_SIZE(buffer)); 125 StringBuilder builder(buffer, ARRAY_SIZE(buffer));
126 va_list arguments; 126 va_list arguments;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 __ push(Immediate(Smi::FromInt(StackFrame::STUB))); 203 __ push(Immediate(Smi::FromInt(StackFrame::STUB)));
204 } else { 204 } else {
205 __ push(edi); // Callee's JS function. 205 __ push(edi); // Callee's JS function.
206 } 206 }
207 } 207 }
208 208
209 if (info()->IsOptimizing() && 209 if (info()->IsOptimizing() &&
210 dynamic_frame_alignment_ && 210 dynamic_frame_alignment_ &&
211 FLAG_debug_code) { 211 FLAG_debug_code) {
212 __ test(esp, Immediate(kPointerSize)); 212 __ test(esp, Immediate(kPointerSize));
213 __ Assert(zero, "frame is expected to be aligned"); 213 __ Assert(zero, kFrameIsExpectedToBeAligned);
214 } 214 }
215 215
216 // Reserve space for the stack slots needed by the code. 216 // Reserve space for the stack slots needed by the code.
217 int slots = GetStackSlotCount(); 217 int slots = GetStackSlotCount();
218 ASSERT(slots != 0 || !info()->IsOptimizing()); 218 ASSERT(slots != 0 || !info()->IsOptimizing());
219 if (slots > 0) { 219 if (slots > 0) {
220 if (slots == 1) { 220 if (slots == 1) {
221 if (dynamic_frame_alignment_) { 221 if (dynamic_frame_alignment_) {
222 __ push(edx); 222 __ push(edx);
223 } else { 223 } else {
(...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after
936 void LCodeGen::DeoptimizeIf(Condition cc, 936 void LCodeGen::DeoptimizeIf(Condition cc,
937 LEnvironment* environment, 937 LEnvironment* environment,
938 Deoptimizer::BailoutType bailout_type) { 938 Deoptimizer::BailoutType bailout_type) {
939 RegisterEnvironmentForDeoptimization(environment, Safepoint::kNoLazyDeopt); 939 RegisterEnvironmentForDeoptimization(environment, Safepoint::kNoLazyDeopt);
940 ASSERT(environment->HasBeenRegistered()); 940 ASSERT(environment->HasBeenRegistered());
941 int id = environment->deoptimization_index(); 941 int id = environment->deoptimization_index();
942 ASSERT(info()->IsOptimizing() || info()->IsStub()); 942 ASSERT(info()->IsOptimizing() || info()->IsStub());
943 Address entry = 943 Address entry =
944 Deoptimizer::GetDeoptimizationEntry(isolate(), id, bailout_type); 944 Deoptimizer::GetDeoptimizationEntry(isolate(), id, bailout_type);
945 if (entry == NULL) { 945 if (entry == NULL) {
946 Abort("bailout was not prepared"); 946 Abort(kBailoutWasNotPrepared);
947 return; 947 return;
948 } 948 }
949 949
950 if (FLAG_deopt_every_n_times != 0 && !info()->IsStub()) { 950 if (FLAG_deopt_every_n_times != 0 && !info()->IsStub()) {
951 ExternalReference count = ExternalReference::stress_deopt_count(isolate()); 951 ExternalReference count = ExternalReference::stress_deopt_count(isolate());
952 Label no_deopt; 952 Label no_deopt;
953 __ pushfd(); 953 __ pushfd();
954 __ push(eax); 954 __ push(eax);
955 __ mov(eax, Operand::StaticVariable(count)); 955 __ mov(eax, Operand::StaticVariable(count));
956 __ sub(eax, Immediate(1)); 956 __ sub(eax, Immediate(1));
(...skipping 1007 matching lines...) Expand 10 before | Expand all | Expand 10 after
1964 if (FLAG_debug_code) { 1964 if (FLAG_debug_code) {
1965 __ push(value); 1965 __ push(value);
1966 __ mov(value, FieldOperand(string, HeapObject::kMapOffset)); 1966 __ mov(value, FieldOperand(string, HeapObject::kMapOffset));
1967 __ movzx_b(value, FieldOperand(value, Map::kInstanceTypeOffset)); 1967 __ movzx_b(value, FieldOperand(value, Map::kInstanceTypeOffset));
1968 1968
1969 __ and_(value, Immediate(kStringRepresentationMask | kStringEncodingMask)); 1969 __ and_(value, Immediate(kStringRepresentationMask | kStringEncodingMask));
1970 static const uint32_t one_byte_seq_type = kSeqStringTag | kOneByteStringTag; 1970 static const uint32_t one_byte_seq_type = kSeqStringTag | kOneByteStringTag;
1971 static const uint32_t two_byte_seq_type = kSeqStringTag | kTwoByteStringTag; 1971 static const uint32_t two_byte_seq_type = kSeqStringTag | kTwoByteStringTag;
1972 __ cmp(value, Immediate(encoding == String::ONE_BYTE_ENCODING 1972 __ cmp(value, Immediate(encoding == String::ONE_BYTE_ENCODING
1973 ? one_byte_seq_type : two_byte_seq_type)); 1973 ? one_byte_seq_type : two_byte_seq_type));
1974 __ Check(equal, "Unexpected string type"); 1974 __ Check(equal, kUnexpectedStringType);
1975 __ pop(value); 1975 __ pop(value);
1976 } 1976 }
1977 1977
1978 if (encoding == String::ONE_BYTE_ENCODING) { 1978 if (encoding == String::ONE_BYTE_ENCODING) {
1979 __ mov_b(FieldOperand(string, index, times_1, SeqString::kHeaderSize), 1979 __ mov_b(FieldOperand(string, index, times_1, SeqString::kHeaderSize),
1980 value); 1980 value);
1981 } else { 1981 } else {
1982 __ mov_w(FieldOperand(string, index, times_2, SeqString::kHeaderSize), 1982 __ mov_w(FieldOperand(string, index, times_2, SeqString::kHeaderSize),
1983 value); 1983 value);
1984 } 1984 }
(...skipping 866 matching lines...) Expand 10 before | Expand all | Expand 10 after
2851 2851
2852 void LCodeGen::EmitReturn(LReturn* instr, bool dynamic_frame_alignment) { 2852 void LCodeGen::EmitReturn(LReturn* instr, bool dynamic_frame_alignment) {
2853 int extra_value_count = dynamic_frame_alignment ? 2 : 1; 2853 int extra_value_count = dynamic_frame_alignment ? 2 : 1;
2854 2854
2855 if (instr->has_constant_parameter_count()) { 2855 if (instr->has_constant_parameter_count()) {
2856 int parameter_count = ToInteger32(instr->constant_parameter_count()); 2856 int parameter_count = ToInteger32(instr->constant_parameter_count());
2857 if (dynamic_frame_alignment && FLAG_debug_code) { 2857 if (dynamic_frame_alignment && FLAG_debug_code) {
2858 __ cmp(Operand(esp, 2858 __ cmp(Operand(esp,
2859 (parameter_count + extra_value_count) * kPointerSize), 2859 (parameter_count + extra_value_count) * kPointerSize),
2860 Immediate(kAlignmentZapValue)); 2860 Immediate(kAlignmentZapValue));
2861 __ Assert(equal, "expected alignment marker"); 2861 __ Assert(equal, kExpectedAlignmentMarker);
2862 } 2862 }
2863 __ Ret((parameter_count + extra_value_count) * kPointerSize, ecx); 2863 __ Ret((parameter_count + extra_value_count) * kPointerSize, ecx);
2864 } else { 2864 } else {
2865 Register reg = ToRegister(instr->parameter_count()); 2865 Register reg = ToRegister(instr->parameter_count());
2866 // The argument count parameter is a smi 2866 // The argument count parameter is a smi
2867 __ SmiUntag(reg); 2867 __ SmiUntag(reg);
2868 Register return_addr_reg = reg.is(ecx) ? ebx : ecx; 2868 Register return_addr_reg = reg.is(ecx) ? ebx : ecx;
2869 if (dynamic_frame_alignment && FLAG_debug_code) { 2869 if (dynamic_frame_alignment && FLAG_debug_code) {
2870 ASSERT(extra_value_count == 2); 2870 ASSERT(extra_value_count == 2);
2871 __ cmp(Operand(esp, reg, times_pointer_size, 2871 __ cmp(Operand(esp, reg, times_pointer_size,
2872 extra_value_count * kPointerSize), 2872 extra_value_count * kPointerSize),
2873 Immediate(kAlignmentZapValue)); 2873 Immediate(kAlignmentZapValue));
2874 __ Assert(equal, "expected alignment marker"); 2874 __ Assert(equal, kExpectedAlignmentMarker);
2875 } 2875 }
2876 2876
2877 // emit code to restore stack based on instr->parameter_count() 2877 // emit code to restore stack based on instr->parameter_count()
2878 __ pop(return_addr_reg); // save return address 2878 __ pop(return_addr_reg); // save return address
2879 if (dynamic_frame_alignment) { 2879 if (dynamic_frame_alignment) {
2880 __ inc(reg); // 1 more for alignment 2880 __ inc(reg); // 1 more for alignment
2881 } 2881 }
2882 __ shl(reg, kPointerSizeLog2); 2882 __ shl(reg, kPointerSizeLog2);
2883 __ add(esp, reg); 2883 __ add(esp, reg);
2884 __ jmp(return_addr_reg); 2884 __ jmp(return_addr_reg);
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after
3435 Representation key_representation, 3435 Representation key_representation,
3436 ElementsKind elements_kind, 3436 ElementsKind elements_kind,
3437 uint32_t offset, 3437 uint32_t offset,
3438 uint32_t additional_index) { 3438 uint32_t additional_index) {
3439 Register elements_pointer_reg = ToRegister(elements_pointer); 3439 Register elements_pointer_reg = ToRegister(elements_pointer);
3440 int element_shift_size = ElementsKindToShiftSize(elements_kind); 3440 int element_shift_size = ElementsKindToShiftSize(elements_kind);
3441 int shift_size = element_shift_size; 3441 int shift_size = element_shift_size;
3442 if (key->IsConstantOperand()) { 3442 if (key->IsConstantOperand()) {
3443 int constant_value = ToInteger32(LConstantOperand::cast(key)); 3443 int constant_value = ToInteger32(LConstantOperand::cast(key));
3444 if (constant_value & 0xF0000000) { 3444 if (constant_value & 0xF0000000) {
3445 Abort("array index constant value too big"); 3445 Abort(kArrayIndexConstantValueTooBig);
3446 } 3446 }
3447 return Operand(elements_pointer_reg, 3447 return Operand(elements_pointer_reg,
3448 ((constant_value + additional_index) << shift_size) 3448 ((constant_value + additional_index) << shift_size)
3449 + offset); 3449 + offset);
3450 } else { 3450 } else {
3451 // Take the tag bit into account while computing the shift size. 3451 // Take the tag bit into account while computing the shift size.
3452 if (key_representation.IsSmi() && (shift_size >= 1)) { 3452 if (key_representation.IsSmi() && (shift_size >= 1)) {
3453 shift_size -= kSmiTagSize; 3453 shift_size -= kSmiTagSize;
3454 } 3454 }
3455 ScaleFactor scale_factor = static_cast<ScaleFactor>(shift_size); 3455 ScaleFactor scale_factor = static_cast<ScaleFactor>(shift_size);
(...skipping 3050 matching lines...) Expand 10 before | Expand all | Expand 10 after
6506 FixedArray::kHeaderSize - kPointerSize)); 6506 FixedArray::kHeaderSize - kPointerSize));
6507 __ bind(&done); 6507 __ bind(&done);
6508 } 6508 }
6509 6509
6510 6510
6511 #undef __ 6511 #undef __
6512 6512
6513 } } // namespace v8::internal 6513 } } // namespace v8::internal
6514 6514
6515 #endif // V8_TARGET_ARCH_IA32 6515 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« src/compiler.cc ('K') | « src/ia32/lithium-codegen-ia32.h ('k') | src/ia32/lithium-ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698