62
70
// ---------------------------------------------------------------------------
65
// For page containing |object| mark region covering |addr| dirty.
66
// RecordWriteHelper only works if the object is not in new
68
void RecordWriteHelper(Register object,
72
// Check if object is in new space.
73
// scratch can be object itself, but it will be clobbered.
74
void InNewSpace(Register object,
76
Condition cc, // equal for new space, not_equal otherwise.
78
Label::Distance branch_near = Label::kFar);
80
// For page containing |object| mark region covering [object+offset]
81
// dirty. |object| is the object being stored into, |value| is the
82
// object being stored. If offset is zero, then the scratch register
83
// contains the array index into the elements array represented as a
84
// Smi. All registers are clobbered by the operation. RecordWrite
72
enum RememberedSetFinalAction {
77
// Record in the remembered set the fact that we have a pointer to new space
78
// at the address pointed to by the addr register. Only works if addr is not
80
void RememberedSetHelper(Register object, // Used for debug code.
83
SaveFPRegsMode save_fp,
84
RememberedSetFinalAction and_then);
86
void CheckPageFlag(Register object,
91
Label::Distance condition_met_distance = Label::kFar);
93
// Check if object is in new space. Jumps if the object is not in new space.
94
// The register scratch can be object itself, but scratch will be clobbered.
95
void JumpIfNotInNewSpace(Register object,
98
Label::Distance distance = Label::kFar) {
99
InNewSpace(object, scratch, zero, branch, distance);
102
// Check if object is in new space. Jumps if the object is in new space.
103
// The register scratch can be object itself, but it will be clobbered.
104
void JumpIfInNewSpace(Register object,
107
Label::Distance distance = Label::kFar) {
108
InNewSpace(object, scratch, not_zero, branch, distance);
111
// Check if an object has a given incremental marking color. Also uses ecx!
112
void HasColor(Register object,
116
Label::Distance has_color_distance,
120
void JumpIfBlack(Register object,
124
Label::Distance on_black_distance = Label::kFar);
126
// Checks the color of an object. If the object is already grey or black
127
// then we just fall through, since it is already live. If it is white and
128
// we can determine that it doesn't need to be scanned, then we just mark it
129
// black and fall through. For the rest we jump to the label so the
130
// incremental marker can fix its assumptions.
131
void EnsureNotWhite(Register object,
134
Label* object_is_white_and_not_data,
135
Label::Distance distance);
137
// Notify the garbage collector that we wrote a pointer into an object.
138
// |object| is the object being stored into, |value| is the object being
139
// stored. value and scratch registers are clobbered by the operation.
140
// The offset is the offset from the start of the object, not the offset from
141
// the tagged HeapObject pointer. For use with FieldOperand(reg, off).
142
void RecordWriteField(
147
SaveFPRegsMode save_fp,
148
RememberedSetAction remembered_set_action = EMIT_REMEMBERED_SET,
149
SmiCheck smi_check = INLINE_SMI_CHECK);
151
// As above, but the offset has the tag presubtracted. For use with
152
// Operand(reg, off).
153
void RecordWriteContextSlot(
158
SaveFPRegsMode save_fp,
159
RememberedSetAction remembered_set_action = EMIT_REMEMBERED_SET,
160
SmiCheck smi_check = INLINE_SMI_CHECK) {
161
RecordWriteField(context,
162
offset + kHeapObjectTag,
166
remembered_set_action,
170
// Notify the garbage collector that we wrote a pointer into a fixed array.
171
// |array| is the array being stored into, |value| is the
172
// object being stored. |index| is the array index represented as a
173
// Smi. All registers are clobbered by the operation RecordWriteArray
85
174
// filters out smis so it does not update the write barrier if the
86
175
// value is a smi.
87
void RecordWrite(Register object,
176
void RecordWriteArray(
180
SaveFPRegsMode save_fp,
181
RememberedSetAction remembered_set_action = EMIT_REMEMBERED_SET,
182
SmiCheck smi_check = INLINE_SMI_CHECK);
92
184
// For page containing |object| mark region covering |address|
93
185
// dirty. |object| is the object being stored into, |value| is the
94
// object being stored. All registers are clobbered by the
186
// object being stored. The address and value registers are clobbered by the
95
187
// operation. RecordWrite filters out smis so it does not update the
96
188
// write barrier if the value is a smi.
97
void RecordWrite(Register object,
193
SaveFPRegsMode save_fp,
194
RememberedSetAction remembered_set_action = EMIT_REMEMBERED_SET,
195
SmiCheck smi_check = INLINE_SMI_CHECK);
101
197
#ifdef ENABLE_DEBUGGER_SUPPORT
102
198
// ---------------------------------------------------------------------------
226
322
Label::Distance distance = Label::kFar);
324
// Check if a map for a JSObject indicates that the object can have both smi
325
// and HeapObject elements. Jump to the specified label if it does not.
326
void CheckFastObjectElements(Register map,
328
Label::Distance distance = Label::kFar);
330
// Check if a map for a JSObject indicates that the object has fast smi only
331
// elements. Jump to the specified label if it does not.
332
void CheckFastSmiOnlyElements(Register map,
334
Label::Distance distance = Label::kFar);
336
// Check to see if maybe_number can be stored as a double in
337
// FastDoubleElements. If it can, store it at the index specified by key in
338
// the FastDoubleElements array elements, otherwise jump to fail.
339
void StoreNumberToDoubleElements(Register maybe_number,
343
XMMRegister scratch2,
345
bool specialize_for_processor);
228
347
// Check if the map of an object is equal to a specified map and branch to
229
348
// label if not. Skip the smi check if not required (object is known to be a
522
643
void CallRuntime(const Runtime::Function* f, int num_arguments);
523
644
void CallRuntimeSaveDoubles(Runtime::FunctionId id);
525
// Call a runtime function, returning the CodeStub object called.
526
// Try to generate the stub code if necessary. Do not perform a GC
527
// but instead return a retry after GC failure.
528
MUST_USE_RESULT MaybeObject* TryCallRuntime(const Runtime::Function* f,
531
646
// Convenience function: Same as above, but takes the fid instead.
532
647
void CallRuntime(Runtime::FunctionId id, int num_arguments);
534
// Convenience function: Same as above, but takes the fid instead.
535
MUST_USE_RESULT MaybeObject* TryCallRuntime(Runtime::FunctionId id,
538
649
// Convenience function: call an external reference.
539
650
void CallExternalReference(ExternalReference ref, int num_arguments);
545
656
int num_arguments,
546
657
int result_size);
548
// Tail call of a runtime routine (jump). Try to generate the code if
549
// necessary. Do not perform a GC but instead return a retry after GC failure.
550
MUST_USE_RESULT MaybeObject* TryTailCallExternalReference(
551
const ExternalReference& ext, int num_arguments, int result_size);
553
659
// Convenience function: tail call a runtime routine (jump).
554
660
void TailCallRuntime(Runtime::FunctionId fid,
555
661
int num_arguments,
556
662
int result_size);
558
// Convenience function: tail call a runtime routine (jump). Try to generate
559
// the code if necessary. Do not perform a GC but instead return a retry after
561
MUST_USE_RESULT MaybeObject* TryTailCallRuntime(Runtime::FunctionId fid,
565
664
// Before calling a C-function from generated code, align arguments on stack.
566
665
// After aligning the frame, arguments must be stored in esp[0], esp[4],
567
666
// etc., not pushed. The argument count assumes all arguments are word sized.
586
685
// stores the pointer to the reserved slot into esi.
587
686
void PrepareCallApiFunction(int argc);
589
// Calls an API function. Allocates HandleScope, extracts
590
// returned value from handle and propagates exceptions.
591
// Clobbers ebx, edi and caller-save registers. Restores context.
592
// On return removes stack_space * kPointerSize (GCed).
593
MaybeObject* TryCallApiFunctionAndReturn(ApiFunction* function,
688
// Calls an API function. Allocates HandleScope, extracts returned value
689
// from handle and propagates exceptions. Clobbers ebx, edi and
690
// caller-save registers. Restores context. On return removes
691
// stack_space * kPointerSize (GCed).
692
void CallApiFunctionAndReturn(Address function_address, int stack_space);
596
694
// Jump to a runtime routine.
597
695
void JumpToExternalReference(const ExternalReference& ext);
599
MaybeObject* TryJumpToExternalReference(const ExternalReference& ext);
602
697
// ---------------------------------------------------------------------------
764
881
// Static helper functions.
766
883
// Generate an Operand for loading a field from an object.
767
static inline Operand FieldOperand(Register object, int offset) {
884
inline Operand FieldOperand(Register object, int offset) {
768
885
return Operand(object, offset - kHeapObjectTag);
772
889
// Generate an Operand for loading an indexed field from an object.
773
static inline Operand FieldOperand(Register object,
890
inline Operand FieldOperand(Register object,
777
894
return Operand(object, index, scale, offset - kHeapObjectTag);
781
static inline Operand ContextOperand(Register context, int index) {
898
inline Operand ContextOperand(Register context, int index) {
782
899
return Operand(context, Context::SlotOffset(index));
786
static inline Operand GlobalObjectOperand() {
903
inline Operand GlobalObjectOperand() {
787
904
return ContextOperand(esi, Context::GLOBAL_INDEX);