| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 | 90 |
| 91 // Finish the code by setting stack height, safepoint, and bailout | 91 // Finish the code by setting stack height, safepoint, and bailout |
| 92 // information on it. | 92 // information on it. |
| 93 void FinishCode(Handle<Code> code); | 93 void FinishCode(Handle<Code> code); |
| 94 | 94 |
| 95 // Deferred code support. | 95 // Deferred code support. |
| 96 void DoDeferredNumberTagD(LNumberTagD* instr); | 96 void DoDeferredNumberTagD(LNumberTagD* instr); |
| 97 void DoDeferredNumberTagI(LNumberTagI* instr); | 97 void DoDeferredNumberTagI(LNumberTagI* instr); |
| 98 void DoDeferredTaggedToI(LTaggedToI* instr); | 98 void DoDeferredTaggedToI(LTaggedToI* instr); |
| 99 void DoDeferredMathAbsTaggedHeapNumber(LUnaryMathOperation* instr); | 99 void DoDeferredMathAbsTaggedHeapNumber(LUnaryMathOperation* instr); |
| 100 void DoDeferredStackCheck(LGoto* instr); | 100 void DoDeferredStackCheck(LStackCheck* instr); |
| 101 void DoDeferredStringCharCodeAt(LStringCharCodeAt* instr); | 101 void DoDeferredStringCharCodeAt(LStringCharCodeAt* instr); |
| 102 void DoDeferredStringCharFromCode(LStringCharFromCode* instr); | 102 void DoDeferredStringCharFromCode(LStringCharFromCode* instr); |
| 103 void DoDeferredLInstanceOfKnownGlobal(LInstanceOfKnownGlobal* instr, | 103 void DoDeferredLInstanceOfKnownGlobal(LInstanceOfKnownGlobal* instr, |
| 104 Label* map_check); | 104 Label* map_check); |
| 105 | 105 |
| 106 // Parallel move support. | 106 // Parallel move support. |
| 107 void DoParallelMove(LParallelMove* move); | 107 void DoParallelMove(LParallelMove* move); |
| 108 void DoGap(LGap* instr); | 108 void DoGap(LGap* instr); |
| 109 | 109 |
| 110 // Emit frame translation commands for an environment. | 110 // Emit frame translation commands for an environment. |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 // Code generation passes. Returns true if code generation should | 159 // Code generation passes. Returns true if code generation should |
| 160 // continue. | 160 // continue. |
| 161 bool GeneratePrologue(); | 161 bool GeneratePrologue(); |
| 162 bool GenerateBody(); | 162 bool GenerateBody(); |
| 163 bool GenerateDeferredCode(); | 163 bool GenerateDeferredCode(); |
| 164 // Pad the reloc info to ensure that we have enough space to patch during | 164 // Pad the reloc info to ensure that we have enough space to patch during |
| 165 // deoptimization. | 165 // deoptimization. |
| 166 bool GenerateRelocPadding(); | 166 bool GenerateRelocPadding(); |
| 167 bool GenerateSafepointTable(); | 167 bool GenerateSafepointTable(); |
| 168 | 168 |
| 169 enum ContextMode { | |
| 170 RESTORE_CONTEXT, | |
| 171 CONTEXT_ADJUSTED | |
| 172 }; | |
| 173 | |
| 174 enum SafepointMode { | 169 enum SafepointMode { |
| 175 RECORD_SIMPLE_SAFEPOINT, | 170 RECORD_SIMPLE_SAFEPOINT, |
| 176 RECORD_SAFEPOINT_WITH_REGISTERS_AND_NO_ARGUMENTS | 171 RECORD_SAFEPOINT_WITH_REGISTERS_AND_NO_ARGUMENTS |
| 177 }; | 172 }; |
| 178 | 173 |
| 179 void CallCode(Handle<Code> code, | 174 void CallCode(Handle<Code> code, |
| 180 RelocInfo::Mode mode, | 175 RelocInfo::Mode mode, |
| 181 LInstruction* instr, | 176 LInstruction* instr); |
| 182 ContextMode context_mode); | |
| 183 | 177 |
| 184 void CallCodeGeneric(Handle<Code> code, | 178 void CallCodeGeneric(Handle<Code> code, |
| 185 RelocInfo::Mode mode, | 179 RelocInfo::Mode mode, |
| 186 LInstruction* instr, | 180 LInstruction* instr, |
| 187 ContextMode context_mode, | |
| 188 SafepointMode safepoint_mode); | 181 SafepointMode safepoint_mode); |
| 189 | 182 |
| 190 void CallRuntime(const Runtime::Function* fun, | 183 void CallRuntime(const Runtime::Function* fun, |
| 191 int argc, | 184 int argc, |
| 192 LInstruction* instr, | 185 LInstruction* instr); |
| 193 ContextMode context_mode); | |
| 194 | 186 |
| 195 void CallRuntime(Runtime::FunctionId id, | 187 void CallRuntime(Runtime::FunctionId id, |
| 196 int argc, | 188 int argc, |
| 197 LInstruction* instr, | 189 LInstruction* instr) { |
| 198 ContextMode context_mode) { | |
| 199 const Runtime::Function* function = Runtime::FunctionForId(id); | 190 const Runtime::Function* function = Runtime::FunctionForId(id); |
| 200 CallRuntime(function, argc, instr, context_mode); | 191 CallRuntime(function, argc, instr); |
| 201 } | 192 } |
| 202 | 193 |
| 203 void CallRuntimeFromDeferred(Runtime::FunctionId id, | 194 void CallRuntimeFromDeferred(Runtime::FunctionId id, |
| 204 int argc, | 195 int argc, |
| 205 LInstruction* instr); | 196 LInstruction* instr, |
| 197 LOperand* context); |
| 206 | 198 |
| 207 // Generate a direct call to a known function. Expects the function | 199 // Generate a direct call to a known function. Expects the function |
| 208 // to be in edi. | 200 // to be in edi. |
| 209 void CallKnownFunction(Handle<JSFunction> function, | 201 void CallKnownFunction(Handle<JSFunction> function, |
| 210 int arity, | 202 int arity, |
| 211 LInstruction* instr, | 203 LInstruction* instr, |
| 212 CallKind call_kind); | 204 CallKind call_kind); |
| 213 | 205 |
| 214 void LoadHeapObject(Register result, Handle<HeapObject> object); | 206 void LoadHeapObject(Register result, Handle<HeapObject> object); |
| 215 | 207 |
| 216 void RegisterLazyDeoptimization(LInstruction* instr, | 208 void RegisterLazyDeoptimization(LInstruction* instr, |
| 217 SafepointMode safepoint_mode); | 209 SafepointMode safepoint_mode); |
| 218 | 210 |
| 219 void RegisterEnvironmentForDeoptimization(LEnvironment* environment); | 211 void RegisterEnvironmentForDeoptimization(LEnvironment* environment); |
| 220 void DeoptimizeIf(Condition cc, LEnvironment* environment); | 212 void DeoptimizeIf(Condition cc, LEnvironment* environment); |
| 221 | 213 |
| 222 void AddToTranslation(Translation* translation, | 214 void AddToTranslation(Translation* translation, |
| 223 LOperand* op, | 215 LOperand* op, |
| 224 bool is_tagged); | 216 bool is_tagged); |
| 225 void PopulateDeoptimizationData(Handle<Code> code); | 217 void PopulateDeoptimizationData(Handle<Code> code); |
| 226 int DefineDeoptimizationLiteral(Handle<Object> literal); | 218 int DefineDeoptimizationLiteral(Handle<Object> literal); |
| 227 | 219 |
| 228 void PopulateDeoptimizationLiteralsWithInlinedFunctions(); | 220 void PopulateDeoptimizationLiteralsWithInlinedFunctions(); |
| 229 | 221 |
| 230 Register ToRegister(int index) const; | 222 Register ToRegister(int index) const; |
| 231 XMMRegister ToDoubleRegister(int index) const; | 223 XMMRegister ToDoubleRegister(int index) const; |
| 232 int ToInteger32(LConstantOperand* op) const; | 224 int ToInteger32(LConstantOperand* op) const; |
| 233 Operand BuildExternalArrayOperand(LOperand* external_pointer, | 225 Operand BuildExternalArrayOperand(LOperand* external_pointer, |
| 234 LOperand* key, | 226 LOperand* key, |
| 235 ExternalArrayType array_type); | 227 JSObject::ElementsKind elements_kind); |
| 236 | 228 |
| 237 // Specific math operations - used from DoUnaryMathOperation. | 229 // Specific math operations - used from DoUnaryMathOperation. |
| 238 void EmitIntegerMathAbs(LUnaryMathOperation* instr); | 230 void EmitIntegerMathAbs(LUnaryMathOperation* instr); |
| 239 void DoMathAbs(LUnaryMathOperation* instr); | 231 void DoMathAbs(LUnaryMathOperation* instr); |
| 240 void DoMathFloor(LUnaryMathOperation* instr); | 232 void DoMathFloor(LUnaryMathOperation* instr); |
| 241 void DoMathRound(LUnaryMathOperation* instr); | 233 void DoMathRound(LUnaryMathOperation* instr); |
| 242 void DoMathSqrt(LUnaryMathOperation* instr); | 234 void DoMathSqrt(LUnaryMathOperation* instr); |
| 243 void DoMathPowHalf(LUnaryMathOperation* instr); | 235 void DoMathPowHalf(LUnaryMathOperation* instr); |
| 244 void DoMathLog(LUnaryMathOperation* instr); | 236 void DoMathLog(LUnaryMathOperation* instr); |
| 245 void DoMathCos(LUnaryMathOperation* instr); | 237 void DoMathCos(LUnaryMathOperation* instr); |
| 246 void DoMathSin(LUnaryMathOperation* instr); | 238 void DoMathSin(LUnaryMathOperation* instr); |
| 247 | 239 |
| 248 // Support for recording safepoint and position information. | 240 // Support for recording safepoint and position information. |
| 249 void RecordSafepoint(LPointerMap* pointers, | 241 void RecordSafepoint(LPointerMap* pointers, |
| 250 Safepoint::Kind kind, | 242 Safepoint::Kind kind, |
| 251 int arguments, | 243 int arguments, |
| 252 int deoptimization_index); | 244 int deoptimization_index); |
| 253 void RecordSafepoint(LPointerMap* pointers, int deoptimization_index); | 245 void RecordSafepoint(LPointerMap* pointers, int deoptimization_index); |
| 254 void RecordSafepoint(int deoptimization_index); | 246 void RecordSafepoint(int deoptimization_index); |
| 255 void RecordSafepointWithRegisters(LPointerMap* pointers, | 247 void RecordSafepointWithRegisters(LPointerMap* pointers, |
| 256 int arguments, | 248 int arguments, |
| 257 int deoptimization_index); | 249 int deoptimization_index); |
| 258 void RecordPosition(int position); | 250 void RecordPosition(int position); |
| 251 int LastSafepointEnd() { |
| 252 return static_cast<int>(safepoints_.GetPcAfterGap()); |
| 253 } |
| 259 | 254 |
| 260 static Condition TokenToCondition(Token::Value op, bool is_unsigned); | 255 static Condition TokenToCondition(Token::Value op, bool is_unsigned); |
| 261 void EmitGoto(int block, LDeferredCode* deferred_stack_check = NULL); | 256 void EmitGoto(int block); |
| 262 void EmitBranch(int left_block, int right_block, Condition cc); | 257 void EmitBranch(int left_block, int right_block, Condition cc); |
| 263 void EmitCmpI(LOperand* left, LOperand* right); | 258 void EmitCmpI(LOperand* left, LOperand* right); |
| 264 void EmitNumberUntagD(Register input, XMMRegister result, LEnvironment* env); | 259 void EmitNumberUntagD(Register input, |
| 260 XMMRegister result, |
| 261 bool deoptimize_on_undefined, |
| 262 LEnvironment* env); |
| 265 | 263 |
| 266 // Emits optimized code for typeof x == "y". Modifies input register. | 264 // Emits optimized code for typeof x == "y". Modifies input register. |
| 267 // Returns the condition on which a final split to | 265 // Returns the condition on which a final split to |
| 268 // true and false label should be made, to optimize fallthrough. | 266 // true and false label should be made, to optimize fallthrough. |
| 269 Condition EmitTypeofIs(Label* true_label, Label* false_label, | 267 Condition EmitTypeofIs(Label* true_label, Label* false_label, |
| 270 Register input, Handle<String> type_name); | 268 Register input, Handle<String> type_name); |
| 271 | 269 |
| 272 // Emits optimized code for %_IsObject(x). Preserves input register. | 270 // Emits optimized code for %_IsObject(x). Preserves input register. |
| 273 // Returns the condition on which a final split to | 271 // Returns the condition on which a final split to |
| 274 // true and false label should be made, to optimize fallthrough. | 272 // true and false label should be made, to optimize fallthrough. |
| 275 Condition EmitIsObject(Register input, | 273 Condition EmitIsObject(Register input, |
| 276 Register temp1, | 274 Register temp1, |
| 277 Register temp2, | |
| 278 Label* is_not_object, | 275 Label* is_not_object, |
| 279 Label* is_object); | 276 Label* is_object); |
| 280 | 277 |
| 281 // Emits optimized code for %_IsConstructCall(). | 278 // Emits optimized code for %_IsConstructCall(). |
| 282 // Caller should branch on equal condition. | 279 // Caller should branch on equal condition. |
| 283 void EmitIsConstructCall(Register temp); | 280 void EmitIsConstructCall(Register temp); |
| 284 | 281 |
| 285 void EmitLoadFieldOrConstantFunction(Register result, | 282 void EmitLoadFieldOrConstantFunction(Register result, |
| 286 Register object, | 283 Register object, |
| 287 Handle<Map> type, | 284 Handle<Map> type, |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 private: | 363 private: |
| 367 LCodeGen* codegen_; | 364 LCodeGen* codegen_; |
| 368 Label entry_; | 365 Label entry_; |
| 369 Label exit_; | 366 Label exit_; |
| 370 Label* external_exit_; | 367 Label* external_exit_; |
| 371 }; | 368 }; |
| 372 | 369 |
| 373 } } // namespace v8::internal | 370 } } // namespace v8::internal |
| 374 | 371 |
| 375 #endif // V8_IA32_LITHIUM_CODEGEN_IA32_H_ | 372 #endif // V8_IA32_LITHIUM_CODEGEN_IA32_H_ |
| OLD | NEW |