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

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

Issue 2084017: Version 2.2.11... (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
Patch Set: Created 10 years, 7 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/flag-definitions.h ('k') | src/full-codegen.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 2009 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
11 // with the distribution. 11 // with the distribution.
(...skipping 12 matching lines...) Expand all
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_FULL_CODEGEN_H_ 28 #ifndef V8_FULL_CODEGEN_H_
29 #define V8_FULL_CODEGEN_H_ 29 #define V8_FULL_CODEGEN_H_
30 30
31 #include "v8.h" 31 #include "v8.h"
32 32
33 #include "ast.h" 33 #include "ast.h"
34 #include "compiler.h"
34 35
35 namespace v8 { 36 namespace v8 {
36 namespace internal { 37 namespace internal {
37 38
38 class FullCodeGenSyntaxChecker: public AstVisitor { 39 class FullCodeGenSyntaxChecker: public AstVisitor {
39 public: 40 public:
40 FullCodeGenSyntaxChecker() : has_supported_syntax_(true) {} 41 FullCodeGenSyntaxChecker() : has_supported_syntax_(true) {}
41 42
42 void Check(FunctionLiteral* fun); 43 void Check(FunctionLiteral* fun);
43 44
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 public: 223 public:
223 ForIn(FullCodeGenerator* codegen, 224 ForIn(FullCodeGenerator* codegen,
224 ForInStatement* statement) 225 ForInStatement* statement)
225 : Iteration(codegen, statement) { } 226 : Iteration(codegen, statement) { }
226 virtual ~ForIn() {} 227 virtual ~ForIn() {}
227 virtual ForIn* AsForIn() { return this; } 228 virtual ForIn* AsForIn() { return this; }
228 virtual int Exit(int stack_depth) { 229 virtual int Exit(int stack_depth) {
229 return stack_depth + kForInStackElementCount; 230 return stack_depth + kForInStackElementCount;
230 } 231 }
231 private: 232 private:
232 // TODO(lrn): Check that this value is correct when implementing
233 // for-in.
234 static const int kForInStackElementCount = 5; 233 static const int kForInStackElementCount = 5;
235 DISALLOW_COPY_AND_ASSIGN(ForIn); 234 DISALLOW_COPY_AND_ASSIGN(ForIn);
236 }; 235 };
237 236
238 enum Location { 237 enum Location {
239 kAccumulator, 238 kAccumulator,
240 kStack 239 kStack
241 }; 240 };
242 241
243 int SlotOffset(Slot* slot); 242 int SlotOffset(Slot* slot);
244 243
245 // Emit code to convert a pure value (in a register, slot, as a literal, 244 // Emit code to convert a pure value (in a register, slot, as a literal,
246 // or on top of the stack) into the result expected according to an 245 // or on top of the stack) into the result expected according to an
247 // expression context. 246 // expression context.
248 void Apply(Expression::Context context, Register reg); 247 void Apply(Expression::Context context, Register reg);
249 248
250 // Slot cannot have type Slot::LOOKUP. 249 // Slot cannot have type Slot::LOOKUP.
251 void Apply(Expression::Context context, Slot* slot); 250 void Apply(Expression::Context context, Slot* slot);
252 251
253 void Apply(Expression::Context context, Literal* lit); 252 void Apply(Expression::Context context, Literal* lit);
254 void ApplyTOS(Expression::Context context); 253 void ApplyTOS(Expression::Context context);
255 254
256 // Emit code to discard count elements from the top of stack, then convert 255 // Emit code to discard count elements from the top of stack, then convert
257 // a pure value into the result expected according to an expression 256 // a pure value into the result expected according to an expression
258 // context. 257 // context.
259 void DropAndApply(int count, Expression::Context context, Register reg); 258 void DropAndApply(int count, Expression::Context context, Register reg);
260 259
260 // Set up branch labels for a test expression.
261 void PrepareTest(Label* materialize_true,
262 Label* materialize_false,
263 Label** if_true,
264 Label** if_false);
265
261 // Emit code to convert pure control flow to a pair of labels into the 266 // Emit code to convert pure control flow to a pair of labels into the
262 // result expected according to an expression context. 267 // result expected according to an expression context.
263 void Apply(Expression::Context context, 268 void Apply(Expression::Context context,
264 Label* materialize_true, 269 Label* materialize_true,
265 Label* materialize_false); 270 Label* materialize_false);
266 271
272 // Emit code to convert constant control flow (true or false) into
273 // the result expected according to an expression context.
274 void Apply(Expression::Context context, bool flag);
275
267 // Helper function to convert a pure value into a test context. The value 276 // Helper function to convert a pure value into a test context. The value
268 // is expected on the stack or the accumulator, depending on the platform. 277 // is expected on the stack or the accumulator, depending on the platform.
269 // See the platform-specific implementation for details. 278 // See the platform-specific implementation for details.
270 void DoTest(Expression::Context context); 279 void DoTest(Expression::Context context);
271 280
272 void Move(Slot* dst, Register source, Register scratch1, Register scratch2); 281 void Move(Slot* dst, Register source, Register scratch1, Register scratch2);
273 void Move(Register dst, Slot* source); 282 void Move(Register dst, Slot* source);
274 283
275 // Return an operand used to read/write to a known (ie, non-LOOKUP) slot. 284 // Return an operand used to read/write to a known (ie, non-LOOKUP) slot.
276 // May emit code to traverse the context chain, destroying the scratch 285 // May emit code to traverse the context chain, destroying the scratch
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 Visit(expr); 350 Visit(expr);
342 context_ = saved_context; 351 context_ = saved_context;
343 location_ = saved_location; 352 location_ = saved_location;
344 true_label_ = saved_true; 353 true_label_ = saved_true;
345 false_label_ = saved_false; 354 false_label_ = saved_false;
346 } 355 }
347 356
348 void VisitDeclarations(ZoneList<Declaration*>* declarations); 357 void VisitDeclarations(ZoneList<Declaration*>* declarations);
349 void DeclareGlobals(Handle<FixedArray> pairs); 358 void DeclareGlobals(Handle<FixedArray> pairs);
350 359
360 // Platform-specific code for a variable, constant, or function
361 // declaration. Functions have an initial value.
362 void EmitDeclaration(Variable* variable,
363 Variable::Mode mode,
364 FunctionLiteral* function);
365
351 // Platform-specific return sequence 366 // Platform-specific return sequence
352 void EmitReturnSequence(int position); 367 void EmitReturnSequence(int position);
353 368
354 // Platform-specific code sequences for calls 369 // Platform-specific code sequences for calls
355 void EmitCallWithStub(Call* expr); 370 void EmitCallWithStub(Call* expr);
356 void EmitCallWithIC(Call* expr, Handle<Object> name, RelocInfo::Mode mode); 371 void EmitCallWithIC(Call* expr, Handle<Object> name, RelocInfo::Mode mode);
357 372
373
374 // Platform-specific code for inline runtime calls.
375 void EmitInlineRuntimeCall(CallRuntime* expr);
376 void EmitIsSmi(ZoneList<Expression*>* arguments);
377 void EmitIsNonNegativeSmi(ZoneList<Expression*>* arguments);
378 void EmitIsObject(ZoneList<Expression*>* arguments);
379 void EmitIsUndetectableObject(ZoneList<Expression*>* arguments);
380 void EmitIsFunction(ZoneList<Expression*>* arguments);
381 void EmitIsArray(ZoneList<Expression*>* arguments);
382 void EmitIsRegExp(ZoneList<Expression*>* arguments);
383 void EmitIsConstructCall(ZoneList<Expression*>* arguments);
384 void EmitObjectEquals(ZoneList<Expression*>* arguments);
385 void EmitArguments(ZoneList<Expression*>* arguments);
386 void EmitArgumentsLength(ZoneList<Expression*>* arguments);
387 void EmitClassOf(ZoneList<Expression*>* arguments);
388 void EmitValueOf(ZoneList<Expression*>* arguments);
389 void EmitSetValueOf(ZoneList<Expression*>* arguments);
390 void EmitNumberToString(ZoneList<Expression*>* arguments);
391 void EmitCharFromCode(ZoneList<Expression*>* arguments);
392 void EmitFastCharCodeAt(ZoneList<Expression*>* arguments);
393 void EmitStringCompare(ZoneList<Expression*>* arguments);
394 void EmitStringAdd(ZoneList<Expression*>* arguments);
395 void EmitLog(ZoneList<Expression*>* arguments);
396 void EmitRandomHeapNumber(ZoneList<Expression*>* arguments);
397 void EmitSubString(ZoneList<Expression*>* arguments);
398 void EmitRegExpExec(ZoneList<Expression*>* arguments);
399 void EmitMathPow(ZoneList<Expression*>* arguments);
400 void EmitMathSin(ZoneList<Expression*>* arguments);
401 void EmitMathCos(ZoneList<Expression*>* arguments);
402 void EmitMathSqrt(ZoneList<Expression*>* arguments);
403 void EmitCallFunction(ZoneList<Expression*>* arguments);
404 void EmitRegExpConstructResult(ZoneList<Expression*>* arguments);
405 void EmitSwapElements(ZoneList<Expression*>* arguments);
406 void EmitGetFromCache(ZoneList<Expression*>* arguments);
407
358 // Platform-specific code for loading variables. 408 // Platform-specific code for loading variables.
359 void EmitVariableLoad(Variable* expr, Expression::Context context); 409 void EmitVariableLoad(Variable* expr, Expression::Context context);
360 410
411 // Platform-specific support for allocating a new closure based on
412 // the given function info.
413 void EmitNewClosure(Handle<SharedFunctionInfo> info);
414
361 // Platform-specific support for compiling assignments. 415 // Platform-specific support for compiling assignments.
362 416
363 // Load a value from a named property. 417 // Load a value from a named property.
364 // The receiver is left on the stack by the IC. 418 // The receiver is left on the stack by the IC.
365 void EmitNamedPropertyLoad(Property* expr); 419 void EmitNamedPropertyLoad(Property* expr);
366 420
367 // Load a value from a keyed property. 421 // Load a value from a keyed property.
368 // The receiver and the key is left on the stack by the IC. 422 // The receiver and the key is left on the stack by the IC.
369 void EmitKeyedPropertyLoad(Property* expr); 423 void EmitKeyedPropertyLoad(Property* expr);
370 424
371 // Apply the compound assignment operator. Expects the left operand on top 425 // Apply the compound assignment operator. Expects the left operand on top
372 // of the stack and the right one in the accumulator. 426 // of the stack and the right one in the accumulator.
373 void EmitBinaryOp(Token::Value op, Expression::Context context); 427 void EmitBinaryOp(Token::Value op, Expression::Context context);
374 428
429 // Assign to the given expression as if via '='. The right-hand-side value
430 // is expected in the accumulator.
431 void EmitAssignment(Expression* expr);
432
375 // Complete a variable assignment. The right-hand-side value is expected 433 // Complete a variable assignment. The right-hand-side value is expected
376 // in the accumulator. 434 // in the accumulator.
377 void EmitVariableAssignment(Variable* var, Expression::Context context); 435 void EmitVariableAssignment(Variable* var,
436 Token::Value op,
437 Expression::Context context);
378 438
379 // Complete a named property assignment. The receiver is expected on top 439 // Complete a named property assignment. The receiver is expected on top
380 // of the stack and the right-hand-side value in the accumulator. 440 // of the stack and the right-hand-side value in the accumulator.
381 void EmitNamedPropertyAssignment(Assignment* expr); 441 void EmitNamedPropertyAssignment(Assignment* expr);
382 442
383 // Complete a keyed property assignment. The receiver and key are 443 // Complete a keyed property assignment. The receiver and key are
384 // expected on top of the stack and the right-hand-side value in the 444 // expected on top of the stack and the right-hand-side value in the
385 // accumulator. 445 // accumulator.
386 void EmitKeyedPropertyAssignment(Assignment* expr); 446 void EmitKeyedPropertyAssignment(Assignment* expr);
387 447
448 // Helper for compare operations. Expects the null-value in a register.
449 void EmitNullCompare(bool strict,
450 Register obj,
451 Register null_const,
452 Label* if_true,
453 Label* if_false,
454 Register scratch);
455
388 void SetFunctionPosition(FunctionLiteral* fun); 456 void SetFunctionPosition(FunctionLiteral* fun);
389 void SetReturnPosition(FunctionLiteral* fun); 457 void SetReturnPosition(FunctionLiteral* fun);
390 void SetStatementPosition(Statement* stmt); 458 void SetStatementPosition(Statement* stmt);
391 void SetStatementPosition(int pos); 459 void SetStatementPosition(int pos);
392 void SetSourcePosition(int pos); 460 void SetSourcePosition(int pos);
393 461
394 // Non-local control flow support. 462 // Non-local control flow support.
395 void EnterFinallyBlock(); 463 void EnterFinallyBlock();
396 void ExitFinallyBlock(); 464 void ExitFinallyBlock();
397 465
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 510
443 friend class NestedStatement; 511 friend class NestedStatement;
444 512
445 DISALLOW_COPY_AND_ASSIGN(FullCodeGenerator); 513 DISALLOW_COPY_AND_ASSIGN(FullCodeGenerator);
446 }; 514 };
447 515
448 516
449 } } // namespace v8::internal 517 } } // namespace v8::internal
450 518
451 #endif // V8_FULL_CODEGEN_H_ 519 #endif // V8_FULL_CODEGEN_H_
OLDNEW
« no previous file with comments | « src/flag-definitions.h ('k') | src/full-codegen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698