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

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

Issue 655002: Merge revisions 3777-3813 from bleding_edge to partial snapshots ... (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/partial_snapshots/
Patch Set: Created 10 years, 10 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/arm/assembler-thumb2.h ('k') | src/arm/codegen-arm.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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 // compiler and needs to setup everything or the compiler is used as 154 // compiler and needs to setup everything or the compiler is used as
155 // the secondary compiler for split compilation and has to handle 155 // the secondary compiler for split compilation and has to handle
156 // bailouts. 156 // bailouts.
157 enum Mode { 157 enum Mode {
158 PRIMARY, 158 PRIMARY,
159 SECONDARY 159 SECONDARY
160 }; 160 };
161 161
162 // Takes a function literal, generates code for it. This function should only 162 // Takes a function literal, generates code for it. This function should only
163 // be called by compiler.cc. 163 // be called by compiler.cc.
164 static Handle<Code> MakeCode(FunctionLiteral* fun, 164 static Handle<Code> MakeCode(CompilationInfo* info);
165 Handle<Script> script,
166 bool is_eval,
167 CompilationInfo* info);
168 165
169 // Printing of AST, etc. as requested by flags. 166 // Printing of AST, etc. as requested by flags.
170 static void MakeCodePrologue(FunctionLiteral* fun); 167 static void MakeCodePrologue(CompilationInfo* info);
171 168
172 // Allocate and install the code. 169 // Allocate and install the code.
173 static Handle<Code> MakeCodeEpilogue(FunctionLiteral* fun, 170 static Handle<Code> MakeCodeEpilogue(MacroAssembler* masm,
174 MacroAssembler* masm,
175 Code::Flags flags, 171 Code::Flags flags,
176 Handle<Script> script); 172 CompilationInfo* info);
177 173
178 #ifdef ENABLE_LOGGING_AND_PROFILING 174 #ifdef ENABLE_LOGGING_AND_PROFILING
179 static bool ShouldGenerateLog(Expression* type); 175 static bool ShouldGenerateLog(Expression* type);
180 #endif 176 #endif
181 177
182 static void SetFunctionInfo(Handle<JSFunction> fun, 178 static void SetFunctionInfo(Handle<JSFunction> fun,
183 FunctionLiteral* lit, 179 FunctionLiteral* lit,
184 bool is_toplevel, 180 bool is_toplevel,
185 Handle<Script> script); 181 Handle<Script> script);
186 182
187 static void RecordPositions(MacroAssembler* masm, int pos); 183 static void RecordPositions(MacroAssembler* masm, int pos);
188 184
189 // Accessors 185 // Accessors
190 MacroAssembler* masm() { return masm_; } 186 MacroAssembler* masm() { return masm_; }
191 VirtualFrame* frame() const { return frame_; } 187 VirtualFrame* frame() const { return frame_; }
192 Handle<Script> script() { return script_; } 188 inline Handle<Script> script();
193 189
194 bool has_valid_frame() const { return frame_ != NULL; } 190 bool has_valid_frame() const { return frame_ != NULL; }
195 191
196 // Set the virtual frame to be new_frame, with non-frame register 192 // Set the virtual frame to be new_frame, with non-frame register
197 // reference counts given by non_frame_registers. The non-frame 193 // reference counts given by non_frame_registers. The non-frame
198 // register reference counts of the old frame are returned in 194 // register reference counts of the old frame are returned in
199 // non_frame_registers. 195 // non_frame_registers.
200 void SetFrame(VirtualFrame* new_frame, RegisterFile* non_frame_registers); 196 void SetFrame(VirtualFrame* new_frame, RegisterFile* non_frame_registers);
201 197
202 void DeleteFrame(); 198 void DeleteFrame();
203 199
204 RegisterAllocator* allocator() const { return allocator_; } 200 RegisterAllocator* allocator() const { return allocator_; }
205 201
206 CodeGenState* state() { return state_; } 202 CodeGenState* state() { return state_; }
207 void set_state(CodeGenState* state) { state_ = state; } 203 void set_state(CodeGenState* state) { state_ = state; }
208 204
209 void AddDeferred(DeferredCode* code) { deferred_.Add(code); } 205 void AddDeferred(DeferredCode* code) { deferred_.Add(code); }
210 206
211 static const int kUnknownIntValue = -1; 207 static const int kUnknownIntValue = -1;
212 208
213 private: 209 private:
214 // Construction/Destruction 210 // Construction/Destruction
215 CodeGenerator(MacroAssembler* masm, Handle<Script> script, bool is_eval); 211 explicit CodeGenerator(MacroAssembler* masm);
216 212
217 // Accessors 213 // Accessors
218 Scope* scope() const { return scope_; } 214 inline bool is_eval();
215 Scope* scope();
219 216
220 // Generating deferred code. 217 // Generating deferred code.
221 void ProcessDeferred(); 218 void ProcessDeferred();
222 219
223 bool is_eval() { return is_eval_; }
224
225 // State 220 // State
226 bool has_cc() const { return cc_reg_ != al; } 221 bool has_cc() const { return cc_reg_ != al; }
227 JumpTarget* true_target() const { return state_->true_target(); } 222 JumpTarget* true_target() const { return state_->true_target(); }
228 JumpTarget* false_target() const { return state_->false_target(); } 223 JumpTarget* false_target() const { return state_->false_target(); }
229 224
230 // We don't track loop nesting level on ARM yet. 225 // We don't track loop nesting level on ARM yet.
231 int loop_nesting() const { return 0; } 226 int loop_nesting() const { return 0; }
232 227
233 // Node visitors. 228 // Node visitors.
234 void VisitStatements(ZoneList<Statement*>* statements); 229 void VisitStatements(ZoneList<Statement*>* statements);
235 230
236 #define DEF_VISIT(type) \ 231 #define DEF_VISIT(type) \
237 void Visit##type(type* node); 232 void Visit##type(type* node);
238 AST_NODE_LIST(DEF_VISIT) 233 AST_NODE_LIST(DEF_VISIT)
239 #undef DEF_VISIT 234 #undef DEF_VISIT
240 235
241 // Visit a statement and then spill the virtual frame if control flow can 236 // Visit a statement and then spill the virtual frame if control flow can
242 // reach the end of the statement (ie, it does not exit via break, 237 // reach the end of the statement (ie, it does not exit via break,
243 // continue, return, or throw). This function is used temporarily while 238 // continue, return, or throw). This function is used temporarily while
244 // the code generator is being transformed. 239 // the code generator is being transformed.
245 inline void VisitAndSpill(Statement* statement); 240 inline void VisitAndSpill(Statement* statement);
246 241
247 // Visit a list of statements and then spill the virtual frame if control 242 // Visit a list of statements and then spill the virtual frame if control
248 // flow can reach the end of the list. 243 // flow can reach the end of the list.
249 inline void VisitStatementsAndSpill(ZoneList<Statement*>* statements); 244 inline void VisitStatementsAndSpill(ZoneList<Statement*>* statements);
250 245
251 // Main code generation function 246 // Main code generation function
252 void Generate(FunctionLiteral* fun, Mode mode, CompilationInfo* info); 247 void Generate(CompilationInfo* info, Mode mode);
253 248
254 // The following are used by class Reference. 249 // The following are used by class Reference.
255 void LoadReference(Reference* ref); 250 void LoadReference(Reference* ref);
256 void UnloadReference(Reference* ref); 251 void UnloadReference(Reference* ref);
257 252
258 static MemOperand ContextOperand(Register context, int index) { 253 static MemOperand ContextOperand(Register context, int index) {
259 return MemOperand(context, Context::SlotOffset(index)); 254 return MemOperand(context, Context::SlotOffset(index));
260 } 255 }
261 256
262 MemOperand SlotOperand(Slot* slot, Register tmp); 257 MemOperand SlotOperand(Slot* slot, Register tmp);
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 void CodeForReturnPosition(FunctionLiteral* fun); 413 void CodeForReturnPosition(FunctionLiteral* fun);
419 void CodeForStatementPosition(Statement* node); 414 void CodeForStatementPosition(Statement* node);
420 void CodeForDoWhileConditionPosition(DoWhileStatement* stmt); 415 void CodeForDoWhileConditionPosition(DoWhileStatement* stmt);
421 void CodeForSourcePosition(int pos); 416 void CodeForSourcePosition(int pos);
422 417
423 #ifdef DEBUG 418 #ifdef DEBUG
424 // True if the registers are valid for entry to a block. 419 // True if the registers are valid for entry to a block.
425 bool HasValidEntryRegisters(); 420 bool HasValidEntryRegisters();
426 #endif 421 #endif
427 422
428 bool is_eval_; // Tells whether code is generated for eval.
429
430 Handle<Script> script_;
431 List<DeferredCode*> deferred_; 423 List<DeferredCode*> deferred_;
432 424
433 // Assembler 425 // Assembler
434 MacroAssembler* masm_; // to generate code 426 MacroAssembler* masm_; // to generate code
435 427
428 CompilationInfo* info_;
429
436 // Code generation state 430 // Code generation state
437 Scope* scope_;
438 VirtualFrame* frame_; 431 VirtualFrame* frame_;
439 RegisterAllocator* allocator_; 432 RegisterAllocator* allocator_;
440 Condition cc_reg_; 433 Condition cc_reg_;
441 CodeGenState* state_; 434 CodeGenState* state_;
442 435
443 // Jump targets 436 // Jump targets
444 BreakTarget function_return_; 437 BreakTarget function_return_;
445 438
446 // True if the function return is shadowed (ie, jumping to the target 439 // True if the function return is shadowed (ie, jumping to the target
447 // function_return_ does not jump to the true function return, but rather 440 // function_return_ does not jump to the true function return, but rather
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 } else { 524 } else {
532 PrintF("GenericBinaryOpStub (%s by %d)\n", 525 PrintF("GenericBinaryOpStub (%s by %d)\n",
533 Token::String(op_), 526 Token::String(op_),
534 constant_rhs_); 527 constant_rhs_);
535 } 528 }
536 } 529 }
537 #endif 530 #endif
538 }; 531 };
539 532
540 533
534 class StringStubBase: public CodeStub {
535 public:
536 // Generate code for copying characters using a simple loop. This should only
537 // be used in places where the number of characters is small and the
538 // additional setup and checking in GenerateCopyCharactersLong adds too much
539 // overhead. Copying of overlapping regions is not supported.
540 // Dest register ends at the position after the last character written.
541 void GenerateCopyCharacters(MacroAssembler* masm,
542 Register dest,
543 Register src,
544 Register count,
545 Register scratch,
546 bool ascii);
547
548 // Generate code for copying a large number of characters. This function
549 // is allowed to spend extra time setting up conditions to make copying
550 // faster. Copying of overlapping regions is not supported.
551 // Dest register ends at the position after the last character written.
552 void GenerateCopyCharactersLong(MacroAssembler* masm,
553 Register dest,
554 Register src,
555 Register count,
556 Register scratch1,
557 Register scratch2,
558 Register scratch3,
559 Register scratch4,
560 Register scratch5,
561 int flags);
562 };
563
564
565 // Flag that indicates how to generate code for the stub StringAddStub.
566 enum StringAddFlags {
567 NO_STRING_ADD_FLAGS = 0,
568 NO_STRING_CHECK_IN_STUB = 1 << 0 // Omit string check in stub.
569 };
570
571
572 class StringAddStub: public StringStubBase {
573 public:
574 explicit StringAddStub(StringAddFlags flags) {
575 string_check_ = ((flags & NO_STRING_CHECK_IN_STUB) == 0);
576 }
577
578 private:
579 Major MajorKey() { return StringAdd; }
580 int MinorKey() { return string_check_ ? 0 : 1; }
581
582 void Generate(MacroAssembler* masm);
583
584 // Should the stub check whether arguments are strings?
585 bool string_check_;
586 };
587
588
589 class SubStringStub: public StringStubBase {
590 public:
591 SubStringStub() {}
592
593 private:
594 Major MajorKey() { return SubString; }
595 int MinorKey() { return 0; }
596
597 void Generate(MacroAssembler* masm);
598 };
599
600
601
541 class StringCompareStub: public CodeStub { 602 class StringCompareStub: public CodeStub {
542 public: 603 public:
543 StringCompareStub() { } 604 StringCompareStub() { }
544 605
545 // Compare two flat ASCII strings and returns result in r0. 606 // Compare two flat ASCII strings and returns result in r0.
546 // Does not use the stack. 607 // Does not use the stack.
547 static void GenerateCompareFlatAsciiStrings(MacroAssembler* masm, 608 static void GenerateCompareFlatAsciiStrings(MacroAssembler* masm,
548 Register left, 609 Register left,
549 Register right, 610 Register right,
550 Register scratch1, 611 Register scratch1,
551 Register scratch2, 612 Register scratch2,
552 Register scratch3, 613 Register scratch3,
553 Register scratch4); 614 Register scratch4);
554 615
555 private: 616 private:
556 Major MajorKey() { return StringCompare; } 617 Major MajorKey() { return StringCompare; }
557 int MinorKey() { return 0; } 618 int MinorKey() { return 0; }
558 619
559 void Generate(MacroAssembler* masm); 620 void Generate(MacroAssembler* masm);
560 }; 621 };
561 622
562 623
563 } } // namespace v8::internal 624 } } // namespace v8::internal
564 625
565 #endif // V8_ARM_CODEGEN_ARM_H_ 626 #endif // V8_ARM_CODEGEN_ARM_H_
OLDNEW
« no previous file with comments | « src/arm/assembler-thumb2.h ('k') | src/arm/codegen-arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698