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

Side by Side Diff: src/stub-cache.cc

Issue 96083005: Remove Reloc::Mode CODE_TARGET_CONTEXT (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Complete for ia32. Created 7 years 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
OLDNEW
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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 // prototype cannot hold multiple handlers, one for each of the string maps, 139 // prototype cannot hold multiple handlers, one for each of the string maps,
140 // for a single name. Hence, turn off caching of the IC. 140 // for a single name. Hence, turn off caching of the IC.
141 bool can_be_cached = !type->Is(Type::String()); 141 bool can_be_cached = !type->Is(Type::String());
142 if (can_be_cached) { 142 if (can_be_cached) {
143 stub_holder = IC::GetCodeCacheHolder(flag, *type, isolate()); 143 stub_holder = IC::GetCodeCacheHolder(flag, *type, isolate());
144 ic = FindIC(name, stub_holder, kind, extra_ic_state, flag); 144 ic = FindIC(name, stub_holder, kind, extra_ic_state, flag);
145 if (!ic.is_null()) return ic; 145 if (!ic.is_null()) return ic;
146 } 146 }
147 147
148 if (kind == Code::LOAD_IC) { 148 if (kind == Code::LOAD_IC) {
149 LoadStubCompiler ic_compiler(isolate(), flag); 149 LoadStubCompiler ic_compiler(isolate(), extra_ic_state, flag);
150 ic = ic_compiler.CompileMonomorphicIC(type, handler, name); 150 ic = ic_compiler.CompileMonomorphicIC(type, handler, name);
151 } else if (kind == Code::KEYED_LOAD_IC) { 151 } else if (kind == Code::KEYED_LOAD_IC) {
152 KeyedLoadStubCompiler ic_compiler(isolate(), flag); 152 KeyedLoadStubCompiler ic_compiler(isolate(), extra_ic_state, flag);
153 ic = ic_compiler.CompileMonomorphicIC(type, handler, name); 153 ic = ic_compiler.CompileMonomorphicIC(type, handler, name);
154 } else if (kind == Code::STORE_IC) { 154 } else if (kind == Code::STORE_IC) {
155 StoreStubCompiler ic_compiler(isolate(), extra_ic_state); 155 StoreStubCompiler ic_compiler(isolate(), extra_ic_state);
156 ic = ic_compiler.CompileMonomorphicIC(type, handler, name); 156 ic = ic_compiler.CompileMonomorphicIC(type, handler, name);
157 } else { 157 } else {
158 ASSERT(kind == Code::KEYED_STORE_IC); 158 ASSERT(kind == Code::KEYED_STORE_IC);
159 ASSERT(STANDARD_STORE == 159 ASSERT(STANDARD_STORE ==
160 KeyedStoreIC::GetKeyedAccessStoreMode(extra_ic_state)); 160 KeyedStoreIC::GetKeyedAccessStoreMode(extra_ic_state));
161 KeyedStoreStubCompiler ic_compiler(isolate(), extra_ic_state); 161 KeyedStoreStubCompiler ic_compiler(isolate(), extra_ic_state);
162 ic = ic_compiler.CompileMonomorphicIC(type, handler, name); 162 ic = ic_compiler.CompileMonomorphicIC(type, handler, name);
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 static void FillCache(Isolate* isolate, Handle<Code> code) { 411 static void FillCache(Isolate* isolate, Handle<Code> code) {
412 Handle<UnseededNumberDictionary> dictionary = 412 Handle<UnseededNumberDictionary> dictionary =
413 UnseededNumberDictionary::Set(isolate->factory()->non_monomorphic_cache(), 413 UnseededNumberDictionary::Set(isolate->factory()->non_monomorphic_cache(),
414 code->flags(), 414 code->flags(),
415 code); 415 code);
416 isolate->heap()->public_set_non_monomorphic_cache(*dictionary); 416 isolate->heap()->public_set_non_monomorphic_cache(*dictionary);
417 } 417 }
418 418
419 419
420 Code* StubCache::FindCallInitialize(int argc, 420 Code* StubCache::FindCallInitialize(int argc,
421 RelocInfo::Mode mode, 421 ContextualMode mode,
422 Code::Kind kind) { 422 Code::Kind kind) {
423 ExtraICState extra_state = 423 ExtraICState extra_state =
424 CallICBase::StringStubState::encode(DEFAULT_STRING_STUB) | 424 CallICBase::StringStubState::encode(DEFAULT_STRING_STUB) |
425 CallICBase::Contextual::encode(mode == RelocInfo::CODE_TARGET_CONTEXT 425 CallICBase::Contextual::encode(mode);
426 ? CONTEXTUAL : NOT_CONTEXTUAL);
427 Code::Flags flags = 426 Code::Flags flags =
428 Code::ComputeFlags(kind, UNINITIALIZED, extra_state, Code::NORMAL, argc); 427 Code::ComputeFlags(kind, UNINITIALIZED, extra_state, Code::NORMAL, argc);
429 UnseededNumberDictionary* dictionary = 428 UnseededNumberDictionary* dictionary =
430 isolate()->heap()->non_monomorphic_cache(); 429 isolate()->heap()->non_monomorphic_cache();
431 int entry = dictionary->FindEntry(isolate(), flags); 430 int entry = dictionary->FindEntry(isolate(), flags);
432 ASSERT(entry != -1); 431 ASSERT(entry != -1);
433 Object* code = dictionary->ValueAt(entry); 432 Object* code = dictionary->ValueAt(entry);
434 // This might be called during the marking phase of the collector 433 // This might be called during the marking phase of the collector
435 // hence the unchecked cast. 434 // hence the unchecked cast.
436 return reinterpret_cast<Code*>(code); 435 return reinterpret_cast<Code*>(code);
437 } 436 }
438 437
439 438
440 Handle<Code> StubCache::ComputeCallInitialize(int argc, 439 Handle<Code> StubCache::ComputeCallInitialize(int argc,
441 RelocInfo::Mode mode, 440 ContextualMode mode,
442 Code::Kind kind) { 441 Code::Kind kind) {
443 ExtraICState extra_state = 442 ExtraICState extra_state =
444 CallICBase::StringStubState::encode(DEFAULT_STRING_STUB) | 443 CallICBase::ComputeExtraICState(mode, DEFAULT_STRING_STUB);
445 CallICBase::Contextual::encode(mode == RelocInfo::CODE_TARGET_CONTEXT
446 ? CONTEXTUAL : NOT_CONTEXTUAL);
447 Code::Flags flags = 444 Code::Flags flags =
448 Code::ComputeFlags(kind, UNINITIALIZED, extra_state, Code::NORMAL, argc); 445 Code::ComputeFlags(kind, UNINITIALIZED, extra_state, Code::NORMAL, argc);
449 Handle<UnseededNumberDictionary> cache = 446 Handle<UnseededNumberDictionary> cache =
450 isolate_->factory()->non_monomorphic_cache(); 447 isolate_->factory()->non_monomorphic_cache();
451 int entry = cache->FindEntry(isolate_, flags); 448 int entry = cache->FindEntry(isolate_, flags);
452 if (entry != -1) return Handle<Code>(Code::cast(cache->ValueAt(entry))); 449 if (entry != -1) return Handle<Code>(Code::cast(cache->ValueAt(entry)));
453 450
454 StubCompiler compiler(isolate_); 451 StubCompiler compiler(isolate_);
455 Handle<Code> code = compiler.CompileCallInitialize(flags); 452 Handle<Code> code = compiler.CompileCallInitialize(flags);
456 FillCache(isolate_, code); 453 FillCache(isolate_, code);
457 return code; 454 return code;
458 } 455 }
459 456
460 457
461 Handle<Code> StubCache::ComputeCallInitialize(int argc, RelocInfo::Mode mode) { 458 Handle<Code> StubCache::ComputeCallInitialize(int argc, ContextualMode mode) {
462 return ComputeCallInitialize(argc, mode, Code::CALL_IC); 459 return ComputeCallInitialize(argc, mode, Code::CALL_IC);
463 } 460 }
464 461
465 462
466 Handle<Code> StubCache::ComputeKeyedCallInitialize(int argc) { 463 Handle<Code> StubCache::ComputeKeyedCallInitialize(int argc) {
467 return ComputeCallInitialize(argc, RelocInfo::CODE_TARGET, 464 return ComputeCallInitialize(argc, NOT_CONTEXTUAL, Code::KEYED_CALL_IC);
468 Code::KEYED_CALL_IC);
469 } 465 }
470 466
471 467
472 Handle<Code> StubCache::ComputeCallPreMonomorphic( 468 Handle<Code> StubCache::ComputeCallPreMonomorphic(
473 int argc, 469 int argc,
474 Code::Kind kind, 470 Code::Kind kind,
475 ExtraICState extra_state) { 471 ExtraICState extra_state) {
476 Code::Flags flags = 472 Code::Flags flags =
477 Code::ComputeFlags(kind, PREMONOMORPHIC, extra_state, Code::NORMAL, argc); 473 Code::ComputeFlags(kind, PREMONOMORPHIC, extra_state, Code::NORMAL, argc);
478 Handle<UnseededNumberDictionary> cache = 474 Handle<UnseededNumberDictionary> cache =
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 CodeHandleList* handlers, 606 CodeHandleList* handlers,
611 int number_of_valid_types, 607 int number_of_valid_types,
612 Handle<Name> name, 608 Handle<Name> name,
613 ExtraICState extra_ic_state) { 609 ExtraICState extra_ic_state) {
614 610
615 Handle<Code> handler = handlers->at(0); 611 Handle<Code> handler = handlers->at(0);
616 Code::Kind kind = handler->handler_kind(); 612 Code::Kind kind = handler->handler_kind();
617 Code::StubType type = number_of_valid_types == 1 ? handler->type() 613 Code::StubType type = number_of_valid_types == 1 ? handler->type()
618 : Code::NORMAL; 614 : Code::NORMAL;
619 if (kind == Code::LOAD_IC) { 615 if (kind == Code::LOAD_IC) {
620 LoadStubCompiler ic_compiler(isolate_); 616 LoadStubCompiler ic_compiler(isolate_, extra_ic_state);
621 return ic_compiler.CompilePolymorphicIC( 617 return ic_compiler.CompilePolymorphicIC(
622 types, handlers, name, type, PROPERTY); 618 types, handlers, name, type, PROPERTY);
623 } else { 619 } else {
624 ASSERT(kind == Code::STORE_IC); 620 ASSERT(kind == Code::STORE_IC);
625 StrictModeFlag strict_mode = StoreIC::GetStrictMode(extra_ic_state); 621 StoreStubCompiler ic_compiler(isolate_, extra_ic_state);
626 StoreStubCompiler ic_compiler(isolate_, strict_mode);
627 return ic_compiler.CompilePolymorphicIC( 622 return ic_compiler.CompilePolymorphicIC(
628 types, handlers, name, type, PROPERTY); 623 types, handlers, name, type, PROPERTY);
629 } 624 }
630 } 625 }
631 626
632 627
633 Handle<Code> StubCache::ComputeStoreElementPolymorphic( 628 Handle<Code> StubCache::ComputeStoreElementPolymorphic(
634 MapHandleList* receiver_maps, 629 MapHandleList* receiver_maps,
635 KeyedAccessStoreMode store_mode, 630 KeyedAccessStoreMode store_mode,
636 StrictModeFlag strict_mode) { 631 StrictModeFlag strict_mode) {
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
826 } 821 }
827 822
828 823
829 static MaybeObject* ThrowReferenceError(Isolate* isolate, Name* name) { 824 static MaybeObject* ThrowReferenceError(Isolate* isolate, Name* name) {
830 // If the load is non-contextual, just return the undefined result. 825 // If the load is non-contextual, just return the undefined result.
831 // Note that both keyed and non-keyed loads may end up here, so we 826 // Note that both keyed and non-keyed loads may end up here, so we
832 // can't use either LoadIC or KeyedLoadIC constructors. 827 // can't use either LoadIC or KeyedLoadIC constructors.
833 HandleScope scope(isolate); 828 HandleScope scope(isolate);
834 IC ic(IC::NO_EXTRA_FRAME, isolate); 829 IC ic(IC::NO_EXTRA_FRAME, isolate);
835 ASSERT(ic.IsLoadStub()); 830 ASSERT(ic.IsLoadStub());
836 if (!ic.SlowIsUndeclaredGlobal()) return isolate->heap()->undefined_value(); 831 if (ic.contextual_mode() == NOT_CONTEXTUAL) {
832 return isolate->heap()->undefined_value();
833 }
837 834
838 // Throw a reference error. 835 // Throw a reference error.
839 Handle<Name> name_handle(name); 836 Handle<Name> name_handle(name);
840 Handle<Object> error = 837 Handle<Object> error =
841 isolate->factory()->NewReferenceError("not_defined", 838 isolate->factory()->NewReferenceError("not_defined",
842 HandleVector(&name_handle, 1)); 839 HandleVector(&name_handle, 1));
843 return isolate->Throw(*error); 840 return isolate->Throw(*error);
844 } 841 }
845 842
846 843
(...skipping 1050 matching lines...) Expand 10 before | Expand all | Expand 10 after
1897 Handle<FunctionTemplateInfo>( 1894 Handle<FunctionTemplateInfo>(
1898 FunctionTemplateInfo::cast(signature->receiver())); 1895 FunctionTemplateInfo::cast(signature->receiver()));
1899 } 1896 }
1900 } 1897 }
1901 1898
1902 is_simple_api_call_ = true; 1899 is_simple_api_call_ = true;
1903 } 1900 }
1904 1901
1905 1902
1906 } } // namespace v8::internal 1903 } } // namespace v8::internal
OLDNEW
« src/builtins.cc ('K') | « src/stub-cache.h ('k') | test/cctest/test-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698