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

Side by Side Diff: src/x64/codegen-x64.h

Issue 6811012: Remove some dead code. (Closed) Base URL: https://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/x64/builtins-x64.cc ('k') | src/x64/codegen-x64.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 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 12 matching lines...) Expand all
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #ifndef V8_X64_CODEGEN_X64_H_ 28 #ifndef V8_X64_CODEGEN_X64_H_
29 #define V8_X64_CODEGEN_X64_H_ 29 #define V8_X64_CODEGEN_X64_H_
30 30
31 #include "ast.h" 31 #include "ast.h"
32 #include "ic-inl.h" 32 #include "ic-inl.h"
33 #include "jump-target-heavy.h"
34 33
35 namespace v8 { 34 namespace v8 {
36 namespace internal { 35 namespace internal {
37 36
38 // Forward declarations 37 // Forward declarations
39 class CompilationInfo; 38 class CompilationInfo;
40 class DeferredCode;
41 class RegisterAllocator;
42 class RegisterFile;
43 39
44 enum InitState { CONST_INIT, NOT_CONST_INIT };
45 enum TypeofState { INSIDE_TYPEOF, NOT_INSIDE_TYPEOF }; 40 enum TypeofState { INSIDE_TYPEOF, NOT_INSIDE_TYPEOF };
46 41
47 42
48 // ------------------------------------------------------------------------- 43 // -------------------------------------------------------------------------
49 // Reference support
50
51 // A reference is a C++ stack-allocated object that puts a
52 // reference on the virtual frame. The reference may be consumed
53 // by GetValue, TakeValue, SetValue, and Codegen::UnloadReference.
54 // When the lifetime (scope) of a valid reference ends, it must have
55 // been consumed, and be in state UNLOADED.
56 class Reference BASE_EMBEDDED {
57 public:
58 // The values of the types is important, see size().
59 enum Type { UNLOADED = -2, ILLEGAL = -1, SLOT = 0, NAMED = 1, KEYED = 2 };
60
61 Reference(CodeGenerator* cgen,
62 Expression* expression,
63 bool persist_after_get = false);
64 ~Reference();
65
66 Expression* expression() const { return expression_; }
67 Type type() const { return type_; }
68 void set_type(Type value) {
69 ASSERT_EQ(ILLEGAL, type_);
70 type_ = value;
71 }
72
73 void set_unloaded() {
74 ASSERT_NE(ILLEGAL, type_);
75 ASSERT_NE(UNLOADED, type_);
76 type_ = UNLOADED;
77 }
78 // The size the reference takes up on the stack.
79 int size() const {
80 return (type_ < SLOT) ? 0 : type_;
81 }
82
83 bool is_illegal() const { return type_ == ILLEGAL; }
84 bool is_slot() const { return type_ == SLOT; }
85 bool is_property() const { return type_ == NAMED || type_ == KEYED; }
86 bool is_unloaded() const { return type_ == UNLOADED; }
87
88 // Return the name. Only valid for named property references.
89 Handle<String> GetName();
90
91 // Generate code to push the value of the reference on top of the
92 // expression stack. The reference is expected to be already on top of
93 // the expression stack, and it is consumed by the call unless the
94 // reference is for a compound assignment.
95 // If the reference is not consumed, it is left in place under its value.
96 void GetValue();
97
98 // Like GetValue except that the slot is expected to be written to before
99 // being read from again. The value of the reference may be invalidated,
100 // causing subsequent attempts to read it to fail.
101 void TakeValue();
102
103 // Generate code to store the value on top of the expression stack in the
104 // reference. The reference is expected to be immediately below the value
105 // on the expression stack. The value is stored in the location specified
106 // by the reference, and is left on top of the stack, after the reference
107 // is popped from beneath it (unloaded).
108 void SetValue(InitState init_state);
109
110 private:
111 CodeGenerator* cgen_;
112 Expression* expression_;
113 Type type_;
114 bool persist_after_get_;
115 };
116
117
118 // -------------------------------------------------------------------------
119 // Control destinations.
120
121 // A control destination encapsulates a pair of jump targets and a
122 // flag indicating which one is the preferred fall-through. The
123 // preferred fall-through must be unbound, the other may be already
124 // bound (ie, a backward target).
125 //
126 // The true and false targets may be jumped to unconditionally or
127 // control may split conditionally. Unconditional jumping and
128 // splitting should be emitted in tail position (as the last thing
129 // when compiling an expression) because they can cause either label
130 // to be bound or the non-fall through to be jumped to leaving an
131 // invalid virtual frame.
132 //
133 // The labels in the control destination can be extracted and
134 // manipulated normally without affecting the state of the
135 // destination.
136
137 class ControlDestination BASE_EMBEDDED {
138 public:
139 ControlDestination(JumpTarget* true_target,
140 JumpTarget* false_target,
141 bool true_is_fall_through)
142 : true_target_(true_target),
143 false_target_(false_target),
144 true_is_fall_through_(true_is_fall_through),
145 is_used_(false) {
146 ASSERT(true_is_fall_through ? !true_target->is_bound()
147 : !false_target->is_bound());
148 }
149
150 // Accessors for the jump targets. Directly jumping or branching to
151 // or binding the targets will not update the destination's state.
152 JumpTarget* true_target() const { return true_target_; }
153 JumpTarget* false_target() const { return false_target_; }
154
155 // True if the the destination has been jumped to unconditionally or
156 // control has been split to both targets. This predicate does not
157 // test whether the targets have been extracted and manipulated as
158 // raw jump targets.
159 bool is_used() const { return is_used_; }
160
161 // True if the destination is used and the true target (respectively
162 // false target) was the fall through. If the target is backward,
163 // "fall through" included jumping unconditionally to it.
164 bool true_was_fall_through() const {
165 return is_used_ && true_is_fall_through_;
166 }
167
168 bool false_was_fall_through() const {
169 return is_used_ && !true_is_fall_through_;
170 }
171
172 // Emit a branch to one of the true or false targets, and bind the
173 // other target. Because this binds the fall-through target, it
174 // should be emitted in tail position (as the last thing when
175 // compiling an expression).
176 void Split(Condition cc) {
177 ASSERT(!is_used_);
178 if (true_is_fall_through_) {
179 false_target_->Branch(NegateCondition(cc));
180 true_target_->Bind();
181 } else {
182 true_target_->Branch(cc);
183 false_target_->Bind();
184 }
185 is_used_ = true;
186 }
187
188 // Emit an unconditional jump in tail position, to the true target
189 // (if the argument is true) or the false target. The "jump" will
190 // actually bind the jump target if it is forward, jump to it if it
191 // is backward.
192 void Goto(bool where) {
193 ASSERT(!is_used_);
194 JumpTarget* target = where ? true_target_ : false_target_;
195 if (target->is_bound()) {
196 target->Jump();
197 } else {
198 target->Bind();
199 }
200 is_used_ = true;
201 true_is_fall_through_ = where;
202 }
203
204 // Mark this jump target as used as if Goto had been called, but
205 // without generating a jump or binding a label (the control effect
206 // should have already happened). This is used when the left
207 // subexpression of the short-circuit boolean operators are
208 // compiled.
209 void Use(bool where) {
210 ASSERT(!is_used_);
211 ASSERT((where ? true_target_ : false_target_)->is_bound());
212 is_used_ = true;
213 true_is_fall_through_ = where;
214 }
215
216 // Swap the true and false targets but keep the same actual label as
217 // the fall through. This is used when compiling negated
218 // expressions, where we want to swap the targets but preserve the
219 // state.
220 void Invert() {
221 JumpTarget* temp_target = true_target_;
222 true_target_ = false_target_;
223 false_target_ = temp_target;
224
225 true_is_fall_through_ = !true_is_fall_through_;
226 }
227
228 private:
229 // True and false jump targets.
230 JumpTarget* true_target_;
231 JumpTarget* false_target_;
232
233 // Before using the destination: true if the true target is the
234 // preferred fall through, false if the false target is. After
235 // using the destination: true if the true target was actually used
236 // as the fall through, false if the false target was.
237 bool true_is_fall_through_;
238
239 // True if the Split or Goto functions have been called.
240 bool is_used_;
241 };
242
243
244 // -------------------------------------------------------------------------
245 // Code generation state
246
247 // The state is passed down the AST by the code generator (and back up, in
248 // the form of the state of the jump target pair). It is threaded through
249 // the call stack. Constructing a state implicitly pushes it on the owning
250 // code generator's stack of states, and destroying one implicitly pops it.
251 //
252 // The code generator state is only used for expressions, so statements have
253 // the initial state.
254
255 class CodeGenState BASE_EMBEDDED {
256 public:
257 // Create an initial code generator state. Destroying the initial state
258 // leaves the code generator with a NULL state.
259 explicit CodeGenState(CodeGenerator* owner);
260
261 // Create a code generator state based on a code generator's current
262 // state. The new state has its own control destination.
263 CodeGenState(CodeGenerator* owner, ControlDestination* destination);
264
265 // Destroy a code generator state and restore the owning code generator's
266 // previous state.
267 ~CodeGenState();
268
269 // Accessors for the state.
270 ControlDestination* destination() const { return destination_; }
271
272 private:
273 // The owning code generator.
274 CodeGenerator* owner_;
275
276 // A control destination in case the expression has a control-flow
277 // effect.
278 ControlDestination* destination_;
279
280 // The previous state of the owning code generator, restored when
281 // this state is destroyed.
282 CodeGenState* previous_;
283 };
284
285
286 // -------------------------------------------------------------------------
287 // Arguments allocation mode
288
289 enum ArgumentsAllocationMode {
290 NO_ARGUMENTS_ALLOCATION,
291 EAGER_ARGUMENTS_ALLOCATION,
292 LAZY_ARGUMENTS_ALLOCATION
293 };
294
295
296 // -------------------------------------------------------------------------
297 // CodeGenerator 44 // CodeGenerator
298 45
299 class CodeGenerator: public AstVisitor { 46 class CodeGenerator: public AstVisitor {
300 public: 47 public:
301 static bool MakeCode(CompilationInfo* info); 48 static bool MakeCode(CompilationInfo* info);
302 49
303 // Printing of AST, etc. as requested by flags. 50 // Printing of AST, etc. as requested by flags.
304 static void MakeCodePrologue(CompilationInfo* info); 51 static void MakeCodePrologue(CompilationInfo* info);
305 52
306 // Allocate and install the code. 53 // Allocate and install the code.
307 static Handle<Code> MakeCodeEpilogue(MacroAssembler* masm, 54 static Handle<Code> MakeCodeEpilogue(MacroAssembler* masm,
308 Code::Flags flags, 55 Code::Flags flags,
309 CompilationInfo* info); 56 CompilationInfo* info);
310 57
311 // Print the code after compiling it. 58 // Print the code after compiling it.
312 static void PrintCode(Handle<Code> code, CompilationInfo* info); 59 static void PrintCode(Handle<Code> code, CompilationInfo* info);
313 60
314 #ifdef ENABLE_LOGGING_AND_PROFILING 61 #ifdef ENABLE_LOGGING_AND_PROFILING
315 static bool ShouldGenerateLog(Expression* type); 62 static bool ShouldGenerateLog(Expression* type);
316 #endif 63 #endif
317 64
318 static bool RecordPositions(MacroAssembler* masm, 65 static bool RecordPositions(MacroAssembler* masm,
319 int pos, 66 int pos,
320 bool right_here = false); 67 bool right_here = false);
321 68
322 // Accessors
323 MacroAssembler* masm() { return masm_; }
324 VirtualFrame* frame() const { return frame_; }
325 inline Handle<Script> script();
326
327 bool has_valid_frame() const { return frame_ != NULL; }
328
329 // Set the virtual frame to be new_frame, with non-frame register
330 // reference counts given by non_frame_registers. The non-frame
331 // register reference counts of the old frame are returned in
332 // non_frame_registers.
333 void SetFrame(VirtualFrame* new_frame, RegisterFile* non_frame_registers);
334
335 void DeleteFrame();
336
337 RegisterAllocator* allocator() const { return allocator_; }
338
339 CodeGenState* state() { return state_; }
340 void set_state(CodeGenState* state) { state_ = state; }
341
342 void AddDeferred(DeferredCode* code) { deferred_.Add(code); }
343
344 bool in_spilled_code() const { return in_spilled_code_; }
345 void set_in_spilled_code(bool flag) { in_spilled_code_ = flag; }
346
347 private: 69 private:
348 // Type of a member function that generates inline code for a native function.
349 typedef void (CodeGenerator::*InlineFunctionGenerator)
350 (ZoneList<Expression*>*);
351
352 static const InlineFunctionGenerator kInlineFunctionGenerators[];
353
354 // Construction/Destruction
355 explicit CodeGenerator(MacroAssembler* masm);
356
357 // Accessors
358 inline bool is_eval();
359 inline Scope* scope();
360 inline bool is_strict_mode();
361 inline StrictModeFlag strict_mode_flag();
362
363 // Generating deferred code.
364 void ProcessDeferred();
365
366 // State
367 ControlDestination* destination() const { return state_->destination(); }
368
369 // Track loop nesting level.
370 int loop_nesting() const { return loop_nesting_; }
371 void IncrementLoopNesting() { loop_nesting_++; }
372 void DecrementLoopNesting() { loop_nesting_--; }
373
374
375 // Node visitors.
376 void VisitStatements(ZoneList<Statement*>* statements);
377
378 virtual void VisitSlot(Slot* node);
379 #define DEF_VISIT(type) \
380 virtual void Visit##type(type* node);
381 AST_NODE_LIST(DEF_VISIT)
382 #undef DEF_VISIT
383
384 // Visit a statement and then spill the virtual frame if control flow can
385 // reach the end of the statement (ie, it does not exit via break,
386 // continue, return, or throw). This function is used temporarily while
387 // the code generator is being transformed.
388 void VisitAndSpill(Statement* statement);
389
390 // Visit a list of statements and then spill the virtual frame if control
391 // flow can reach the end of the list.
392 void VisitStatementsAndSpill(ZoneList<Statement*>* statements);
393
394 // Main code generation function
395 void Generate(CompilationInfo* info);
396
397 // Generate the return sequence code. Should be called no more than
398 // once per compiled function, immediately after binding the return
399 // target (which can not be done more than once).
400 void GenerateReturnSequence(Result* return_value);
401
402 // Generate code for a fast smi loop.
403 void GenerateFastSmiLoop(ForStatement* node);
404
405 // Returns the arguments allocation mode.
406 ArgumentsAllocationMode ArgumentsMode();
407
408 // Store the arguments object and allocate it if necessary.
409 Result StoreArgumentsObject(bool initial);
410
411 // The following are used by class Reference.
412 void LoadReference(Reference* ref);
413 void UnloadReference(Reference* ref);
414
415 Operand SlotOperand(Slot* slot, Register tmp);
416
417 Operand ContextSlotOperandCheckExtensions(Slot* slot,
418 Result tmp,
419 JumpTarget* slow);
420
421 // Expressions
422 void LoadCondition(Expression* x,
423 ControlDestination* destination,
424 bool force_control);
425 void Load(Expression* expr);
426 void LoadGlobal();
427 void LoadGlobalReceiver();
428
429 // Generate code to push the value of an expression on top of the frame
430 // and then spill the frame fully to memory. This function is used
431 // temporarily while the code generator is being transformed.
432 void LoadAndSpill(Expression* expression);
433
434 // Read a value from a slot and leave it on top of the expression stack.
435 void LoadFromSlot(Slot* slot, TypeofState typeof_state);
436 void LoadFromSlotCheckForArguments(Slot* slot, TypeofState state);
437 Result LoadFromGlobalSlotCheckExtensions(Slot* slot,
438 TypeofState typeof_state,
439 JumpTarget* slow);
440
441 // Support for loading from local/global variables and arguments
442 // whose location is known unless they are shadowed by
443 // eval-introduced bindings. Generates no code for unsupported slot
444 // types and therefore expects to fall through to the slow jump target.
445 void EmitDynamicLoadFromSlotFastCase(Slot* slot,
446 TypeofState typeof_state,
447 Result* result,
448 JumpTarget* slow,
449 JumpTarget* done);
450
451 // Store the value on top of the expression stack into a slot, leaving the
452 // value in place.
453 void StoreToSlot(Slot* slot, InitState init_state);
454
455 // Support for compiling assignment expressions.
456 void EmitSlotAssignment(Assignment* node);
457 void EmitNamedPropertyAssignment(Assignment* node);
458 void EmitKeyedPropertyAssignment(Assignment* node);
459
460 // Receiver is passed on the frame and not consumed.
461 Result EmitNamedLoad(Handle<String> name, bool is_contextual);
462
463 // If the store is contextual, value is passed on the frame and consumed.
464 // Otherwise, receiver and value are passed on the frame and consumed.
465 Result EmitNamedStore(Handle<String> name, bool is_contextual);
466
467 // Load a property of an object, returning it in a Result.
468 // The object and the property name are passed on the stack, and
469 // not changed.
470 Result EmitKeyedLoad();
471
472 // Receiver, key, and value are passed on the frame and consumed.
473 Result EmitKeyedStore(StaticType* key_type);
474
475 // Special code for typeof expressions: Unfortunately, we must
476 // be careful when loading the expression in 'typeof'
477 // expressions. We are not allowed to throw reference errors for
478 // non-existing properties of the global object, so we must make it
479 // look like an explicit property access, instead of an access
480 // through the context chain.
481 void LoadTypeofExpression(Expression* x);
482
483 // Translate the value on top of the frame into control flow to the
484 // control destination.
485 void ToBoolean(ControlDestination* destination);
486
487 // Generate code that computes a shortcutting logical operation.
488 void GenerateLogicalBooleanOperation(BinaryOperation* node);
489
490 void GenericBinaryOperation(BinaryOperation* expr,
491 OverwriteMode overwrite_mode);
492
493 // Generate a stub call from the virtual frame.
494 Result GenerateGenericBinaryOpStubCall(GenericBinaryOpStub* stub,
495 Result* left,
496 Result* right);
497
498 // Emits code sequence that jumps to a JumpTarget if the inputs
499 // are both smis. Cannot be in MacroAssembler because it takes
500 // advantage of TypeInfo to skip unneeded checks.
501 void JumpIfBothSmiUsingTypeInfo(Result* left,
502 Result* right,
503 JumpTarget* both_smi);
504
505 // Emits code sequence that jumps to deferred code if the input
506 // is not a smi. Cannot be in MacroAssembler because it takes
507 // advantage of TypeInfo to skip unneeded checks.
508 void JumpIfNotSmiUsingTypeInfo(Register reg,
509 TypeInfo type,
510 DeferredCode* deferred);
511
512 // Emits code sequence that jumps to deferred code if the inputs
513 // are not both smis. Cannot be in MacroAssembler because it takes
514 // advantage of TypeInfo to skip unneeded checks.
515 void JumpIfNotBothSmiUsingTypeInfo(Register left,
516 Register right,
517 TypeInfo left_info,
518 TypeInfo right_info,
519 DeferredCode* deferred);
520
521 // If possible, combine two constant smi values using op to produce
522 // a smi result, and push it on the virtual frame, all at compile time.
523 // Returns true if it succeeds. Otherwise it has no effect.
524 bool FoldConstantSmis(Token::Value op, int left, int right);
525
526 // Emit code to perform a binary operation on a constant
527 // smi and a likely smi. Consumes the Result *operand.
528 Result ConstantSmiBinaryOperation(BinaryOperation* expr,
529 Result* operand,
530 Handle<Object> constant_operand,
531 bool reversed,
532 OverwriteMode overwrite_mode);
533
534 // Emit code to perform a binary operation on two likely smis.
535 // The code to handle smi arguments is produced inline.
536 // Consumes the Results *left and *right.
537 Result LikelySmiBinaryOperation(BinaryOperation* expr,
538 Result* left,
539 Result* right,
540 OverwriteMode overwrite_mode);
541
542 void Comparison(AstNode* node,
543 Condition cc,
544 bool strict,
545 ControlDestination* destination);
546
547 // If at least one of the sides is a constant smi, generate optimized code.
548 void ConstantSmiComparison(Condition cc,
549 bool strict,
550 ControlDestination* destination,
551 Result* left_side,
552 Result* right_side,
553 bool left_side_constant_smi,
554 bool right_side_constant_smi,
555 bool is_loop_condition);
556
557 void GenerateInlineNumberComparison(Result* left_side,
558 Result* right_side,
559 Condition cc,
560 ControlDestination* dest);
561
562 // To prevent long attacker-controlled byte sequences, integer constants
563 // from the JavaScript source are loaded in two parts if they are larger
564 // than 16 bits.
565 static const int kMaxSmiInlinedBits = 16;
566 bool IsUnsafeSmi(Handle<Object> value);
567 // Load an integer constant x into a register target using
568 // at most 16 bits of user-controlled data per assembly operation.
569 void LoadUnsafeSmi(Register target, Handle<Object> value);
570
571 void CallWithArguments(ZoneList<Expression*>* arguments,
572 CallFunctionFlags flags,
573 int position);
574
575 // An optimized implementation of expressions of the form
576 // x.apply(y, arguments). We call x the applicand and y the receiver.
577 // The optimization avoids allocating an arguments object if possible.
578 void CallApplyLazy(Expression* applicand,
579 Expression* receiver,
580 VariableProxy* arguments,
581 int position);
582
583 void CheckStack();
584
585 bool CheckForInlineRuntimeCall(CallRuntime* node);
586
587 void ProcessDeclarations(ZoneList<Declaration*>* declarations);
588
589 // Declare global variables and functions in the given array of
590 // name/value pairs.
591 void DeclareGlobals(Handle<FixedArray> pairs);
592
593 // Instantiate the function based on the shared function info.
594 void InstantiateFunction(Handle<SharedFunctionInfo> function_info,
595 bool pretenure);
596
597 // Support for type checks.
598 void GenerateIsSmi(ZoneList<Expression*>* args);
599 void GenerateIsNonNegativeSmi(ZoneList<Expression*>* args);
600 void GenerateIsArray(ZoneList<Expression*>* args);
601 void GenerateIsRegExp(ZoneList<Expression*>* args);
602 void GenerateIsObject(ZoneList<Expression*>* args);
603 void GenerateIsSpecObject(ZoneList<Expression*>* args);
604 void GenerateIsFunction(ZoneList<Expression*>* args);
605 void GenerateIsUndetectableObject(ZoneList<Expression*>* args);
606 void GenerateIsStringWrapperSafeForDefaultValueOf(
607 ZoneList<Expression*>* args);
608
609 // Support for construct call checks.
610 void GenerateIsConstructCall(ZoneList<Expression*>* args);
611
612 // Support for arguments.length and arguments[?].
613 void GenerateArgumentsLength(ZoneList<Expression*>* args);
614 void GenerateArguments(ZoneList<Expression*>* args);
615
616 // Support for accessing the class and value fields of an object.
617 void GenerateClassOf(ZoneList<Expression*>* args);
618 void GenerateValueOf(ZoneList<Expression*>* args);
619 void GenerateSetValueOf(ZoneList<Expression*>* args);
620
621 // Fast support for charCodeAt(n).
622 void GenerateStringCharCodeAt(ZoneList<Expression*>* args);
623
624 // Fast support for string.charAt(n) and string[n].
625 void GenerateStringCharFromCode(ZoneList<Expression*>* args);
626
627 // Fast support for string.charAt(n) and string[n].
628 void GenerateStringCharAt(ZoneList<Expression*>* args);
629
630 // Fast support for object equality testing.
631 void GenerateObjectEquals(ZoneList<Expression*>* args);
632
633 void GenerateLog(ZoneList<Expression*>* args);
634
635 void GenerateGetFramePointer(ZoneList<Expression*>* args);
636
637 // Fast support for Math.random().
638 void GenerateRandomHeapNumber(ZoneList<Expression*>* args);
639
640 // Fast support for StringAdd.
641 void GenerateStringAdd(ZoneList<Expression*>* args);
642
643 // Fast support for SubString.
644 void GenerateSubString(ZoneList<Expression*>* args);
645
646 // Fast support for StringCompare.
647 void GenerateStringCompare(ZoneList<Expression*>* args);
648
649 // Support for direct calls from JavaScript to native RegExp code.
650 void GenerateRegExpExec(ZoneList<Expression*>* args);
651
652 void GenerateRegExpConstructResult(ZoneList<Expression*>* args);
653
654 // Support for fast native caches.
655 void GenerateGetFromCache(ZoneList<Expression*>* args);
656
657 // Fast support for number to string.
658 void GenerateNumberToString(ZoneList<Expression*>* args);
659
660 // Fast swapping of elements. Takes three expressions, the object and two
661 // indices. This should only be used if the indices are known to be
662 // non-negative and within bounds of the elements array at the call site.
663 void GenerateSwapElements(ZoneList<Expression*>* args);
664
665 // Fast call for custom callbacks.
666 void GenerateCallFunction(ZoneList<Expression*>* args);
667
668 // Fast call to math functions.
669 void GenerateMathPow(ZoneList<Expression*>* args);
670 void GenerateMathSin(ZoneList<Expression*>* args);
671 void GenerateMathCos(ZoneList<Expression*>* args);
672 void GenerateMathSqrt(ZoneList<Expression*>* args);
673 void GenerateMathLog(ZoneList<Expression*>* args);
674
675 // Check whether two RegExps are equivalent.
676 void GenerateIsRegExpEquivalent(ZoneList<Expression*>* args);
677
678 void GenerateHasCachedArrayIndex(ZoneList<Expression*>* args);
679 void GenerateGetCachedArrayIndex(ZoneList<Expression*>* args);
680 void GenerateFastAsciiArrayJoin(ZoneList<Expression*>* args);
681
682 // Simple condition analysis.
683 enum ConditionAnalysis {
684 ALWAYS_TRUE,
685 ALWAYS_FALSE,
686 DONT_KNOW
687 };
688 ConditionAnalysis AnalyzeCondition(Expression* cond);
689
690 // Methods used to indicate which source code is generated for. Source
691 // positions are collected by the assembler and emitted with the relocation
692 // information.
693 void CodeForFunctionPosition(FunctionLiteral* fun);
694 void CodeForReturnPosition(FunctionLiteral* fun);
695 void CodeForStatementPosition(Statement* node);
696 void CodeForDoWhileConditionPosition(DoWhileStatement* stmt);
697 void CodeForSourcePosition(int pos);
698
699 void SetTypeForStackSlot(Slot* slot, TypeInfo info);
700
701 #ifdef DEBUG
702 // True if the registers are valid for entry to a block. There should
703 // be no frame-external references to (non-reserved) registers.
704 bool HasValidEntryRegisters();
705 #endif
706
707 ZoneList<DeferredCode*> deferred_;
708
709 // Assembler
710 MacroAssembler* masm_; // to generate code
711
712 CompilationInfo* info_;
713
714 // Code generation state
715 VirtualFrame* frame_;
716 RegisterAllocator* allocator_;
717 CodeGenState* state_;
718 int loop_nesting_;
719
720 // Jump targets.
721 // The target of the return from the function.
722 BreakTarget function_return_;
723
724 // True if the function return is shadowed (ie, jumping to the target
725 // function_return_ does not jump to the true function return, but rather
726 // to some unlinking code).
727 bool function_return_is_shadowed_;
728
729 // True when we are in code that expects the virtual frame to be fully
730 // spilled. Some virtual frame function are disabled in DEBUG builds when
731 // called from spilled code, because they do not leave the virtual frame
732 // in a spilled state.
733 bool in_spilled_code_;
734
735 friend class VirtualFrame;
736 friend class Isolate;
737 friend class JumpTarget;
738 friend class Reference;
739 friend class Result;
740 friend class FastCodeGenerator;
741 friend class FullCodeGenerator;
742 friend class FullCodeGenSyntaxChecker;
743
744 friend class CodeGeneratorPatcher; // Used in test-log-stack-tracer.cc
745 friend class InlineRuntimeFunctionsTable;
746
747 DISALLOW_COPY_AND_ASSIGN(CodeGenerator); 70 DISALLOW_COPY_AND_ASSIGN(CodeGenerator);
748 }; 71 };
749 72
750 73
751 } } // namespace v8::internal 74 } } // namespace v8::internal
752 75
753 #endif // V8_X64_CODEGEN_X64_H_ 76 #endif // V8_X64_CODEGEN_X64_H_
OLDNEW
« no previous file with comments | « src/x64/builtins-x64.cc ('k') | src/x64/codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698