28 #ifndef V8_IA32_CODE_STUBS_IA32_H_
29 #define V8_IA32_CODE_STUBS_IA32_H_
41 class TranscendentalCacheStub:
public CodeStub {
50 : type_(type), argument_type_(argument_type) {}
59 int MinorKey() {
return type_ | argument_type_; }
64 class StoreBufferOverflowStub:
public CodeStub {
67 : save_doubles_(save_fp) { }
78 Major MajorKey() {
return StoreBufferOverflow; }
79 int MinorKey() {
return (save_doubles_ ==
kSaveFPRegs) ? 1 : 0; }
83 class UnaryOpStub:
public CodeStub {
90 operand_type_(operand_type) {
102 class ModeBits:
public BitField<UnaryOverwriteMode, 0, 1> {};
103 class OpBits:
public BitField<Token::Value, 1, 7> {};
104 class OperandTypeInfoBits:
public BitField<UnaryOpIC::TypeInfo, 8, 3> {};
106 Major MajorKey() {
return UnaryOp; }
108 return ModeBits::encode(mode_)
109 | OpBits::encode(op_)
110 | OperandTypeInfoBits::encode(operand_type_);
115 void Generate(MacroAssembler* masm);
117 void GenerateTypeTransition(MacroAssembler* masm);
119 void GenerateSmiStub(MacroAssembler* masm);
120 void GenerateSmiStubSub(MacroAssembler* masm);
121 void GenerateSmiStubBitNot(MacroAssembler* masm);
122 void GenerateSmiCodeSub(MacroAssembler* masm,
126 Label::Distance non_smi_near = Label::kFar,
127 Label::Distance undo_near = Label::kFar,
128 Label::Distance slow_near = Label::kFar);
129 void GenerateSmiCodeBitNot(MacroAssembler* masm,
131 Label::Distance non_smi_near = Label::kFar);
132 void GenerateSmiCodeUndo(MacroAssembler* masm);
134 void GenerateHeapNumberStub(MacroAssembler* masm);
135 void GenerateHeapNumberStubSub(MacroAssembler* masm);
136 void GenerateHeapNumberStubBitNot(MacroAssembler* masm);
137 void GenerateHeapNumberCodeSub(MacroAssembler* masm, Label* slow);
138 void GenerateHeapNumberCodeBitNot(MacroAssembler* masm, Label* slow);
140 void GenerateGenericStub(MacroAssembler* masm);
141 void GenerateGenericStubSub(MacroAssembler* masm);
142 void GenerateGenericStubBitNot(MacroAssembler* masm);
143 void GenerateGenericCodeFallback(MacroAssembler* masm);
145 virtual int GetCodeKind() {
return Code::UNARY_OP_IC; }
151 virtual void FinishCode(Handle<Code>
code) {
152 code->set_unary_op_type(operand_type_);
157 class BinaryOpStub:
public CodeStub {
172 : op_(OpBits::decode(key)),
173 mode_(ModeBits::decode(key)),
174 use_sse3_(SSE3Bits::decode(key)),
175 operands_type_(operands_type),
176 result_type_(result_type) { }
179 enum SmiCodeGenerateHeapNumberResults {
180 ALLOW_HEAPNUMBER_RESULTS,
181 NO_HEAPNUMBER_RESULTS
192 virtual void PrintName(StringStream* stream);
195 class ModeBits:
public BitField<OverwriteMode, 0, 2> {};
196 class OpBits:
public BitField<Token::Value, 2, 7> {};
197 class SSE3Bits:
public BitField<bool, 9, 1> {};
198 class OperandTypeInfoBits:
public BitField<BinaryOpIC::TypeInfo, 10, 3> {};
199 class ResultTypeInfoBits:
public BitField<BinaryOpIC::TypeInfo, 13, 3> {};
201 Major MajorKey() {
return BinaryOp; }
203 return OpBits::encode(op_)
204 | ModeBits::encode(mode_)
205 | SSE3Bits::encode(use_sse3_)
206 | OperandTypeInfoBits::encode(operands_type_)
207 | ResultTypeInfoBits::encode(result_type_);
210 void Generate(MacroAssembler* masm);
211 void GenerateGeneric(MacroAssembler* masm);
212 void GenerateSmiCode(MacroAssembler* masm,
214 SmiCodeGenerateHeapNumberResults heapnumber_results);
215 void GenerateLoadArguments(MacroAssembler* masm);
216 void GenerateReturn(MacroAssembler* masm);
217 void GenerateUninitializedStub(MacroAssembler* masm);
218 void GenerateSmiStub(MacroAssembler* masm);
219 void GenerateInt32Stub(MacroAssembler* masm);
220 void GenerateHeapNumberStub(MacroAssembler* masm);
221 void GenerateOddballStub(MacroAssembler* masm);
222 void GenerateStringStub(MacroAssembler* masm);
223 void GenerateBothStringStub(MacroAssembler* masm);
224 void GenerateGenericStub(MacroAssembler* masm);
225 void GenerateAddStrings(MacroAssembler* masm);
227 void GenerateHeapResultAllocation(MacroAssembler* masm, Label* alloc_failure);
228 void GenerateRegisterArgsPush(MacroAssembler* masm);
229 void GenerateTypeTransition(MacroAssembler* masm);
230 void GenerateTypeTransitionWithSavedArgs(MacroAssembler* masm);
232 virtual int GetCodeKind() {
return Code::BINARY_OP_IC; }
238 virtual void FinishCode(Handle<Code>
code) {
239 code->set_binary_op_type(operands_type_);
240 code->set_binary_op_result_type(result_type_);
247 class StringHelper :
public AllStatic {
301 DISALLOW_IMPLICIT_CONSTRUCTORS(StringHelper);
318 class StringAddStub:
public CodeStub {
323 Major MajorKey() {
return StringAdd; }
324 int MinorKey() {
return flags_; }
326 void Generate(MacroAssembler* masm);
328 void GenerateConvertArgument(MacroAssembler* masm,
340 class SubStringStub:
public CodeStub {
346 int MinorKey() {
return 0; }
348 void Generate(MacroAssembler* masm);
352 class StringCompareStub:
public CodeStub {
373 virtual Major MajorKey() {
return StringCompare; }
374 virtual int MinorKey() {
return 0; }
375 virtual void Generate(MacroAssembler* masm);
377 static void GenerateAsciiCharsCompareLoop(
378 MacroAssembler* masm,
383 Label* chars_not_equal,
384 Label::Distance chars_not_equal_near = Label::kFar);
388 class NumberToStringStub:
public CodeStub {
406 Major MajorKey() {
return NumberToString; }
407 int MinorKey() {
return 0; }
409 void Generate(MacroAssembler* masm);
413 class StringDictionaryLookupStub:
public CodeStub {
421 : dictionary_(dictionary), result_(result), index_(index), mode_(mode) { }
443 static const int kInlinedProbes = 4;
444 static const int kTotalProbes = 20;
446 static const int kCapacityOffset =
450 static const int kElementsStartOffset =
454 Major MajorKey() {
return StringDictionaryLookup; }
457 return DictionaryBits::encode(dictionary_.
code()) |
458 ResultBits::encode(result_.
code()) |
459 IndexBits::encode(index_.
code()) |
460 LookupModeBits::encode(mode_);
463 class DictionaryBits:
public BitField<int, 0, 3> {};
464 class ResultBits:
public BitField<int, 3, 3> {};
465 class IndexBits:
public BitField<int, 6, 3> {};
466 class LookupModeBits:
public BitField<LookupMode, 9, 1> {};
468 Register dictionary_;
475 class RecordWriteStub:
public CodeStub {
485 remembered_set_action_(remembered_set_action),
486 save_fp_regs_mode_(fp_mode),
553 class RegisterAllocation {
558 : object_orig_(object),
559 address_orig_(address),
560 scratch0_orig_(scratch0),
563 scratch0_(scratch0) {
565 scratch1_ = GetRegThatIsNotEcxOr(object_, address_, scratch0_);
566 if (scratch0.
is(
ecx)) {
567 scratch0_ = GetRegThatIsNotEcxOr(object_, address_, scratch1_);
569 if (
object.is(
ecx)) {
570 object_ = GetRegThatIsNotEcxOr(address_, scratch0_, scratch1_);
572 if (address.
is(
ecx)) {
573 address_ = GetRegThatIsNotEcxOr(object_, scratch0_, scratch1_);
578 void Save(MacroAssembler* masm) {
579 ASSERT(!address_orig_.is(object_));
580 ASSERT(object_.is(object_orig_) || address_.is(address_orig_));
587 if (!scratch0_.is(scratch0_orig_)) masm->push(scratch0_);
588 if (!
ecx.
is(scratch0_orig_) &&
589 !
ecx.
is(object_orig_) &&
590 !
ecx.
is(address_orig_)) {
593 masm->push(scratch1_);
594 if (!address_.is(address_orig_)) {
595 masm->push(address_);
596 masm->mov(address_, address_orig_);
598 if (!object_.is(object_orig_)) {
600 masm->mov(object_, object_orig_);
604 void Restore(MacroAssembler* masm) {
608 if (!object_.is(object_orig_)) {
609 masm->mov(object_orig_, object_);
612 if (!address_.is(address_orig_)) {
613 masm->mov(address_orig_, address_);
616 masm->pop(scratch1_);
617 if (!
ecx.
is(scratch0_orig_) &&
618 !
ecx.
is(object_orig_) &&
619 !
ecx.
is(address_orig_)) {
622 if (!scratch0_.is(scratch0_orig_)) masm->pop(scratch0_);
629 void SaveCallerSaveRegisters(MacroAssembler* masm,
SaveFPRegsMode mode) {
630 if (!scratch0_.is(
eax) && !scratch1_.is(
eax)) masm->push(
eax);
631 if (!scratch0_.is(
edx) && !scratch1_.is(
edx)) masm->push(
edx);
633 CpuFeatures::Scope scope(
SSE2);
644 inline void RestoreCallerSaveRegisters(MacroAssembler*masm,
647 CpuFeatures::Scope scope(
SSE2);
656 if (!scratch0_.is(
edx) && !scratch1_.is(
edx)) masm->pop(
edx);
657 if (!scratch0_.is(
eax) && !scratch1_.is(
eax)) masm->pop(
eax);
660 inline Register object() {
return object_; }
661 inline Register address() {
return address_; }
662 inline Register scratch0() {
return scratch0_; }
663 inline Register scratch1() {
return scratch1_; }
666 Register object_orig_;
667 Register address_orig_;
668 Register scratch0_orig_;
675 Register GetRegThatIsNotEcxOr(Register
r1,
680 if (candidate.is(
ecx))
continue;
681 if (candidate.is(r1))
continue;
682 if (candidate.is(r2))
continue;
683 if (candidate.is(r3))
continue;
692 enum OnNoNeedToInformIncrementalMarker {
693 kReturnOnNoNeedToInformIncrementalMarker,
694 kUpdateRememberedSetOnNoNeedToInformIncrementalMarker
697 void Generate(MacroAssembler* masm);
698 void GenerateIncremental(MacroAssembler* masm,
Mode mode);
699 void CheckNeedsToInformIncrementalMarker(
700 MacroAssembler* masm,
701 OnNoNeedToInformIncrementalMarker on_no_need,
703 void InformIncrementalMarker(MacroAssembler* masm,
Mode mode);
705 Major MajorKey() {
return RecordWrite; }
708 return ObjectBits::encode(object_.
code()) |
709 ValueBits::encode(value_.
code()) |
710 AddressBits::encode(address_.
code()) |
711 RememberedSetActionBits::encode(remembered_set_action_) |
712 SaveFPRegsModeBits::encode(save_fp_regs_mode_);
715 void Activate(Code* code) {
716 code->GetHeap()->incremental_marking()->ActivateGeneratedStub(code);
719 class ObjectBits:
public BitField<int, 0, 3> {};
720 class ValueBits:
public BitField<int, 3, 3> {};
721 class AddressBits:
public BitField<int, 6, 3> {};
722 class RememberedSetActionBits:
public BitField<RememberedSetAction, 9, 1> {};
723 class SaveFPRegsModeBits:
public BitField<SaveFPRegsMode, 10, 1> {};
730 RegisterAllocation regs_;
736 #endif // V8_IA32_CODE_STUBS_IA32_H_
static Mode GetMode(Code *stub)
static void Patch(Code *stub, Mode mode)
static const int kElementsStartIndex
RecordWriteStub(Register object, Register value, Register address, RememberedSetAction remembered_set_action, SaveFPRegsMode fp_mode)
StringDictionaryLookupStub(Register dictionary, Register result, Register index, LookupMode mode)
friend class CodeGenerator
virtual bool SometimesSetsUpAFrame()
static void GenerateFixedRegStubsAheadOfTime()
static void GenerateCopyCharacters(MacroAssembler *masm, Register dest, Register src, Register count, Register scratch, bool ascii)
UnaryOpStub(Token::Value op, UnaryOverwriteMode mode, UnaryOpIC::TypeInfo operand_type=UnaryOpIC::UNINITIALIZED)
static const byte kTwoByteNopInstruction
void Generate(MacroAssembler *masm)
static void GenerateHashGetHash(MacroAssembler *masm, Register hash)
static bool IsSupported(CpuFeature f)
virtual bool SometimesSetsUpAFrame()
bool AreAliased(Register r1, Register r2, Register r3, Register r4)
#define ASSERT(condition)
static void GenerateCompareFlatAsciiStrings(MacroAssembler *masm, Register left, Register right, Register scratch1, Register scratch2, Register scratch3, Register scratch4)
static void GenerateOperation(MacroAssembler *masm, TranscendentalCache::Type type)
BinaryOpStub(Token::Value op, OverwriteMode mode)
static State ToState(TypeInfo type_info)
static void GenerateNegativeLookup(MacroAssembler *masm, Label *miss, Label *done, Register receiver, Register properties, Handle< String > name, Register scratch0)
Handle< String > SubString(Handle< String > str, int start, int end, PretenureFlag pretenure)
static void GenerateCopyCharactersREP(MacroAssembler *masm, Register dest, Register src, Register count, Register scratch, bool ascii)
static void GenerateFlatAsciiStringEquals(MacroAssembler *masm, Register left, Register right, Register scratch1, Register scratch2, Register scratch3)
byte * instruction_start()
virtual bool IsPregenerated()
static Register FromAllocationIndex(int index)
static const byte kTwoByteJumpInstruction
static const byte kFiveByteNopInstruction
static State ToState(TypeInfo type_info)
static void GenerateHashAddCharacter(MacroAssembler *masm, Register hash, Register character)
static const int kHeaderSize
bool is(Register reg) const
static void GenerateFixedRegStubsAheadOfTime()
void Generate(MacroAssembler *masm)
static void GeneratePositiveLookup(MacroAssembler *masm, Label *miss, Label *done, Register elements, Register name, Register r0, Register r1)
BinaryOpStub(int key, BinaryOpIC::TypeInfo operands_type, BinaryOpIC::TypeInfo result_type=BinaryOpIC::UNINITIALIZED)
static const int kCapacityIndex
static const int kNumAllocatableRegisters
TranscendentalCacheStub(TranscendentalCache::Type type, ArgumentType argument_type)
static XMMRegister from_code(int code)
static void GenerateLookupNumberStringCache(MacroAssembler *masm, Register object, Register result, Register scratch1, Register scratch2, Register scratch3, bool object_is_smi, Label *not_found)
static void GenerateTwoCharacterSymbolTableProbe(MacroAssembler *masm, Register c1, Register c2, Register scratch1, Register scratch2, Register scratch3, Register scratch4, Register scratch5, Label *not_found)
activate correct semantics for inheriting readonliness enable harmony semantics for typeof enable harmony enable harmony proxies enable all harmony harmony_scoping harmony_proxies harmony_scoping tracks arrays with only smi values automatically unbox arrays of doubles use crankshaft use hydrogen range analysis use hydrogen global value numbering use function inlining maximum number of AST nodes considered for a single inlining loop invariant code motion print statistics for hydrogen trace generated IR for specified phases trace register allocator trace range analysis trace representation types environment for every instruction put a break point before deoptimizing polymorphic inlining perform array bounds checks elimination use dead code elimination trace on stack replacement optimize closures cache optimized code for closures functions with arguments object loop weight for representation inference allow uint32 values on optimize frames if they are used only in safe operations track parallel recompilation enable all profiler experiments number of stack frames inspected by the profiler call recompile stub directly when self optimizing trigger profiler ticks based on counting instead of timing weight back edges by jump distance for interrupt triggering percentage of ICs that must have type info to allow optimization watch_ic_patching retry_self_opt interrupt_at_exit extra verbose compilation tracing generate extra code(assertions) for debugging") DEFINE_bool(code_comments
static void FlushICache(void *start, size_t size)
static const byte kFiveByteJumpInstruction
static const int kTranscendentalTypeBits
virtual bool SometimesSetsUpAFrame()
static const int kNumRegisters
activate correct semantics for inheriting readonliness enable harmony semantics for typeof enable harmony enable harmony proxies enable all harmony harmony_scoping harmony_proxies harmony_scoping tracks arrays with only smi values automatically unbox arrays of doubles use crankshaft use hydrogen range analysis use hydrogen global value numbering use function inlining maximum number of AST nodes considered for a single inlining loop invariant code motion print statistics for hydrogen trace generated IR for specified phases trace register allocator trace range analysis trace representation types environment for every instruction put a break point before deoptimizing polymorphic inlining perform array bounds checks elimination use dead code elimination trace on stack replacement optimize closures cache optimized code for closures functions with arguments object loop weight for representation inference allow uint32 values on optimize frames if they are used only in safe operations track parallel recompilation enable all profiler experiments number of stack frames inspected by the profiler call recompile stub directly when self optimizing trigger profiler ticks based on counting instead of timing weight back edges by jump distance for interrupt triggering percentage of ICs that must have type info to allow optimization watch_ic_patching retry_self_opt interrupt_at_exit extra verbose compilation tracing generate extra emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of SAHF instruction if enable use of VFP3 instructions if available this implies enabling ARMv7 and VFP2 enable use of VFP2 instructions if available enable use of SDIV and UDIV instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of MIPS FPU instructions if expose natives in global object expose gc extension number of stack frames to capture disable builtin natives files print a stack trace if an assertion failure occurs use random jit cookie to mask large constants trace lazy optimization use adaptive optimizations prepare for turning on always opt minimum length for automatic enable preparsing maximum number of optimization attempts before giving up cache prototype transitions automatically set the debug break flag when debugger commands are in the queue always cause a debug break before aborting maximum length of function source code printed in a stack trace max size of the new max size of the old max size of executable always perform global GCs print one trace line following each garbage collection do not print trace line after scavenger collection print more details following each garbage collection print amount of external allocated memory after each time it is adjusted flush code that we expect not to use again before full gc do incremental marking steps track object counts and memory usage use caching Perform compaction on every full GC Never perform compaction on full GC testing only Compact code space on full incremental collections Default seed for initializing random allows verbose printing trace parsing and preparsing Check icache flushes in ARM and MIPS simulator Stack alingment in bytes in print stack trace when throwing exceptions randomize hashes to avoid predictable hash Fixed seed to use to hash property activate a timer that switches between V8 threads testing_bool_flag float flag Seed used for threading test randomness A filename with extra code to be included in the Print usage including flags
StringAddStub(StringAddFlags flags)
StoreBufferOverflowStub(SaveFPRegsMode save_fp)
virtual bool IsPregenerated()
static void GenerateHashInit(MacroAssembler *masm, Register hash, Register character)
void Generate(MacroAssembler *masm)