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

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

Issue 6685088: Merge isolates to bleeding_edge. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years, 9 months 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/checks.cc ('k') | src/codegen.h » ('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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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
30 #include "bootstrapper.h" 30 #include "bootstrapper.h"
31 #include "code-stubs.h" 31 #include "code-stubs.h"
32 #include "factory.h" 32 #include "factory.h"
33 #include "gdb-jit.h" 33 #include "gdb-jit.h"
34 #include "macro-assembler.h" 34 #include "macro-assembler.h"
35 35
36 namespace v8 { 36 namespace v8 {
37 namespace internal { 37 namespace internal {
38 38
39 bool CodeStub::FindCodeInCache(Code** code_out) { 39 bool CodeStub::FindCodeInCache(Code** code_out) {
40 int index = Heap::code_stubs()->FindEntry(GetKey()); 40 int index = HEAP->code_stubs()->FindEntry(GetKey());
41 if (index != NumberDictionary::kNotFound) { 41 if (index != NumberDictionary::kNotFound) {
42 *code_out = Code::cast(Heap::code_stubs()->ValueAt(index)); 42 *code_out = Code::cast(HEAP->code_stubs()->ValueAt(index));
43 return true; 43 return true;
44 } 44 }
45 return false; 45 return false;
46 } 46 }
47 47
48 48
49 void CodeStub::GenerateCode(MacroAssembler* masm) { 49 void CodeStub::GenerateCode(MacroAssembler* masm) {
50 // Update the static counter each time a new code stub is generated. 50 // Update the static counter each time a new code stub is generated.
51 Counters::code_stubs.Increment(); 51 COUNTERS->code_stubs()->Increment();
52 52
53 // Nested stubs are not allowed for leafs. 53 // Nested stubs are not allowed for leafs.
54 AllowStubCallsScope allow_scope(masm, AllowsStubCalls()); 54 AllowStubCallsScope allow_scope(masm, AllowsStubCalls());
55 55
56 // Generate the code for the stub. 56 // Generate the code for the stub.
57 masm->set_generating_stub(true); 57 masm->set_generating_stub(true);
58 Generate(masm); 58 Generate(masm);
59 } 59 }
60 60
61 61
62 void CodeStub::RecordCodeGeneration(Code* code, MacroAssembler* masm) { 62 void CodeStub::RecordCodeGeneration(Code* code, MacroAssembler* masm) {
63 code->set_major_key(MajorKey()); 63 code->set_major_key(MajorKey());
64 64
65 PROFILE(CodeCreateEvent(Logger::STUB_TAG, code, GetName())); 65 PROFILE(ISOLATE, CodeCreateEvent(Logger::STUB_TAG, code, GetName()));
66 GDBJIT(AddCode(GDBJITInterface::STUB, GetName(), code)); 66 GDBJIT(AddCode(GDBJITInterface::STUB, GetName(), code));
67 Counters::total_stubs_code_size.Increment(code->instruction_size()); 67 COUNTERS->total_stubs_code_size()->Increment(code->instruction_size());
68 68
69 #ifdef ENABLE_DISASSEMBLER 69 #ifdef ENABLE_DISASSEMBLER
70 if (FLAG_print_code_stubs) { 70 if (FLAG_print_code_stubs) {
71 #ifdef DEBUG 71 #ifdef DEBUG
72 Print(); 72 Print();
73 #endif 73 #endif
74 code->Disassemble(GetName()); 74 code->Disassemble(GetName());
75 PrintF("\n"); 75 PrintF("\n");
76 } 76 }
77 #endif 77 #endif
(...skipping 16 matching lines...) Expand all
94 94
95 // Create the code object. 95 // Create the code object.
96 CodeDesc desc; 96 CodeDesc desc;
97 masm.GetCode(&desc); 97 masm.GetCode(&desc);
98 98
99 // Copy the generated code into a heap object. 99 // Copy the generated code into a heap object.
100 Code::Flags flags = Code::ComputeFlags( 100 Code::Flags flags = Code::ComputeFlags(
101 static_cast<Code::Kind>(GetCodeKind()), 101 static_cast<Code::Kind>(GetCodeKind()),
102 InLoop(), 102 InLoop(),
103 GetICState()); 103 GetICState());
104 Handle<Code> new_object = Factory::NewCode( 104 Handle<Code> new_object = FACTORY->NewCode(
105 desc, flags, masm.CodeObject(), NeedsImmovableCode()); 105 desc, flags, masm.CodeObject(), NeedsImmovableCode());
106 RecordCodeGeneration(*new_object, &masm); 106 RecordCodeGeneration(*new_object, &masm);
107 FinishCode(*new_object); 107 FinishCode(*new_object);
108 108
109 // Update the dictionary and the root in Heap. 109 // Update the dictionary and the root in Heap.
110 Handle<NumberDictionary> dict = 110 Handle<NumberDictionary> dict =
111 Factory::DictionaryAtNumberPut( 111 FACTORY->DictionaryAtNumberPut(
112 Handle<NumberDictionary>(Heap::code_stubs()), 112 Handle<NumberDictionary>(HEAP->code_stubs()),
113 GetKey(), 113 GetKey(),
114 new_object); 114 new_object);
115 Heap::public_set_code_stubs(*dict); 115 HEAP->public_set_code_stubs(*dict);
116 116
117 code = *new_object; 117 code = *new_object;
118 } 118 }
119 119
120 ASSERT(!NeedsImmovableCode() || Heap::lo_space()->Contains(code)); 120 ASSERT(!NeedsImmovableCode() || HEAP->lo_space()->Contains(code));
121 return Handle<Code>(code); 121 return Handle<Code>(code);
122 } 122 }
123 123
124 124
125 MaybeObject* CodeStub::TryGetCode() { 125 MaybeObject* CodeStub::TryGetCode() {
126 Code* code; 126 Code* code;
127 if (!FindCodeInCache(&code)) { 127 if (!FindCodeInCache(&code)) {
128 // Generate the new code. 128 // Generate the new code.
129 MacroAssembler masm(NULL, 256); 129 MacroAssembler masm(NULL, 256);
130 GenerateCode(&masm); 130 GenerateCode(&masm);
131 131
132 // Create the code object. 132 // Create the code object.
133 CodeDesc desc; 133 CodeDesc desc;
134 masm.GetCode(&desc); 134 masm.GetCode(&desc);
135 135
136 // Try to copy the generated code into a heap object. 136 // Try to copy the generated code into a heap object.
137 Code::Flags flags = Code::ComputeFlags( 137 Code::Flags flags = Code::ComputeFlags(
138 static_cast<Code::Kind>(GetCodeKind()), 138 static_cast<Code::Kind>(GetCodeKind()),
139 InLoop(), 139 InLoop(),
140 GetICState()); 140 GetICState());
141 Object* new_object; 141 Object* new_object;
142 { MaybeObject* maybe_new_object = 142 { MaybeObject* maybe_new_object =
143 Heap::CreateCode(desc, flags, masm.CodeObject()); 143 HEAP->CreateCode(desc, flags, masm.CodeObject());
144 if (!maybe_new_object->ToObject(&new_object)) return maybe_new_object; 144 if (!maybe_new_object->ToObject(&new_object)) return maybe_new_object;
145 } 145 }
146 code = Code::cast(new_object); 146 code = Code::cast(new_object);
147 RecordCodeGeneration(code, &masm); 147 RecordCodeGeneration(code, &masm);
148 FinishCode(code); 148 FinishCode(code);
149 149
150 // Try to update the code cache but do not fail if unable. 150 // Try to update the code cache but do not fail if unable.
151 MaybeObject* maybe_new_object = 151 MaybeObject* maybe_new_object =
152 Heap::code_stubs()->AtNumberPut(GetKey(), code); 152 HEAP->code_stubs()->AtNumberPut(GetKey(), code);
153 if (maybe_new_object->ToObject(&new_object)) { 153 if (maybe_new_object->ToObject(&new_object)) {
154 Heap::public_set_code_stubs(NumberDictionary::cast(new_object)); 154 HEAP->public_set_code_stubs(NumberDictionary::cast(new_object));
155 } 155 }
156 } 156 }
157 157
158 return code; 158 return code;
159 } 159 }
160 160
161 161
162 const char* CodeStub::MajorName(CodeStub::Major major_key, 162 const char* CodeStub::MajorName(CodeStub::Major major_key,
163 bool allow_unknown_keys) { 163 bool allow_unknown_keys) {
164 switch (major_key) { 164 switch (major_key) {
(...skipping 30 matching lines...) Expand all
195 break; 195 break;
196 default: 196 default:
197 UNREACHABLE(); 197 UNREACHABLE();
198 } 198 }
199 } 199 }
200 200
201 201
202 const char* InstanceofStub::GetName() { 202 const char* InstanceofStub::GetName() {
203 if (name_ != NULL) return name_; 203 if (name_ != NULL) return name_;
204 const int kMaxNameLength = 100; 204 const int kMaxNameLength = 100;
205 name_ = Bootstrapper::AllocateAutoDeletedArray(kMaxNameLength); 205 name_ = Isolate::Current()->bootstrapper()->AllocateAutoDeletedArray(
206 kMaxNameLength);
206 if (name_ == NULL) return "OOM"; 207 if (name_ == NULL) return "OOM";
207 208
208 const char* args = ""; 209 const char* args = "";
209 if (HasArgsInRegisters()) { 210 if (HasArgsInRegisters()) {
210 args = "_REGS"; 211 args = "_REGS";
211 } 212 }
212 213
213 const char* inline_check = ""; 214 const char* inline_check = "";
214 if (HasCallSiteInlineCheck()) { 215 if (HasCallSiteInlineCheck()) {
215 inline_check = "_INLINE"; 216 inline_check = "_INLINE";
216 } 217 }
217 218
218 const char* return_true_false_object = ""; 219 const char* return_true_false_object = "";
219 if (ReturnTrueFalseObject()) { 220 if (ReturnTrueFalseObject()) {
220 return_true_false_object = "_TRUEFALSE"; 221 return_true_false_object = "_TRUEFALSE";
221 } 222 }
222 223
223 OS::SNPrintF(Vector<char>(name_, kMaxNameLength), 224 OS::SNPrintF(Vector<char>(name_, kMaxNameLength),
224 "InstanceofStub%s%s%s", 225 "InstanceofStub%s%s%s",
225 args, 226 args,
226 inline_check, 227 inline_check,
227 return_true_false_object); 228 return_true_false_object);
228 return name_; 229 return name_;
229 } 230 }
230 231
231 232
232 } } // namespace v8::internal 233 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/checks.cc ('k') | src/codegen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698