| 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 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 } | 344 } |
| 345 } | 345 } |
| 346 } | 346 } |
| 347 | 347 |
| 348 // Invoke the platform-dependent code generator to do the actual | 348 // Invoke the platform-dependent code generator to do the actual |
| 349 // declaration the global variables and functions. | 349 // declaration the global variables and functions. |
| 350 DeclareGlobals(array); | 350 DeclareGlobals(array); |
| 351 } | 351 } |
| 352 | 352 |
| 353 | 353 |
| 354 // List of special runtime calls which are generated inline. For some of these |
| 355 // functions the code will be generated inline, and for others a call to a code |
| 356 // stub will be inlined. |
| 354 | 357 |
| 355 // Special cases: These 'runtime calls' manipulate the current | 358 #define INLINE_RUNTIME_ENTRY(Name, argc, ressize) \ |
| 356 // frame and are only used 1 or two places, so we generate them | 359 {&CodeGenerator::Generate##Name, "_" #Name, argc}, \ |
| 357 // inline instead of generating calls to them. They are used | 360 |
| 358 // for implementing Function.prototype.call() and | |
| 359 // Function.prototype.apply(). | |
| 360 CodeGenerator::InlineRuntimeLUT CodeGenerator::kInlineRuntimeLUT[] = { | 361 CodeGenerator::InlineRuntimeLUT CodeGenerator::kInlineRuntimeLUT[] = { |
| 361 {&CodeGenerator::GenerateIsSmi, "_IsSmi"}, | 362 INLINE_RUNTIME_FUNCTION_LIST(INLINE_RUNTIME_ENTRY) |
| 362 {&CodeGenerator::GenerateIsNonNegativeSmi, "_IsNonNegativeSmi"}, | |
| 363 {&CodeGenerator::GenerateIsArray, "_IsArray"}, | |
| 364 {&CodeGenerator::GenerateIsRegExp, "_IsRegExp"}, | |
| 365 {&CodeGenerator::GenerateIsConstructCall, "_IsConstructCall"}, | |
| 366 {&CodeGenerator::GenerateArgumentsLength, "_ArgumentsLength"}, | |
| 367 {&CodeGenerator::GenerateArgumentsAccess, "_Arguments"}, | |
| 368 {&CodeGenerator::GenerateClassOf, "_ClassOf"}, | |
| 369 {&CodeGenerator::GenerateValueOf, "_ValueOf"}, | |
| 370 {&CodeGenerator::GenerateSetValueOf, "_SetValueOf"}, | |
| 371 {&CodeGenerator::GenerateFastCharCodeAt, "_FastCharCodeAt"}, | |
| 372 {&CodeGenerator::GenerateCharFromCode, "_CharFromCode"}, | |
| 373 {&CodeGenerator::GenerateObjectEquals, "_ObjectEquals"}, | |
| 374 {&CodeGenerator::GenerateLog, "_Log"}, | |
| 375 {&CodeGenerator::GenerateRandomPositiveSmi, "_RandomPositiveSmi"}, | |
| 376 {&CodeGenerator::GenerateIsObject, "_IsObject"}, | |
| 377 {&CodeGenerator::GenerateIsFunction, "_IsFunction"}, | |
| 378 {&CodeGenerator::GenerateIsUndetectableObject, "_IsUndetectableObject"}, | |
| 379 {&CodeGenerator::GenerateStringAdd, "_StringAdd"}, | |
| 380 {&CodeGenerator::GenerateSubString, "_SubString"}, | |
| 381 {&CodeGenerator::GenerateStringCompare, "_StringCompare"}, | |
| 382 {&CodeGenerator::GenerateRegExpExec, "_RegExpExec"}, | |
| 383 {&CodeGenerator::GenerateNumberToString, "_NumberToString"}, | |
| 384 {&CodeGenerator::GenerateMathPow, "_Math_pow"}, | |
| 385 {&CodeGenerator::GenerateMathSin, "_Math_sin"}, | |
| 386 {&CodeGenerator::GenerateMathCos, "_Math_cos"}, | |
| 387 {&CodeGenerator::GenerateMathSqrt, "_Math_sqrt"}, | |
| 388 }; | 363 }; |
| 389 | 364 |
| 365 #undef INLINE_RUNTIME_ENTRY |
| 390 | 366 |
| 391 CodeGenerator::InlineRuntimeLUT* CodeGenerator::FindInlineRuntimeLUT( | 367 CodeGenerator::InlineRuntimeLUT* CodeGenerator::FindInlineRuntimeLUT( |
| 392 Handle<String> name) { | 368 Handle<String> name) { |
| 393 const int entries_count = | 369 const int entries_count = |
| 394 sizeof(kInlineRuntimeLUT) / sizeof(InlineRuntimeLUT); | 370 sizeof(kInlineRuntimeLUT) / sizeof(InlineRuntimeLUT); |
| 395 for (int i = 0; i < entries_count; i++) { | 371 for (int i = 0; i < entries_count; i++) { |
| 396 InlineRuntimeLUT* entry = &kInlineRuntimeLUT[i]; | 372 InlineRuntimeLUT* entry = &kInlineRuntimeLUT[i]; |
| 397 if (name->IsEqualTo(CStrVector(entry->name))) { | 373 if (name->IsEqualTo(CStrVector(entry->name))) { |
| 398 return entry; | 374 return entry; |
| 399 } | 375 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 424 if (old_entry != NULL) { | 400 if (old_entry != NULL) { |
| 425 old_entry->name = entry->name; | 401 old_entry->name = entry->name; |
| 426 old_entry->method = entry->method; | 402 old_entry->method = entry->method; |
| 427 } | 403 } |
| 428 entry->name = new_entry.name; | 404 entry->name = new_entry.name; |
| 429 entry->method = new_entry.method; | 405 entry->method = new_entry.method; |
| 430 return true; | 406 return true; |
| 431 } | 407 } |
| 432 | 408 |
| 433 | 409 |
| 410 int CodeGenerator::InlineRuntimeCallArgumentsCount(Handle<String> name) { |
| 411 CodeGenerator::InlineRuntimeLUT* f = |
| 412 CodeGenerator::FindInlineRuntimeLUT(name); |
| 413 if (f != NULL) return f->nargs; |
| 414 return -1; |
| 415 } |
| 416 |
| 417 |
| 434 // Simple condition analysis. ALWAYS_TRUE and ALWAYS_FALSE represent a | 418 // Simple condition analysis. ALWAYS_TRUE and ALWAYS_FALSE represent a |
| 435 // known result for the test expression, with no side effects. | 419 // known result for the test expression, with no side effects. |
| 436 CodeGenerator::ConditionAnalysis CodeGenerator::AnalyzeCondition( | 420 CodeGenerator::ConditionAnalysis CodeGenerator::AnalyzeCondition( |
| 437 Expression* cond) { | 421 Expression* cond) { |
| 438 if (cond == NULL) return ALWAYS_TRUE; | 422 if (cond == NULL) return ALWAYS_TRUE; |
| 439 | 423 |
| 440 Literal* lit = cond->AsLiteral(); | 424 Literal* lit = cond->AsLiteral(); |
| 441 if (lit == NULL) return DONT_KNOW; | 425 if (lit == NULL) return DONT_KNOW; |
| 442 | 426 |
| 443 if (lit->IsTrue()) { | 427 if (lit->IsTrue()) { |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 } | 514 } |
| 531 } | 515 } |
| 532 | 516 |
| 533 | 517 |
| 534 void ApiGetterEntryStub::SetCustomCache(Code* value) { | 518 void ApiGetterEntryStub::SetCustomCache(Code* value) { |
| 535 info()->set_load_stub_cache(value); | 519 info()->set_load_stub_cache(value); |
| 536 } | 520 } |
| 537 | 521 |
| 538 | 522 |
| 539 } } // namespace v8::internal | 523 } } // namespace v8::internal |
| OLD | NEW |