OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
498 } | 498 } |
499 | 499 |
500 | 500 |
501 void FullCodeGenerator::SetSourcePosition(int pos) { | 501 void FullCodeGenerator::SetSourcePosition(int pos) { |
502 if (FLAG_debug_info && pos != RelocInfo::kNoPosition) { | 502 if (FLAG_debug_info && pos != RelocInfo::kNoPosition) { |
503 masm_->RecordPosition(pos); | 503 masm_->RecordPosition(pos); |
504 } | 504 } |
505 } | 505 } |
506 | 506 |
507 | 507 |
508 void FullCodeGenerator::EmitInlineRuntimeCall(CallRuntime* expr) { | 508 // Lookup table for code generators for special runtime calls which are |
509 Handle<String> name = expr->name(); | 509 // generated inline. |
510 SmartPointer<char> cstring = name->ToCString(); | 510 #define INLINE_FUNCTION_GENERATOR_ADDRESS(Name, argc, ressize) \ |
| 511 &FullCodeGenerator::Emit##Name, |
511 | 512 |
512 #define CHECK_EMIT_INLINE_CALL(name, x, y) \ | 513 const FullCodeGenerator::InlineFunctionGenerator |
513 if (strcmp("_"#name, *cstring) == 0) { \ | 514 FullCodeGenerator::kInlineFunctionGenerators[] = { |
514 Emit##name(expr->arguments()); \ | 515 INLINE_FUNCTION_LIST(INLINE_FUNCTION_GENERATOR_ADDRESS) |
515 return; \ | 516 INLINE_RUNTIME_FUNCTION_LIST(INLINE_FUNCTION_GENERATOR_ADDRESS) |
516 } | 517 }; |
517 INLINE_RUNTIME_FUNCTION_LIST(CHECK_EMIT_INLINE_CALL) | 518 #undef INLINE_FUNCTION_GENERATOR_ADDRESS |
518 #undef CHECK_EMIT_INLINE_CALL | 519 |
519 UNREACHABLE(); | 520 |
| 521 FullCodeGenerator::InlineFunctionGenerator |
| 522 FullCodeGenerator::FindInlineFunctionGenerator(Runtime::FunctionId id) { |
| 523 return kInlineFunctionGenerators[ |
| 524 static_cast<int>(id) - static_cast<int>(Runtime::kFirstInlineFunction)]; |
| 525 } |
| 526 |
| 527 |
| 528 void FullCodeGenerator::EmitInlineRuntimeCall(CallRuntime* node) { |
| 529 ZoneList<Expression*>* args = node->arguments(); |
| 530 Handle<String> name = node->name(); |
| 531 Runtime::Function* function = node->function(); |
| 532 ASSERT(function != NULL); |
| 533 ASSERT(function->intrinsic_type == Runtime::INLINE); |
| 534 InlineFunctionGenerator generator = |
| 535 FindInlineFunctionGenerator(function->function_id); |
| 536 ASSERT(generator != NULL); |
| 537 ((*this).*(generator))(args); |
520 } | 538 } |
521 | 539 |
522 | 540 |
523 void FullCodeGenerator::VisitBinaryOperation(BinaryOperation* expr) { | 541 void FullCodeGenerator::VisitBinaryOperation(BinaryOperation* expr) { |
524 Comment cmnt(masm_, "[ BinaryOperation"); | 542 Comment cmnt(masm_, "[ BinaryOperation"); |
525 Token::Value op = expr->op(); | 543 Token::Value op = expr->op(); |
526 Expression* left = expr->left(); | 544 Expression* left = expr->left(); |
527 Expression* right = expr->right(); | 545 Expression* right = expr->right(); |
528 | 546 |
529 OverwriteMode mode = NO_OVERWRITE; | 547 OverwriteMode mode = NO_OVERWRITE; |
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1138 ASSERT(args->length() == 1); | 1156 ASSERT(args->length() == 1); |
1139 VisitForValue(args->at(0), kStack); | 1157 VisitForValue(args->at(0), kStack); |
1140 __ CallRuntime(Runtime::kRegExpCloneResult, 1); | 1158 __ CallRuntime(Runtime::kRegExpCloneResult, 1); |
1141 Apply(context_, result_register()); | 1159 Apply(context_, result_register()); |
1142 } | 1160 } |
1143 | 1161 |
1144 #undef __ | 1162 #undef __ |
1145 | 1163 |
1146 | 1164 |
1147 } } // namespace v8::internal | 1165 } } // namespace v8::internal |
OLD | NEW |