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

Side by Side Diff: src/code-stubs.cc

Issue 11414262: Revert 13105: "Enable stub generation using Hydrogen/Lithium." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 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
« no previous file with comments | « src/code-stubs.h ('k') | src/code-stubs-hydrogen.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 30 matching lines...) Expand all
41 UnseededNumberDictionary* stubs = isolate->heap()->code_stubs(); 41 UnseededNumberDictionary* stubs = isolate->heap()->code_stubs();
42 int index = stubs->FindEntry(GetKey()); 42 int index = stubs->FindEntry(GetKey());
43 if (index != UnseededNumberDictionary::kNotFound) { 43 if (index != UnseededNumberDictionary::kNotFound) {
44 *code_out = Code::cast(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) {
52 // Update the static counter each time a new code stub is generated.
53 masm->isolate()->counters()->code_stubs()->Increment();
54
55 // Nested stubs are not allowed for leaves.
56 AllowStubCallsScope allow_scope(masm, false);
57
58 // Generate the code for the stub.
59 masm->set_generating_stub(true);
60 NoCurrentFrameScope scope(masm);
61 Generate(masm);
62 }
63
64
51 SmartArrayPointer<const char> CodeStub::GetName() { 65 SmartArrayPointer<const char> CodeStub::GetName() {
52 char buffer[100]; 66 char buffer[100];
53 NoAllocationStringAllocator allocator(buffer, 67 NoAllocationStringAllocator allocator(buffer,
54 static_cast<unsigned>(sizeof(buffer))); 68 static_cast<unsigned>(sizeof(buffer)));
55 StringStream stream(&allocator); 69 StringStream stream(&allocator);
56 PrintName(&stream); 70 PrintName(&stream);
57 return stream.ToCString(); 71 return stream.ToCString();
58 } 72 }
59 73
60 74
61 void CodeStub::RecordCodeGeneration(Code* code, Isolate* isolate) { 75 void CodeStub::RecordCodeGeneration(Code* code, MacroAssembler* masm) {
76 Isolate* isolate = masm->isolate();
62 SmartArrayPointer<const char> name = GetName(); 77 SmartArrayPointer<const char> name = GetName();
63 PROFILE(isolate, CodeCreateEvent(Logger::STUB_TAG, code, *name)); 78 PROFILE(isolate, CodeCreateEvent(Logger::STUB_TAG, code, *name));
64 GDBJIT(AddCode(GDBJITInterface::STUB, *name, code)); 79 GDBJIT(AddCode(GDBJITInterface::STUB, *name, code));
65 Counters* counters = isolate->counters(); 80 Counters* counters = isolate->counters();
66 counters->total_stubs_code_size()->Increment(code->instruction_size()); 81 counters->total_stubs_code_size()->Increment(code->instruction_size());
67 } 82 }
68 83
69 84
70 int CodeStub::GetCodeKind() { 85 int CodeStub::GetCodeKind() {
71 return Code::STUB; 86 return Code::STUB;
72 } 87 }
73 88
74 89
75 Handle<Code> PlatformCodeStub::GenerateCode() {
76 Isolate* isolate = Isolate::Current();
77 Factory* factory = isolate->factory();
78
79 // Generate the new code.
80 MacroAssembler masm(isolate, NULL, 256);
81
82 {
83 // Update the static counter each time a new code stub is generated.
84 isolate->counters()->code_stubs()->Increment();
85
86 // Nested stubs are not allowed for leaves.
87 AllowStubCallsScope allow_scope(&masm, false);
88
89 // Generate the code for the stub.
90 masm.set_generating_stub(true);
91 NoCurrentFrameScope scope(&masm);
92 Generate(&masm);
93 }
94
95 // Create the code object.
96 CodeDesc desc;
97 masm.GetCode(&desc);
98
99 // Copy the generated code into a heap object.
100 Code::Flags flags = Code::ComputeFlags(
101 static_cast<Code::Kind>(GetCodeKind()), GetICState());
102 Handle<Code> new_object = factory->NewCode(
103 desc, flags, masm.CodeObject(), NeedsImmovableCode());
104 return new_object;
105 }
106
107
108 Handle<Code> CodeStub::GetCode() { 90 Handle<Code> CodeStub::GetCode() {
109 Isolate* isolate = Isolate::Current(); 91 Isolate* isolate = Isolate::Current();
110 Factory* factory = isolate->factory(); 92 Factory* factory = isolate->factory();
111 Heap* heap = isolate->heap(); 93 Heap* heap = isolate->heap();
112 Code* code; 94 Code* code;
113 if (UseSpecialCache() 95 if (UseSpecialCache()
114 ? FindCodeInSpecialCache(&code, isolate) 96 ? FindCodeInSpecialCache(&code, isolate)
115 : FindCodeInCache(&code, isolate)) { 97 : FindCodeInCache(&code, isolate)) {
116 ASSERT(IsPregenerated() == code->is_pregenerated()); 98 ASSERT(IsPregenerated() == code->is_pregenerated());
117 return Handle<Code>(code); 99 return Handle<Code>(code);
118 } 100 }
119 101
120 { 102 {
121 HandleScope scope(isolate); 103 HandleScope scope(isolate);
122 104
123 Handle<Code> new_object = GenerateCode(); 105 // Generate the new code.
106 MacroAssembler masm(isolate, NULL, 256);
107 GenerateCode(&masm);
108
109 // Create the code object.
110 CodeDesc desc;
111 masm.GetCode(&desc);
112
113 // Copy the generated code into a heap object.
114 Code::Flags flags = Code::ComputeFlags(
115 static_cast<Code::Kind>(GetCodeKind()),
116 GetICState());
117 Handle<Code> new_object = factory->NewCode(
118 desc, flags, masm.CodeObject(), NeedsImmovableCode());
124 new_object->set_major_key(MajorKey()); 119 new_object->set_major_key(MajorKey());
125 FinishCode(new_object); 120 FinishCode(new_object);
126 RecordCodeGeneration(*new_object, isolate); 121 RecordCodeGeneration(*new_object, &masm);
127 122
128 #ifdef ENABLE_DISASSEMBLER 123 #ifdef ENABLE_DISASSEMBLER
129 if (FLAG_print_code_stubs) { 124 if (FLAG_print_code_stubs) {
130 new_object->Disassemble(*GetName()); 125 new_object->Disassemble(*GetName());
131 PrintF("\n"); 126 PrintF("\n");
132 } 127 }
133 #endif 128 #endif
134 129
135 if (UseSpecialCache()) { 130 if (UseSpecialCache()) {
136 AddToSpecialCache(new_object); 131 AddToSpecialCache(new_object);
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 409
415 410
416 void JSEntryStub::FinishCode(Handle<Code> code) { 411 void JSEntryStub::FinishCode(Handle<Code> code) {
417 Handle<FixedArray> handler_table = 412 Handle<FixedArray> handler_table =
418 code->GetIsolate()->factory()->NewFixedArray(1, TENURED); 413 code->GetIsolate()->factory()->NewFixedArray(1, TENURED);
419 handler_table->set(0, Smi::FromInt(handler_offset_)); 414 handler_table->set(0, Smi::FromInt(handler_offset_));
420 code->set_handler_table(*handler_table); 415 code->set_handler_table(*handler_table);
421 } 416 }
422 417
423 418
424 void KeyedLoadDictionaryElementStub::Generate(MacroAssembler* masm) { 419 void KeyedLoadElementStub::Generate(MacroAssembler* masm) {
425 KeyedLoadStubCompiler::GenerateLoadDictionaryElement(masm); 420 switch (elements_kind_) {
421 case FAST_ELEMENTS:
422 case FAST_HOLEY_ELEMENTS:
423 case FAST_SMI_ELEMENTS:
424 case FAST_HOLEY_SMI_ELEMENTS:
425 KeyedLoadStubCompiler::GenerateLoadFastElement(masm);
426 break;
427 case FAST_DOUBLE_ELEMENTS:
428 case FAST_HOLEY_DOUBLE_ELEMENTS:
429 KeyedLoadStubCompiler::GenerateLoadFastDoubleElement(masm);
430 break;
431 case EXTERNAL_BYTE_ELEMENTS:
432 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS:
433 case EXTERNAL_SHORT_ELEMENTS:
434 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS:
435 case EXTERNAL_INT_ELEMENTS:
436 case EXTERNAL_UNSIGNED_INT_ELEMENTS:
437 case EXTERNAL_FLOAT_ELEMENTS:
438 case EXTERNAL_DOUBLE_ELEMENTS:
439 case EXTERNAL_PIXEL_ELEMENTS:
440 KeyedLoadStubCompiler::GenerateLoadExternalArray(masm, elements_kind_);
441 break;
442 case DICTIONARY_ELEMENTS:
443 KeyedLoadStubCompiler::GenerateLoadDictionaryElement(masm);
444 break;
445 case NON_STRICT_ARGUMENTS_ELEMENTS:
446 UNREACHABLE();
447 break;
448 }
426 } 449 }
427 450
428 451
429 void KeyedStoreElementStub::Generate(MacroAssembler* masm) { 452 void KeyedStoreElementStub::Generate(MacroAssembler* masm) {
430 switch (elements_kind_) { 453 switch (elements_kind_) {
431 case FAST_ELEMENTS: 454 case FAST_ELEMENTS:
432 case FAST_HOLEY_ELEMENTS: 455 case FAST_HOLEY_ELEMENTS:
433 case FAST_SMI_ELEMENTS: 456 case FAST_SMI_ELEMENTS:
434 case FAST_HOLEY_SMI_ELEMENTS: { 457 case FAST_HOLEY_SMI_ELEMENTS: {
435 KeyedStoreStubCompiler::GenerateStoreFastElement(masm, 458 KeyedStoreStubCompiler::GenerateStoreFastElement(masm,
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 // already active, as the hooks won't stack. 643 // already active, as the hooks won't stack.
621 if (entry_hook != 0 && entry_hook_ != 0) 644 if (entry_hook != 0 && entry_hook_ != 0)
622 return false; 645 return false;
623 646
624 entry_hook_ = entry_hook; 647 entry_hook_ = entry_hook;
625 return true; 648 return true;
626 } 649 }
627 650
628 651
629 } } // namespace v8::internal 652 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/code-stubs.h ('k') | src/code-stubs-hydrogen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698