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

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

Issue 4695003: Removing redundant stubs for API functions. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 1 month 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
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 "macro-assembler.h" 33 #include "macro-assembler.h"
34 #include "oprofile-agent.h" 34 #include "oprofile-agent.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 if (has_custom_cache()) return GetCustomCache(code_out);
41 int index = Heap::code_stubs()->FindEntry(GetKey()); 40 int index = Heap::code_stubs()->FindEntry(GetKey());
42 if (index != NumberDictionary::kNotFound) { 41 if (index != NumberDictionary::kNotFound) {
43 *code_out = Code::cast(Heap::code_stubs()->ValueAt(index)); 42 *code_out = Code::cast(Heap::code_stubs()->ValueAt(index));
44 return true; 43 return true;
45 } 44 }
46 return false; 45 return false;
47 } 46 }
48 47
49 48
50 void CodeStub::GenerateCode(MacroAssembler* masm) { 49 void CodeStub::GenerateCode(MacroAssembler* masm) {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 masm.GetCode(&desc); 97 masm.GetCode(&desc);
99 98
100 // Copy the generated code into a heap object. 99 // Copy the generated code into a heap object.
101 Code::Flags flags = Code::ComputeFlags( 100 Code::Flags flags = Code::ComputeFlags(
102 static_cast<Code::Kind>(GetCodeKind()), 101 static_cast<Code::Kind>(GetCodeKind()),
103 InLoop(), 102 InLoop(),
104 GetICState()); 103 GetICState());
105 Handle<Code> new_object = Factory::NewCode(desc, flags, masm.CodeObject()); 104 Handle<Code> new_object = Factory::NewCode(desc, flags, masm.CodeObject());
106 RecordCodeGeneration(*new_object, &masm); 105 RecordCodeGeneration(*new_object, &masm);
107 106
108 if (has_custom_cache()) { 107 // Update the dictionary and the root in Heap.
109 SetCustomCache(*new_object); 108 Handle<NumberDictionary> dict =
110 } else { 109 Factory::DictionaryAtNumberPut(
111 // Update the dictionary and the root in Heap. 110 Handle<NumberDictionary>(Heap::code_stubs()),
112 Handle<NumberDictionary> dict = 111 GetKey(),
113 Factory::DictionaryAtNumberPut( 112 new_object);
114 Handle<NumberDictionary>(Heap::code_stubs()), 113 Heap::public_set_code_stubs(*dict);
115 GetKey(), 114
116 new_object);
117 Heap::public_set_code_stubs(*dict);
118 }
119 code = *new_object; 115 code = *new_object;
120 } 116 }
121 117
122 return Handle<Code>(code); 118 return Handle<Code>(code);
123 } 119 }
124 120
125 121
126 MaybeObject* CodeStub::TryGetCode() { 122 MaybeObject* CodeStub::TryGetCode() {
127 Code* code; 123 Code* code;
128 if (!FindCodeInCache(&code)) { 124 if (!FindCodeInCache(&code)) {
(...skipping 11 matching lines...) Expand all
140 InLoop(), 136 InLoop(),
141 GetICState()); 137 GetICState());
142 Object* new_object; 138 Object* new_object;
143 { MaybeObject* maybe_new_object = 139 { MaybeObject* maybe_new_object =
144 Heap::CreateCode(desc, flags, masm.CodeObject()); 140 Heap::CreateCode(desc, flags, masm.CodeObject());
145 if (!maybe_new_object->ToObject(&new_object)) return maybe_new_object; 141 if (!maybe_new_object->ToObject(&new_object)) return maybe_new_object;
146 } 142 }
147 code = Code::cast(new_object); 143 code = Code::cast(new_object);
148 RecordCodeGeneration(code, &masm); 144 RecordCodeGeneration(code, &masm);
149 145
150 if (has_custom_cache()) { 146 // Try to update the code cache but do not fail if unable.
151 SetCustomCache(code); 147 MaybeObject* maybe_new_object =
152 } else { 148 Heap::code_stubs()->AtNumberPut(GetKey(), code);
antonm 2010/11/15 16:22:06 [cosmetic nit] just asking: can this fit one line
SeRya 2010/11/15 16:37:50 It can't (only if shorten the var name).
153 // Try to update the code cache but do not fail if unable. 149 if (maybe_new_object->ToObject(&new_object)) {
154 MaybeObject* maybe_new_object = 150 Heap::public_set_code_stubs(NumberDictionary::cast(new_object));
155 Heap::code_stubs()->AtNumberPut(GetKey(), code);
156 if (maybe_new_object->ToObject(&new_object)) {
157 Heap::public_set_code_stubs(NumberDictionary::cast(new_object));
158 }
159 } 151 }
160 } 152 }
161 153
162 return code; 154 return code;
163 } 155 }
164 156
165 157
166 const char* CodeStub::MajorName(CodeStub::Major major_key, 158 const char* CodeStub::MajorName(CodeStub::Major major_key,
167 bool allow_unknown_keys) { 159 bool allow_unknown_keys) {
168 switch (major_key) { 160 switch (major_key) {
169 #define DEF_CASE(name) case name: return #name; 161 #define DEF_CASE(name) case name: return #name;
170 CODE_STUB_LIST(DEF_CASE) 162 CODE_STUB_LIST(DEF_CASE)
171 #undef DEF_CASE 163 #undef DEF_CASE
172 default: 164 default:
173 if (!allow_unknown_keys) { 165 if (!allow_unknown_keys) {
174 UNREACHABLE(); 166 UNREACHABLE();
175 } 167 }
176 return NULL; 168 return NULL;
177 } 169 }
178 } 170 }
179 171
180 172
181 } } // namespace v8::internal 173 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/code-stubs.h ('k') | src/codegen.cc » ('j') | src/x64/macro-assembler-x64.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698