| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/code-stubs.h" | 5 #include "src/code-stubs.h" |
| 6 | 6 |
| 7 #include <sstream> | 7 #include <sstream> |
| 8 | 8 |
| 9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
| 10 #include "src/code-factory.h" | 10 #include "src/code-factory.h" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 #endif | 92 #endif |
| 93 } | 93 } |
| 94 | 94 |
| 95 | 95 |
| 96 Code::Kind CodeStub::GetCodeKind() const { | 96 Code::Kind CodeStub::GetCodeKind() const { |
| 97 return Code::STUB; | 97 return Code::STUB; |
| 98 } | 98 } |
| 99 | 99 |
| 100 | 100 |
| 101 Code::Flags CodeStub::GetCodeFlags() const { | 101 Code::Flags CodeStub::GetCodeFlags() const { |
| 102 return Code::ComputeFlags(GetCodeKind(), GetICState(), GetExtraICState(), | 102 return Code::ComputeFlags(GetCodeKind(), GetICState(), GetExtraICState()); |
| 103 GetStubType()); | |
| 104 } | 103 } |
| 105 | 104 |
| 106 | 105 |
| 107 Handle<Code> CodeStub::GetCodeCopy(const Code::FindAndReplacePattern& pattern) { | 106 Handle<Code> CodeStub::GetCodeCopy(const Code::FindAndReplacePattern& pattern) { |
| 108 Handle<Code> ic = GetCode(); | 107 Handle<Code> ic = GetCode(); |
| 109 ic = isolate()->factory()->CopyCode(ic); | 108 ic = isolate()->factory()->CopyCode(ic); |
| 110 ic->FindAndReplace(pattern); | 109 ic->FindAndReplace(pattern); |
| 111 RecordCodeGeneration(ic); | 110 RecordCodeGeneration(ic); |
| 112 return ic; | 111 return ic; |
| 113 } | 112 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 128 // TODO(yangguo): remove this once we can serialize IC stubs. | 127 // TODO(yangguo): remove this once we can serialize IC stubs. |
| 129 masm.enable_serializer(); | 128 masm.enable_serializer(); |
| 130 NoCurrentFrameScope scope(&masm); | 129 NoCurrentFrameScope scope(&masm); |
| 131 Generate(&masm); | 130 Generate(&masm); |
| 132 } | 131 } |
| 133 | 132 |
| 134 // Create the code object. | 133 // Create the code object. |
| 135 CodeDesc desc; | 134 CodeDesc desc; |
| 136 masm.GetCode(&desc); | 135 masm.GetCode(&desc); |
| 137 // Copy the generated code into a heap object. | 136 // Copy the generated code into a heap object. |
| 138 Code::Flags flags = Code::ComputeFlags( | 137 Code::Flags flags = |
| 139 GetCodeKind(), | 138 Code::ComputeFlags(GetCodeKind(), GetICState(), GetExtraICState()); |
| 140 GetICState(), | |
| 141 GetExtraICState(), | |
| 142 GetStubType()); | |
| 143 Handle<Code> new_object = factory->NewCode( | 139 Handle<Code> new_object = factory->NewCode( |
| 144 desc, flags, masm.CodeObject(), NeedsImmovableCode()); | 140 desc, flags, masm.CodeObject(), NeedsImmovableCode()); |
| 145 return new_object; | 141 return new_object; |
| 146 } | 142 } |
| 147 | 143 |
| 148 | 144 |
| 149 Handle<Code> CodeStub::GetCode() { | 145 Handle<Code> CodeStub::GetCode() { |
| 150 Heap* heap = isolate()->heap(); | 146 Heap* heap = isolate()->heap(); |
| 151 Code* code; | 147 Code* code; |
| 152 if (UseSpecialCache() ? FindCodeInSpecialCache(&code) | 148 if (UseSpecialCache() ? FindCodeInSpecialCache(&code) |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 Factory* factory = isolate->factory(); | 379 Factory* factory = isolate->factory(); |
| 384 return Map::UpdateCodeCache(known_map_, | 380 return Map::UpdateCodeCache(known_map_, |
| 385 strict() ? | 381 strict() ? |
| 386 factory->strict_compare_ic_string() : | 382 factory->strict_compare_ic_string() : |
| 387 factory->compare_ic_string(), | 383 factory->compare_ic_string(), |
| 388 new_object); | 384 new_object); |
| 389 } | 385 } |
| 390 | 386 |
| 391 | 387 |
| 392 bool CompareICStub::FindCodeInSpecialCache(Code** code_out) { | 388 bool CompareICStub::FindCodeInSpecialCache(Code** code_out) { |
| 393 Factory* factory = isolate()->factory(); | |
| 394 Code::Flags flags = Code::ComputeFlags( | 389 Code::Flags flags = Code::ComputeFlags( |
| 395 GetCodeKind(), | 390 GetCodeKind(), |
| 396 UNINITIALIZED); | 391 UNINITIALIZED); |
| 397 Handle<Object> probe( | 392 Name* name = strict() ? isolate()->heap()->strict_compare_ic_string() |
| 398 known_map_->FindInCodeCache( | 393 : isolate()->heap()->compare_ic_string(); |
| 399 strict() ? | 394 Code* code = known_map_->LookupInCodeCache(name, flags); |
| 400 *factory->strict_compare_ic_string() : | 395 if (code != nullptr) { |
| 401 *factory->compare_ic_string(), | 396 *code_out = code; |
| 402 flags), | |
| 403 isolate()); | |
| 404 if (probe->IsCode()) { | |
| 405 *code_out = Code::cast(*probe); | |
| 406 #ifdef DEBUG | 397 #ifdef DEBUG |
| 407 CompareICStub decode((*code_out)->stub_key(), isolate()); | 398 CompareICStub decode((*code_out)->stub_key(), isolate()); |
| 408 DCHECK(op() == decode.op()); | 399 DCHECK(op() == decode.op()); |
| 409 DCHECK(left() == decode.left()); | 400 DCHECK(left() == decode.left()); |
| 410 DCHECK(right() == decode.right()); | 401 DCHECK(right() == decode.right()); |
| 411 DCHECK(state() == decode.state()); | 402 DCHECK(state() == decode.state()); |
| 412 #endif | 403 #endif |
| 413 return true; | 404 return true; |
| 414 } | 405 } |
| 415 return false; | 406 return false; |
| (...skipping 3036 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3452 if (type->Is(Type::UntaggedPointer())) { | 3443 if (type->Is(Type::UntaggedPointer())) { |
| 3453 return Representation::External(); | 3444 return Representation::External(); |
| 3454 } | 3445 } |
| 3455 | 3446 |
| 3456 DCHECK(!type->Is(Type::Untagged())); | 3447 DCHECK(!type->Is(Type::Untagged())); |
| 3457 return Representation::Tagged(); | 3448 return Representation::Tagged(); |
| 3458 } | 3449 } |
| 3459 | 3450 |
| 3460 } // namespace internal | 3451 } // namespace internal |
| 3461 } // namespace v8 | 3452 } // namespace v8 |
| OLD | NEW |