OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 | 411 |
412 static void FillCache(Isolate* isolate, Handle<Code> code) { | 412 static void FillCache(Isolate* isolate, Handle<Code> code) { |
413 Handle<UnseededNumberDictionary> dictionary = | 413 Handle<UnseededNumberDictionary> dictionary = |
414 UnseededNumberDictionary::Set(isolate->factory()->non_monomorphic_cache(), | 414 UnseededNumberDictionary::Set(isolate->factory()->non_monomorphic_cache(), |
415 code->flags(), | 415 code->flags(), |
416 code); | 416 code); |
417 isolate->heap()->public_set_non_monomorphic_cache(*dictionary); | 417 isolate->heap()->public_set_non_monomorphic_cache(*dictionary); |
418 } | 418 } |
419 | 419 |
420 | 420 |
421 Code* StubCache::FindCallInitialize(int argc, | 421 Code* StubCache::FindCallInitialize(int argc, Code::Kind kind) { |
422 ContextualMode mode, | |
423 Code::Kind kind) { | |
424 ExtraICState extra_state = | 422 ExtraICState extra_state = |
425 CallICBase::StringStubState::encode(DEFAULT_STRING_STUB) | | 423 CallICBase::StringStubState::encode(DEFAULT_STRING_STUB); |
426 CallICBase::Contextual::encode(mode); | |
427 Code::Flags flags = | 424 Code::Flags flags = |
428 Code::ComputeFlags(kind, UNINITIALIZED, extra_state, Code::NORMAL, argc); | 425 Code::ComputeFlags(kind, UNINITIALIZED, extra_state, Code::NORMAL, argc); |
429 UnseededNumberDictionary* dictionary = | 426 UnseededNumberDictionary* dictionary = |
430 isolate()->heap()->non_monomorphic_cache(); | 427 isolate()->heap()->non_monomorphic_cache(); |
431 int entry = dictionary->FindEntry(isolate(), flags); | 428 int entry = dictionary->FindEntry(isolate(), flags); |
432 ASSERT(entry != -1); | 429 ASSERT(entry != -1); |
433 Object* code = dictionary->ValueAt(entry); | 430 Object* code = dictionary->ValueAt(entry); |
434 // This might be called during the marking phase of the collector | 431 // This might be called during the marking phase of the collector |
435 // hence the unchecked cast. | 432 // hence the unchecked cast. |
436 return reinterpret_cast<Code*>(code); | 433 return reinterpret_cast<Code*>(code); |
437 } | 434 } |
438 | 435 |
439 | 436 |
440 Code* StubCache::FindPreMonomorphicIC(Code::Kind kind, ExtraICState state) { | 437 Code* StubCache::FindPreMonomorphicIC(Code::Kind kind, ExtraICState state) { |
441 Code::Flags flags = Code::ComputeFlags(kind, PREMONOMORPHIC, state); | 438 Code::Flags flags = Code::ComputeFlags(kind, PREMONOMORPHIC, state); |
442 UnseededNumberDictionary* dictionary = | 439 UnseededNumberDictionary* dictionary = |
443 isolate()->heap()->non_monomorphic_cache(); | 440 isolate()->heap()->non_monomorphic_cache(); |
444 int entry = dictionary->FindEntry(isolate(), flags); | 441 int entry = dictionary->FindEntry(isolate(), flags); |
445 ASSERT(entry != -1); | 442 ASSERT(entry != -1); |
446 Object* code = dictionary->ValueAt(entry); | 443 Object* code = dictionary->ValueAt(entry); |
447 // This might be called during the marking phase of the collector | 444 // This might be called during the marking phase of the collector |
448 // hence the unchecked cast. | 445 // hence the unchecked cast. |
449 return reinterpret_cast<Code*>(code); | 446 return reinterpret_cast<Code*>(code); |
450 } | 447 } |
451 | 448 |
452 | 449 |
453 Handle<Code> StubCache::ComputeCallInitialize(int argc, | 450 Handle<Code> StubCache::ComputeCallInitialize(int argc, Code::Kind kind) { |
454 ContextualMode mode, | |
455 Code::Kind kind) { | |
456 ExtraICState extra_state = | 451 ExtraICState extra_state = |
457 CallICBase::ComputeExtraICState(mode, DEFAULT_STRING_STUB); | 452 CallICBase::ComputeExtraICState(DEFAULT_STRING_STUB); |
458 Code::Flags flags = | 453 Code::Flags flags = |
459 Code::ComputeFlags(kind, UNINITIALIZED, extra_state, Code::NORMAL, argc); | 454 Code::ComputeFlags(kind, UNINITIALIZED, extra_state, Code::NORMAL, argc); |
460 Handle<UnseededNumberDictionary> cache = | 455 Handle<UnseededNumberDictionary> cache = |
461 isolate_->factory()->non_monomorphic_cache(); | 456 isolate_->factory()->non_monomorphic_cache(); |
462 int entry = cache->FindEntry(isolate_, flags); | 457 int entry = cache->FindEntry(isolate_, flags); |
463 if (entry != -1) return Handle<Code>(Code::cast(cache->ValueAt(entry))); | 458 if (entry != -1) return Handle<Code>(Code::cast(cache->ValueAt(entry))); |
464 | 459 |
465 StubCompiler compiler(isolate_); | 460 StubCompiler compiler(isolate_); |
466 Handle<Code> code = compiler.CompileCallInitialize(flags); | 461 Handle<Code> code = compiler.CompileCallInitialize(flags); |
467 FillCache(isolate_, code); | 462 FillCache(isolate_, code); |
468 return code; | 463 return code; |
469 } | 464 } |
470 | 465 |
471 | 466 |
472 Handle<Code> StubCache::ComputeCallInitialize(int argc, ContextualMode mode) { | 467 Handle<Code> StubCache::ComputeCallInitialize(int argc) { |
473 return ComputeCallInitialize(argc, mode, Code::CALL_IC); | 468 return ComputeCallInitialize(argc, Code::CALL_IC); |
474 } | 469 } |
475 | 470 |
476 | 471 |
477 Handle<Code> StubCache::ComputeKeyedCallInitialize(int argc) { | 472 Handle<Code> StubCache::ComputeKeyedCallInitialize(int argc) { |
478 return ComputeCallInitialize(argc, NOT_CONTEXTUAL, Code::KEYED_CALL_IC); | 473 return ComputeCallInitialize(argc, Code::KEYED_CALL_IC); |
479 } | 474 } |
480 | 475 |
481 | 476 |
482 Handle<Code> StubCache::ComputeCallPreMonomorphic( | 477 Handle<Code> StubCache::ComputeCallPreMonomorphic( |
483 int argc, | 478 int argc, |
484 Code::Kind kind, | 479 Code::Kind kind, |
485 ExtraICState extra_state) { | 480 ExtraICState extra_state) { |
486 Code::Flags flags = | 481 Code::Flags flags = |
487 Code::ComputeFlags(kind, PREMONOMORPHIC, extra_state, Code::NORMAL, argc); | 482 Code::ComputeFlags(kind, PREMONOMORPHIC, extra_state, Code::NORMAL, argc); |
488 Handle<UnseededNumberDictionary> cache = | 483 Handle<UnseededNumberDictionary> cache = |
(...skipping 1545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2034 Handle<FunctionTemplateInfo>( | 2029 Handle<FunctionTemplateInfo>( |
2035 FunctionTemplateInfo::cast(signature->receiver())); | 2030 FunctionTemplateInfo::cast(signature->receiver())); |
2036 } | 2031 } |
2037 } | 2032 } |
2038 | 2033 |
2039 is_simple_api_call_ = true; | 2034 is_simple_api_call_ = true; |
2040 } | 2035 } |
2041 | 2036 |
2042 | 2037 |
2043 } } // namespace v8::internal | 2038 } } // namespace v8::internal |
OLD | NEW |