| 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 19 matching lines...) Expand all Loading... |
| 30 #include "bootstrapper.h" | 30 #include "bootstrapper.h" |
| 31 #include "code-stubs.h" | 31 #include "code-stubs.h" |
| 32 #include "stub-cache.h" | 32 #include "stub-cache.h" |
| 33 #include "factory.h" | 33 #include "factory.h" |
| 34 #include "gdb-jit.h" | 34 #include "gdb-jit.h" |
| 35 #include "macro-assembler.h" | 35 #include "macro-assembler.h" |
| 36 | 36 |
| 37 namespace v8 { | 37 namespace v8 { |
| 38 namespace internal { | 38 namespace internal { |
| 39 | 39 |
| 40 bool CodeStub::FindCodeInCache(Code** code_out) { | 40 bool CodeStub::FindCodeInCache(Code** code_out, Isolate* isolate) { |
| 41 Heap* heap = Isolate::Current()->heap(); | 41 UnseededNumberDictionary* stubs = isolate->heap()->code_stubs(); |
| 42 int index = heap->code_stubs()->FindEntry(GetKey()); | 42 int index = stubs->FindEntry(GetKey()); |
| 43 if (index != UnseededNumberDictionary::kNotFound) { | 43 if (index != UnseededNumberDictionary::kNotFound) { |
| 44 *code_out = Code::cast(heap->code_stubs()->ValueAt(index)); | 44 *code_out = Code::cast(stubs->ValueAt(index)); |
| 45 return true; | 45 return true; |
| 46 } | 46 } |
| 47 return false; | 47 return false; |
| 48 } | 48 } |
| 49 | 49 |
| 50 | 50 |
| 51 void CodeStub::GenerateCode(MacroAssembler* masm) { | 51 void CodeStub::GenerateCode(MacroAssembler* masm) { |
| 52 // Update the static counter each time a new code stub is generated. | 52 // Update the static counter each time a new code stub is generated. |
| 53 masm->isolate()->counters()->code_stubs()->Increment(); | 53 masm->isolate()->counters()->code_stubs()->Increment(); |
| 54 | 54 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 return Code::STUB; | 86 return Code::STUB; |
| 87 } | 87 } |
| 88 | 88 |
| 89 | 89 |
| 90 Handle<Code> CodeStub::GetCode() { | 90 Handle<Code> CodeStub::GetCode() { |
| 91 Isolate* isolate = Isolate::Current(); | 91 Isolate* isolate = Isolate::Current(); |
| 92 Factory* factory = isolate->factory(); | 92 Factory* factory = isolate->factory(); |
| 93 Heap* heap = isolate->heap(); | 93 Heap* heap = isolate->heap(); |
| 94 Code* code; | 94 Code* code; |
| 95 if (UseSpecialCache() | 95 if (UseSpecialCache() |
| 96 ? FindCodeInSpecialCache(&code) | 96 ? FindCodeInSpecialCache(&code, isolate) |
| 97 : FindCodeInCache(&code)) { | 97 : FindCodeInCache(&code, isolate)) { |
| 98 ASSERT(IsPregenerated() == code->is_pregenerated()); | 98 ASSERT(IsPregenerated() == code->is_pregenerated()); |
| 99 return Handle<Code>(code); | 99 return Handle<Code>(code); |
| 100 } | 100 } |
| 101 | 101 |
| 102 { | 102 { |
| 103 HandleScope scope(isolate); | 103 HandleScope scope(isolate); |
| 104 | 104 |
| 105 // Generate the new code. | 105 // Generate the new code. |
| 106 MacroAssembler masm(isolate, NULL, 256); | 106 MacroAssembler masm(isolate, NULL, 256); |
| 107 GenerateCode(&masm); | 107 GenerateCode(&masm); |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 Isolate* isolate = new_object->GetIsolate(); | 290 Isolate* isolate = new_object->GetIsolate(); |
| 291 Factory* factory = isolate->factory(); | 291 Factory* factory = isolate->factory(); |
| 292 return Map::UpdateCodeCache(known_map_, | 292 return Map::UpdateCodeCache(known_map_, |
| 293 strict() ? | 293 strict() ? |
| 294 factory->strict_compare_ic_symbol() : | 294 factory->strict_compare_ic_symbol() : |
| 295 factory->compare_ic_symbol(), | 295 factory->compare_ic_symbol(), |
| 296 new_object); | 296 new_object); |
| 297 } | 297 } |
| 298 | 298 |
| 299 | 299 |
| 300 bool ICCompareStub::FindCodeInSpecialCache(Code** code_out) { | 300 bool ICCompareStub::FindCodeInSpecialCache(Code** code_out, Isolate* isolate) { |
| 301 Isolate* isolate = known_map_->GetIsolate(); | |
| 302 Factory* factory = isolate->factory(); | 301 Factory* factory = isolate->factory(); |
| 303 Code::Flags flags = Code::ComputeFlags( | 302 Code::Flags flags = Code::ComputeFlags( |
| 304 static_cast<Code::Kind>(GetCodeKind()), | 303 static_cast<Code::Kind>(GetCodeKind()), |
| 305 UNINITIALIZED); | 304 UNINITIALIZED); |
| 306 ASSERT(op_ == Token::EQ || op_ == Token::EQ_STRICT); | 305 ASSERT(op_ == Token::EQ || op_ == Token::EQ_STRICT); |
| 307 Handle<Object> probe( | 306 Handle<Object> probe( |
| 308 known_map_->FindInCodeCache( | 307 known_map_->FindInCodeCache( |
| 309 strict() ? | 308 strict() ? |
| 310 *factory->strict_compare_ic_symbol() : | 309 *factory->strict_compare_ic_symbol() : |
| 311 *factory->compare_ic_symbol(), | 310 *factory->compare_ic_symbol(), |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 644 // already active, as the hooks won't stack. | 643 // already active, as the hooks won't stack. |
| 645 if (entry_hook != 0 && entry_hook_ != 0) | 644 if (entry_hook != 0 && entry_hook_ != 0) |
| 646 return false; | 645 return false; |
| 647 | 646 |
| 648 entry_hook_ = entry_hook; | 647 entry_hook_ = entry_hook; |
| 649 return true; | 648 return true; |
| 650 } | 649 } |
| 651 | 650 |
| 652 | 651 |
| 653 } } // namespace v8::internal | 652 } } // namespace v8::internal |
| OLD | NEW |