OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 22 matching lines...) Expand all Loading... |
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) { |
41 Heap* heap = Isolate::Current()->heap(); | 41 Heap* heap = Isolate::Current()->heap(); |
42 int index = heap->code_stubs()->FindEntry(GetKey()); | 42 int index = heap->code_stubs()->FindEntry(GetKey()); |
43 if (index != NumberDictionary::kNotFound) { | 43 if (index != UnseededNumberDictionary::kNotFound) { |
44 *code_out = Code::cast(heap->code_stubs()->ValueAt(index)); | 44 *code_out = Code::cast(heap->code_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(); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 // Copy the generated code into a heap object. | 114 // Copy the generated code into a heap object. |
115 Code::Flags flags = Code::ComputeFlags( | 115 Code::Flags flags = Code::ComputeFlags( |
116 static_cast<Code::Kind>(GetCodeKind()), | 116 static_cast<Code::Kind>(GetCodeKind()), |
117 GetICState()); | 117 GetICState()); |
118 Handle<Code> new_object = factory->NewCode( | 118 Handle<Code> new_object = factory->NewCode( |
119 desc, flags, masm.CodeObject(), NeedsImmovableCode()); | 119 desc, flags, masm.CodeObject(), NeedsImmovableCode()); |
120 RecordCodeGeneration(*new_object, &masm); | 120 RecordCodeGeneration(*new_object, &masm); |
121 FinishCode(*new_object); | 121 FinishCode(*new_object); |
122 | 122 |
123 // Update the dictionary and the root in Heap. | 123 // Update the dictionary and the root in Heap. |
124 Handle<NumberDictionary> dict = | 124 Handle<UnseededNumberDictionary> dict = |
125 factory->DictionaryAtNumberPut( | 125 factory->DictionaryAtNumberPut( |
126 Handle<NumberDictionary>(heap->code_stubs()), | 126 Handle<UnseededNumberDictionary>(heap->code_stubs()), |
127 GetKey(), | 127 GetKey(), |
128 new_object); | 128 new_object); |
129 heap->public_set_code_stubs(*dict); | 129 heap->public_set_code_stubs(*dict); |
130 | 130 |
131 code = *new_object; | 131 code = *new_object; |
132 } | 132 } |
133 | 133 |
134 ASSERT(!NeedsImmovableCode() || heap->lo_space()->Contains(code)); | 134 ASSERT(!NeedsImmovableCode() || heap->lo_space()->Contains(code)); |
135 return Handle<Code>(code, isolate); | 135 return Handle<Code>(code, isolate); |
136 } | 136 } |
(...skipping 21 matching lines...) Expand all Loading... |
158 if (!maybe_new_object->ToObject(&new_object)) return maybe_new_object; | 158 if (!maybe_new_object->ToObject(&new_object)) return maybe_new_object; |
159 } | 159 } |
160 code = Code::cast(new_object); | 160 code = Code::cast(new_object); |
161 RecordCodeGeneration(code, &masm); | 161 RecordCodeGeneration(code, &masm); |
162 FinishCode(code); | 162 FinishCode(code); |
163 | 163 |
164 // Try to update the code cache but do not fail if unable. | 164 // Try to update the code cache but do not fail if unable. |
165 MaybeObject* maybe_new_object = | 165 MaybeObject* maybe_new_object = |
166 heap->code_stubs()->AtNumberPut(GetKey(), code); | 166 heap->code_stubs()->AtNumberPut(GetKey(), code); |
167 if (maybe_new_object->ToObject(&new_object)) { | 167 if (maybe_new_object->ToObject(&new_object)) { |
168 heap->public_set_code_stubs(NumberDictionary::cast(new_object)); | 168 heap->public_set_code_stubs(UnseededNumberDictionary::cast(new_object)); |
169 } | 169 } |
170 } | 170 } |
171 | 171 |
172 return code; | 172 return code; |
173 } | 173 } |
174 | 174 |
175 | 175 |
176 const char* CodeStub::MajorName(CodeStub::Major major_key, | 176 const char* CodeStub::MajorName(CodeStub::Major major_key, |
177 bool allow_unknown_keys) { | 177 bool allow_unknown_keys) { |
178 switch (major_key) { | 178 switch (major_key) { |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 } | 396 } |
397 | 397 |
398 | 398 |
399 bool ToBooleanStub::Types::CanBeUndetectable() const { | 399 bool ToBooleanStub::Types::CanBeUndetectable() const { |
400 return Contains(ToBooleanStub::SPEC_OBJECT) | 400 return Contains(ToBooleanStub::SPEC_OBJECT) |
401 || Contains(ToBooleanStub::STRING); | 401 || Contains(ToBooleanStub::STRING); |
402 } | 402 } |
403 | 403 |
404 | 404 |
405 } } // namespace v8::internal | 405 } } // namespace v8::internal |
OLD | NEW |