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

Side by Side Diff: src/ia32/code-stubs-ia32.h

Issue 6826032: Remove code from the deprecated GenericBinaryOpStub. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years, 8 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
« no previous file with comments | « src/debug.cc ('k') | src/ia32/code-stubs-ia32.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 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 ToBooleanStub() { } 65 ToBooleanStub() { }
66 66
67 void Generate(MacroAssembler* masm); 67 void Generate(MacroAssembler* masm);
68 68
69 private: 69 private:
70 Major MajorKey() { return ToBoolean; } 70 Major MajorKey() { return ToBoolean; }
71 int MinorKey() { return 0; } 71 int MinorKey() { return 0; }
72 }; 72 };
73 73
74 74
75 // Flag that indicates how to generate code for the stub GenericBinaryOpStub.
76 enum GenericBinaryFlags {
77 NO_GENERIC_BINARY_FLAGS = 0,
78 NO_SMI_CODE_IN_STUB = 1 << 0 // Omit smi code in stub.
79 };
80
81
82 class GenericBinaryOpStub: public CodeStub {
83 public:
84 GenericBinaryOpStub(Token::Value op,
85 OverwriteMode mode,
86 GenericBinaryFlags flags,
87 TypeInfo operands_type)
88 : op_(op),
89 mode_(mode),
90 flags_(flags),
91 args_in_registers_(false),
92 args_reversed_(false),
93 static_operands_type_(operands_type),
94 runtime_operands_type_(BinaryOpIC::UNINIT_OR_SMI),
95 name_(NULL) {
96 if (static_operands_type_.IsSmi()) {
97 mode_ = NO_OVERWRITE;
98 }
99 use_sse3_ = CpuFeatures::IsSupported(SSE3);
100 ASSERT(OpBits::is_valid(Token::NUM_TOKENS));
101 }
102
103 GenericBinaryOpStub(int key, BinaryOpIC::TypeInfo runtime_operands_type)
104 : op_(OpBits::decode(key)),
105 mode_(ModeBits::decode(key)),
106 flags_(FlagBits::decode(key)),
107 args_in_registers_(ArgsInRegistersBits::decode(key)),
108 args_reversed_(ArgsReversedBits::decode(key)),
109 use_sse3_(SSE3Bits::decode(key)),
110 static_operands_type_(TypeInfo::ExpandedRepresentation(
111 StaticTypeInfoBits::decode(key))),
112 runtime_operands_type_(runtime_operands_type),
113 name_(NULL) {
114 }
115
116 // Generate code to call the stub with the supplied arguments. This will add
117 // code at the call site to prepare arguments either in registers or on the
118 // stack together with the actual call.
119 void GenerateCall(MacroAssembler* masm, Register left, Register right);
120 void GenerateCall(MacroAssembler* masm, Register left, Smi* right);
121 void GenerateCall(MacroAssembler* masm, Smi* left, Register right);
122
123 bool ArgsInRegistersSupported() {
124 return op_ == Token::ADD || op_ == Token::SUB
125 || op_ == Token::MUL || op_ == Token::DIV;
126 }
127
128 void SetArgsInRegisters() {
129 ASSERT(ArgsInRegistersSupported());
130 args_in_registers_ = true;
131 }
132
133 private:
134 Token::Value op_;
135 OverwriteMode mode_;
136 GenericBinaryFlags flags_;
137 bool args_in_registers_; // Arguments passed in registers not on the stack.
138 bool args_reversed_; // Left and right argument are swapped.
139 bool use_sse3_;
140
141 // Number type information of operands, determined by code generator.
142 TypeInfo static_operands_type_;
143
144 // Operand type information determined at runtime.
145 BinaryOpIC::TypeInfo runtime_operands_type_;
146
147 char* name_;
148
149 const char* GetName();
150
151 #ifdef DEBUG
152 void Print() {
153 PrintF("GenericBinaryOpStub %d (op %s), "
154 "(mode %d, flags %d, registers %d, reversed %d, type_info %s)\n",
155 MinorKey(),
156 Token::String(op_),
157 static_cast<int>(mode_),
158 static_cast<int>(flags_),
159 static_cast<int>(args_in_registers_),
160 static_cast<int>(args_reversed_),
161 static_operands_type_.ToString());
162 }
163 #endif
164
165 // Minor key encoding in 18 bits RRNNNFRASOOOOOOOMM.
166 class ModeBits: public BitField<OverwriteMode, 0, 2> {};
167 class OpBits: public BitField<Token::Value, 2, 7> {};
168 class SSE3Bits: public BitField<bool, 9, 1> {};
169 class ArgsInRegistersBits: public BitField<bool, 10, 1> {};
170 class ArgsReversedBits: public BitField<bool, 11, 1> {};
171 class FlagBits: public BitField<GenericBinaryFlags, 12, 1> {};
172 class StaticTypeInfoBits: public BitField<int, 13, 3> {};
173 class RuntimeTypeInfoBits: public BitField<BinaryOpIC::TypeInfo, 16, 3> {};
174
175 Major MajorKey() { return GenericBinaryOp; }
176 int MinorKey() {
177 // Encode the parameters in a unique 18 bit value.
178 return OpBits::encode(op_)
179 | ModeBits::encode(mode_)
180 | FlagBits::encode(flags_)
181 | SSE3Bits::encode(use_sse3_)
182 | ArgsInRegistersBits::encode(args_in_registers_)
183 | ArgsReversedBits::encode(args_reversed_)
184 | StaticTypeInfoBits::encode(
185 static_operands_type_.ThreeBitRepresentation())
186 | RuntimeTypeInfoBits::encode(runtime_operands_type_);
187 }
188
189 void Generate(MacroAssembler* masm);
190 void GenerateSmiCode(MacroAssembler* masm, Label* slow);
191 void GenerateLoadArguments(MacroAssembler* masm);
192 void GenerateReturn(MacroAssembler* masm);
193 void GenerateHeapResultAllocation(MacroAssembler* masm, Label* alloc_failure);
194 void GenerateRegisterArgsPush(MacroAssembler* masm);
195 void GenerateTypeTransition(MacroAssembler* masm);
196
197 bool IsOperationCommutative() {
198 return (op_ == Token::ADD) || (op_ == Token::MUL);
199 }
200
201 void SetArgsReversed() { args_reversed_ = true; }
202 bool HasSmiCodeInStub() { return (flags_ & NO_SMI_CODE_IN_STUB) == 0; }
203 bool HasArgsInRegisters() { return args_in_registers_; }
204 bool HasArgsReversed() { return args_reversed_; }
205
206 bool ShouldGenerateSmiCode() {
207 return HasSmiCodeInStub() &&
208 runtime_operands_type_ != BinaryOpIC::HEAP_NUMBERS &&
209 runtime_operands_type_ != BinaryOpIC::STRINGS;
210 }
211
212 bool ShouldGenerateFPCode() {
213 return runtime_operands_type_ != BinaryOpIC::STRINGS;
214 }
215
216 virtual int GetCodeKind() { return Code::BINARY_OP_IC; }
217
218 virtual InlineCacheState GetICState() {
219 return BinaryOpIC::ToState(runtime_operands_type_);
220 }
221
222 virtual void FinishCode(Code* code) {
223 code->set_binary_op_type(runtime_operands_type_);
224 }
225
226 friend class CodeGenerator;
227 };
228
229
230 class TypeRecordingBinaryOpStub: public CodeStub { 75 class TypeRecordingBinaryOpStub: public CodeStub {
231 public: 76 public:
232 TypeRecordingBinaryOpStub(Token::Value op, OverwriteMode mode) 77 TypeRecordingBinaryOpStub(Token::Value op, OverwriteMode mode)
233 : op_(op), 78 : op_(op),
234 mode_(mode), 79 mode_(mode),
235 operands_type_(TRBinaryOpIC::UNINITIALIZED), 80 operands_type_(TRBinaryOpIC::UNINITIALIZED),
236 result_type_(TRBinaryOpIC::UNINITIALIZED), 81 result_type_(TRBinaryOpIC::UNINITIALIZED),
237 name_(NULL) { 82 name_(NULL) {
238 use_sse3_ = CpuFeatures::IsSupported(SSE3); 83 use_sse3_ = CpuFeatures::IsSupported(SSE3);
239 ASSERT(OpBits::is_valid(Token::NUM_TOKENS)); 84 ASSERT(OpBits::is_valid(Token::NUM_TOKENS));
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 #ifdef DEBUG 331 #ifdef DEBUG
487 void Print() { 332 void Print() {
488 PrintF("NumberToStringStub\n"); 333 PrintF("NumberToStringStub\n");
489 } 334 }
490 #endif 335 #endif
491 }; 336 };
492 337
493 } } // namespace v8::internal 338 } } // namespace v8::internal
494 339
495 #endif // V8_IA32_CODE_STUBS_IA32_H_ 340 #endif // V8_IA32_CODE_STUBS_IA32_H_
OLDNEW
« no previous file with comments | « src/debug.cc ('k') | src/ia32/code-stubs-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698