OLD | NEW |
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 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 // declaration the global variables and functions. | 337 // declaration the global variables and functions. |
338 DeclareGlobals(array); | 338 DeclareGlobals(array); |
339 } | 339 } |
340 | 340 |
341 | 341 |
342 void CodeGenerator::VisitIncrementOperation(IncrementOperation* expr) { | 342 void CodeGenerator::VisitIncrementOperation(IncrementOperation* expr) { |
343 UNREACHABLE(); | 343 UNREACHABLE(); |
344 } | 344 } |
345 | 345 |
346 | 346 |
347 // List of special runtime calls which are generated inline. For some of these | 347 // Lookup table for code generators for special runtime calls which are |
348 // functions the code will be generated inline, and for others a call to a code | 348 // generated inline. |
349 // stub will be inlined. | 349 #define INLINE_FUNCTION_GENERATOR_ADDRESS(Name, argc, ressize) \ |
| 350 &CodeGenerator::Generate##Name, |
350 | 351 |
351 #define INLINE_RUNTIME_ENTRY(Name, argc, ressize) \ | 352 const CodeGenerator::InlineFunctionGenerator |
352 {&CodeGenerator::Generate##Name, "_" #Name, argc}, \ | 353 CodeGenerator::kInlineFunctionGenerators[] = { |
| 354 INLINE_FUNCTION_LIST(INLINE_FUNCTION_GENERATOR_ADDRESS) |
| 355 INLINE_RUNTIME_FUNCTION_LIST(INLINE_FUNCTION_GENERATOR_ADDRESS) |
| 356 }; |
| 357 #undef INLINE_FUNCTION_GENERATOR_ADDRESS |
353 | 358 |
354 CodeGenerator::InlineRuntimeLUT CodeGenerator::kInlineRuntimeLUT[] = { | |
355 INLINE_RUNTIME_FUNCTION_LIST(INLINE_RUNTIME_ENTRY) | |
356 }; | |
357 | 359 |
358 #undef INLINE_RUNTIME_ENTRY | 360 CodeGenerator::InlineFunctionGenerator |
359 | 361 CodeGenerator::FindInlineFunctionGenerator(Runtime::FunctionId id) { |
360 CodeGenerator::InlineRuntimeLUT* CodeGenerator::FindInlineRuntimeLUT( | 362 return kInlineFunctionGenerators[ |
361 Handle<String> name) { | 363 static_cast<int>(id) - static_cast<int>(Runtime::kFirstInlineFunction)]; |
362 const int entries_count = | |
363 sizeof(kInlineRuntimeLUT) / sizeof(InlineRuntimeLUT); | |
364 for (int i = 0; i < entries_count; i++) { | |
365 InlineRuntimeLUT* entry = &kInlineRuntimeLUT[i]; | |
366 if (name->IsEqualTo(CStrVector(entry->name))) { | |
367 return entry; | |
368 } | |
369 } | |
370 return NULL; | |
371 } | 364 } |
372 | 365 |
373 | 366 |
374 bool CodeGenerator::CheckForInlineRuntimeCall(CallRuntime* node) { | 367 bool CodeGenerator::CheckForInlineRuntimeCall(CallRuntime* node) { |
375 ZoneList<Expression*>* args = node->arguments(); | 368 ZoneList<Expression*>* args = node->arguments(); |
376 Handle<String> name = node->name(); | 369 Handle<String> name = node->name(); |
377 if (name->length() > 0 && name->Get(0) == '_') { | 370 Runtime::Function* function = node->function(); |
378 InlineRuntimeLUT* entry = FindInlineRuntimeLUT(name); | 371 if (function != NULL && function->intrinsic_type == Runtime::INLINE) { |
379 if (entry != NULL) { | 372 InlineFunctionGenerator generator = |
380 ((*this).*(entry->method))(args); | 373 FindInlineFunctionGenerator(function->function_id); |
| 374 if (generator != NULL) { |
| 375 ((*this).*(generator))(args); |
381 return true; | 376 return true; |
382 } | 377 } |
383 } | 378 } |
384 return false; | 379 return false; |
385 } | 380 } |
386 | 381 |
387 | 382 |
388 int CodeGenerator::InlineRuntimeCallArgumentsCount(Handle<String> name) { | |
389 CodeGenerator::InlineRuntimeLUT* f = | |
390 CodeGenerator::FindInlineRuntimeLUT(name); | |
391 if (f != NULL) return f->nargs; | |
392 return -1; | |
393 } | |
394 | |
395 | |
396 // Simple condition analysis. ALWAYS_TRUE and ALWAYS_FALSE represent a | 383 // Simple condition analysis. ALWAYS_TRUE and ALWAYS_FALSE represent a |
397 // known result for the test expression, with no side effects. | 384 // known result for the test expression, with no side effects. |
398 CodeGenerator::ConditionAnalysis CodeGenerator::AnalyzeCondition( | 385 CodeGenerator::ConditionAnalysis CodeGenerator::AnalyzeCondition( |
399 Expression* cond) { | 386 Expression* cond) { |
400 if (cond == NULL) return ALWAYS_TRUE; | 387 if (cond == NULL) return ALWAYS_TRUE; |
401 | 388 |
402 Literal* lit = cond->AsLiteral(); | 389 Literal* lit = cond->AsLiteral(); |
403 if (lit == NULL) return DONT_KNOW; | 390 if (lit == NULL) return DONT_KNOW; |
404 | 391 |
405 if (lit->IsTrue()) { | 392 if (lit->IsTrue()) { |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
505 } | 492 } |
506 } | 493 } |
507 | 494 |
508 | 495 |
509 void ApiGetterEntryStub::SetCustomCache(Code* value) { | 496 void ApiGetterEntryStub::SetCustomCache(Code* value) { |
510 info()->set_load_stub_cache(value); | 497 info()->set_load_stub_cache(value); |
511 } | 498 } |
512 | 499 |
513 | 500 |
514 } } // namespace v8::internal | 501 } } // namespace v8::internal |
OLD | NEW |