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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 | 54 |
55 // Nested stubs are not allowed for leafs. | 55 // Nested stubs are not allowed for leafs. |
56 AllowStubCallsScope allow_scope(masm, AllowsStubCalls()); | 56 AllowStubCallsScope allow_scope(masm, AllowsStubCalls()); |
57 | 57 |
58 // Generate the code for the stub. | 58 // Generate the code for the stub. |
59 masm->set_generating_stub(true); | 59 masm->set_generating_stub(true); |
60 Generate(masm); | 60 Generate(masm); |
61 } | 61 } |
62 | 62 |
63 | 63 |
| 64 SmartPointer<const char> CodeStub::GetName() { |
| 65 char buffer[100]; |
| 66 NoAllocationStringAllocator allocator(buffer, |
| 67 static_cast<unsigned>(sizeof(buffer))); |
| 68 StringStream stream(&allocator); |
| 69 PrintName(&stream); |
| 70 return stream.ToCString(); |
| 71 } |
| 72 |
| 73 |
64 void CodeStub::RecordCodeGeneration(Code* code, MacroAssembler* masm) { | 74 void CodeStub::RecordCodeGeneration(Code* code, MacroAssembler* masm) { |
65 code->set_major_key(MajorKey()); | 75 code->set_major_key(MajorKey()); |
66 | 76 |
67 Isolate* isolate = masm->isolate(); | 77 Isolate* isolate = masm->isolate(); |
68 PROFILE(isolate, CodeCreateEvent(Logger::STUB_TAG, code, GetName())); | 78 SmartPointer<const char> name = GetName(); |
69 GDBJIT(AddCode(GDBJITInterface::STUB, GetName(), code)); | 79 PROFILE(isolate, CodeCreateEvent(Logger::STUB_TAG, code, *name)); |
| 80 GDBJIT(AddCode(GDBJITInterface::STUB, *name, code)); |
70 Counters* counters = isolate->counters(); | 81 Counters* counters = isolate->counters(); |
71 counters->total_stubs_code_size()->Increment(code->instruction_size()); | 82 counters->total_stubs_code_size()->Increment(code->instruction_size()); |
72 | 83 |
73 #ifdef ENABLE_DISASSEMBLER | 84 #ifdef ENABLE_DISASSEMBLER |
74 if (FLAG_print_code_stubs) { | 85 if (FLAG_print_code_stubs) { |
75 #ifdef DEBUG | 86 code->Disassemble(*name); |
76 Print(); | |
77 #endif | |
78 code->Disassemble(GetName()); | |
79 PrintF("\n"); | 87 PrintF("\n"); |
80 } | 88 } |
81 #endif | 89 #endif |
82 } | 90 } |
83 | 91 |
84 | 92 |
85 int CodeStub::GetCodeKind() { | 93 int CodeStub::GetCodeKind() { |
86 return Code::STUB; | 94 return Code::STUB; |
87 } | 95 } |
88 | 96 |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 break; | 214 break; |
207 case CompareIC::OBJECTS: | 215 case CompareIC::OBJECTS: |
208 GenerateObjects(masm); | 216 GenerateObjects(masm); |
209 break; | 217 break; |
210 default: | 218 default: |
211 UNREACHABLE(); | 219 UNREACHABLE(); |
212 } | 220 } |
213 } | 221 } |
214 | 222 |
215 | 223 |
216 const char* InstanceofStub::GetName() { | 224 void InstanceofStub::PrintName(StringStream* stream) { |
217 if (name_ != NULL) return name_; | |
218 const int kMaxNameLength = 100; | |
219 name_ = Isolate::Current()->bootstrapper()->AllocateAutoDeletedArray( | |
220 kMaxNameLength); | |
221 if (name_ == NULL) return "OOM"; | |
222 | |
223 const char* args = ""; | 225 const char* args = ""; |
224 if (HasArgsInRegisters()) { | 226 if (HasArgsInRegisters()) { |
225 args = "_REGS"; | 227 args = "_REGS"; |
226 } | 228 } |
227 | 229 |
228 const char* inline_check = ""; | 230 const char* inline_check = ""; |
229 if (HasCallSiteInlineCheck()) { | 231 if (HasCallSiteInlineCheck()) { |
230 inline_check = "_INLINE"; | 232 inline_check = "_INLINE"; |
231 } | 233 } |
232 | 234 |
233 const char* return_true_false_object = ""; | 235 const char* return_true_false_object = ""; |
234 if (ReturnTrueFalseObject()) { | 236 if (ReturnTrueFalseObject()) { |
235 return_true_false_object = "_TRUEFALSE"; | 237 return_true_false_object = "_TRUEFALSE"; |
236 } | 238 } |
237 | 239 |
238 OS::SNPrintF(Vector<char>(name_, kMaxNameLength), | 240 stream->Add("InstanceofStub%s%s%s", |
239 "InstanceofStub%s%s%s", | 241 args, |
240 args, | 242 inline_check, |
241 inline_check, | 243 return_true_false_object); |
242 return_true_false_object); | |
243 return name_; | |
244 } | 244 } |
245 | 245 |
246 | 246 |
247 void KeyedLoadElementStub::Generate(MacroAssembler* masm) { | 247 void KeyedLoadElementStub::Generate(MacroAssembler* masm) { |
248 switch (elements_kind_) { | 248 switch (elements_kind_) { |
249 case JSObject::FAST_ELEMENTS: | 249 case JSObject::FAST_ELEMENTS: |
250 KeyedLoadStubCompiler::GenerateLoadFastElement(masm); | 250 KeyedLoadStubCompiler::GenerateLoadFastElement(masm); |
251 break; | 251 break; |
252 case JSObject::FAST_DOUBLE_ELEMENTS: | 252 case JSObject::FAST_DOUBLE_ELEMENTS: |
253 UNIMPLEMENTED(); | 253 UNIMPLEMENTED(); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 case JSObject::DICTIONARY_ELEMENTS: | 295 case JSObject::DICTIONARY_ELEMENTS: |
296 KeyedStoreStubCompiler::GenerateStoreDictionaryElement(masm); | 296 KeyedStoreStubCompiler::GenerateStoreDictionaryElement(masm); |
297 break; | 297 break; |
298 case JSObject::NON_STRICT_ARGUMENTS_ELEMENTS: | 298 case JSObject::NON_STRICT_ARGUMENTS_ELEMENTS: |
299 UNREACHABLE(); | 299 UNREACHABLE(); |
300 break; | 300 break; |
301 } | 301 } |
302 } | 302 } |
303 | 303 |
304 | 304 |
| 305 void ArgumentsAccessStub::PrintName(StringStream* stream) { |
| 306 const char* type_name = NULL; // Make g++ happy. |
| 307 switch (type_) { |
| 308 case READ_ELEMENT: type_name = "ReadElement"; break; |
| 309 case NEW_NON_STRICT_FAST: type_name = "NewNonStrictFast"; break; |
| 310 case NEW_NON_STRICT_SLOW: type_name = "NewNonStrictSlow"; break; |
| 311 case NEW_STRICT: type_name = "NewStrict"; break; |
| 312 } |
| 313 stream->Add("ArgumentsAccessStub_%s", type_name); |
| 314 } |
| 315 |
| 316 |
| 317 void CallFunctionStub::PrintName(StringStream* stream) { |
| 318 const char* in_loop_name = NULL; // Make g++ happy. |
| 319 switch (in_loop_) { |
| 320 case NOT_IN_LOOP: in_loop_name = ""; break; |
| 321 case IN_LOOP: in_loop_name = "_InLoop"; break; |
| 322 } |
| 323 const char* flags_name = NULL; // Make g++ happy. |
| 324 switch (flags_) { |
| 325 case NO_CALL_FUNCTION_FLAGS: flags_name = ""; break; |
| 326 case RECEIVER_MIGHT_BE_IMPLICIT: flags_name = "_Implicit"; break; |
| 327 } |
| 328 stream->Add("CallFunctionStub_Args%d%s%s", argc_, in_loop_name, flags_name); |
| 329 } |
| 330 |
305 } } // namespace v8::internal | 331 } } // namespace v8::internal |
OLD | NEW |