| OLD | NEW |
| 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 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 11 matching lines...) Expand all Loading... |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #include "v8.h" | 28 #include "v8.h" |
| 29 | 29 |
| 30 #include "api.h" | 30 #include "api.h" |
| 31 #include "arguments.h" | 31 #include "arguments.h" |
| 32 #include "gdb-jit.h" |
| 32 #include "ic-inl.h" | 33 #include "ic-inl.h" |
| 33 #include "stub-cache.h" | 34 #include "stub-cache.h" |
| 34 #include "vm-state-inl.h" | 35 #include "vm-state-inl.h" |
| 35 | 36 |
| 36 namespace v8 { | 37 namespace v8 { |
| 37 namespace internal { | 38 namespace internal { |
| 38 | 39 |
| 39 // ----------------------------------------------------------------------- | 40 // ----------------------------------------------------------------------- |
| 40 // StubCache implementation. | 41 // StubCache implementation. |
| 41 | 42 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 Code::Flags flags = | 116 Code::Flags flags = |
| 116 Code::ComputeMonomorphicFlags(Code::LOAD_IC, NONEXISTENT); | 117 Code::ComputeMonomorphicFlags(Code::LOAD_IC, NONEXISTENT); |
| 117 Object* code = receiver->map()->FindInCodeCache(cache_name, flags); | 118 Object* code = receiver->map()->FindInCodeCache(cache_name, flags); |
| 118 if (code->IsUndefined()) { | 119 if (code->IsUndefined()) { |
| 119 LoadStubCompiler compiler; | 120 LoadStubCompiler compiler; |
| 120 { MaybeObject* maybe_code = | 121 { MaybeObject* maybe_code = |
| 121 compiler.CompileLoadNonexistent(cache_name, receiver, last); | 122 compiler.CompileLoadNonexistent(cache_name, receiver, last); |
| 122 if (!maybe_code->ToObject(&code)) return maybe_code; | 123 if (!maybe_code->ToObject(&code)) return maybe_code; |
| 123 } | 124 } |
| 124 PROFILE(CodeCreateEvent(Logger::LOAD_IC_TAG, Code::cast(code), cache_name)); | 125 PROFILE(CodeCreateEvent(Logger::LOAD_IC_TAG, Code::cast(code), cache_name)); |
| 126 GDBJIT(AddCode(GDBJITInterface::LOAD_IC, cache_name, Code::cast(code))); |
| 125 Object* result; | 127 Object* result; |
| 126 { MaybeObject* maybe_result = | 128 { MaybeObject* maybe_result = |
| 127 receiver->UpdateMapCodeCache(cache_name, Code::cast(code)); | 129 receiver->UpdateMapCodeCache(cache_name, Code::cast(code)); |
| 128 if (!maybe_result->ToObject(&result)) return maybe_result; | 130 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 129 } | 131 } |
| 130 } | 132 } |
| 131 return code; | 133 return code; |
| 132 } | 134 } |
| 133 | 135 |
| 134 | 136 |
| 135 MaybeObject* StubCache::ComputeLoadField(String* name, | 137 MaybeObject* StubCache::ComputeLoadField(String* name, |
| 136 JSObject* receiver, | 138 JSObject* receiver, |
| 137 JSObject* holder, | 139 JSObject* holder, |
| 138 int field_index) { | 140 int field_index) { |
| 139 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP); | 141 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP); |
| 140 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::LOAD_IC, FIELD); | 142 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::LOAD_IC, FIELD); |
| 141 Object* code = receiver->map()->FindInCodeCache(name, flags); | 143 Object* code = receiver->map()->FindInCodeCache(name, flags); |
| 142 if (code->IsUndefined()) { | 144 if (code->IsUndefined()) { |
| 143 LoadStubCompiler compiler; | 145 LoadStubCompiler compiler; |
| 144 { MaybeObject* maybe_code = | 146 { MaybeObject* maybe_code = |
| 145 compiler.CompileLoadField(receiver, holder, field_index, name); | 147 compiler.CompileLoadField(receiver, holder, field_index, name); |
| 146 if (!maybe_code->ToObject(&code)) return maybe_code; | 148 if (!maybe_code->ToObject(&code)) return maybe_code; |
| 147 } | 149 } |
| 148 PROFILE(CodeCreateEvent(Logger::LOAD_IC_TAG, Code::cast(code), name)); | 150 PROFILE(CodeCreateEvent(Logger::LOAD_IC_TAG, Code::cast(code), name)); |
| 151 GDBJIT(AddCode(GDBJITInterface::LOAD_IC, name, Code::cast(code))); |
| 149 Object* result; | 152 Object* result; |
| 150 { MaybeObject* maybe_result = | 153 { MaybeObject* maybe_result = |
| 151 receiver->UpdateMapCodeCache(name, Code::cast(code)); | 154 receiver->UpdateMapCodeCache(name, Code::cast(code)); |
| 152 if (!maybe_result->ToObject(&result)) return maybe_result; | 155 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 153 } | 156 } |
| 154 } | 157 } |
| 155 return code; | 158 return code; |
| 156 } | 159 } |
| 157 | 160 |
| 158 | 161 |
| 159 MaybeObject* StubCache::ComputeLoadCallback(String* name, | 162 MaybeObject* StubCache::ComputeLoadCallback(String* name, |
| 160 JSObject* receiver, | 163 JSObject* receiver, |
| 161 JSObject* holder, | 164 JSObject* holder, |
| 162 AccessorInfo* callback) { | 165 AccessorInfo* callback) { |
| 163 ASSERT(v8::ToCData<Address>(callback->getter()) != 0); | 166 ASSERT(v8::ToCData<Address>(callback->getter()) != 0); |
| 164 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP); | 167 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP); |
| 165 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::LOAD_IC, CALLBACKS); | 168 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::LOAD_IC, CALLBACKS); |
| 166 Object* code = receiver->map()->FindInCodeCache(name, flags); | 169 Object* code = receiver->map()->FindInCodeCache(name, flags); |
| 167 if (code->IsUndefined()) { | 170 if (code->IsUndefined()) { |
| 168 LoadStubCompiler compiler; | 171 LoadStubCompiler compiler; |
| 169 { MaybeObject* maybe_code = | 172 { MaybeObject* maybe_code = |
| 170 compiler.CompileLoadCallback(name, receiver, holder, callback); | 173 compiler.CompileLoadCallback(name, receiver, holder, callback); |
| 171 if (!maybe_code->ToObject(&code)) return maybe_code; | 174 if (!maybe_code->ToObject(&code)) return maybe_code; |
| 172 } | 175 } |
| 173 PROFILE(CodeCreateEvent(Logger::LOAD_IC_TAG, Code::cast(code), name)); | 176 PROFILE(CodeCreateEvent(Logger::LOAD_IC_TAG, Code::cast(code), name)); |
| 177 GDBJIT(AddCode(GDBJITInterface::LOAD_IC, name, Code::cast(code))); |
| 174 Object* result; | 178 Object* result; |
| 175 { MaybeObject* maybe_result = | 179 { MaybeObject* maybe_result = |
| 176 receiver->UpdateMapCodeCache(name, Code::cast(code)); | 180 receiver->UpdateMapCodeCache(name, Code::cast(code)); |
| 177 if (!maybe_result->ToObject(&result)) return maybe_result; | 181 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 178 } | 182 } |
| 179 } | 183 } |
| 180 return code; | 184 return code; |
| 181 } | 185 } |
| 182 | 186 |
| 183 | 187 |
| 184 MaybeObject* StubCache::ComputeLoadConstant(String* name, | 188 MaybeObject* StubCache::ComputeLoadConstant(String* name, |
| 185 JSObject* receiver, | 189 JSObject* receiver, |
| 186 JSObject* holder, | 190 JSObject* holder, |
| 187 Object* value) { | 191 Object* value) { |
| 188 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP); | 192 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP); |
| 189 Code::Flags flags = | 193 Code::Flags flags = |
| 190 Code::ComputeMonomorphicFlags(Code::LOAD_IC, CONSTANT_FUNCTION); | 194 Code::ComputeMonomorphicFlags(Code::LOAD_IC, CONSTANT_FUNCTION); |
| 191 Object* code = receiver->map()->FindInCodeCache(name, flags); | 195 Object* code = receiver->map()->FindInCodeCache(name, flags); |
| 192 if (code->IsUndefined()) { | 196 if (code->IsUndefined()) { |
| 193 LoadStubCompiler compiler; | 197 LoadStubCompiler compiler; |
| 194 { MaybeObject* maybe_code = | 198 { MaybeObject* maybe_code = |
| 195 compiler.CompileLoadConstant(receiver, holder, value, name); | 199 compiler.CompileLoadConstant(receiver, holder, value, name); |
| 196 if (!maybe_code->ToObject(&code)) return maybe_code; | 200 if (!maybe_code->ToObject(&code)) return maybe_code; |
| 197 } | 201 } |
| 198 PROFILE(CodeCreateEvent(Logger::LOAD_IC_TAG, Code::cast(code), name)); | 202 PROFILE(CodeCreateEvent(Logger::LOAD_IC_TAG, Code::cast(code), name)); |
| 203 GDBJIT(AddCode(GDBJITInterface::LOAD_IC, name, Code::cast(code))); |
| 199 Object* result; | 204 Object* result; |
| 200 { MaybeObject* maybe_result = | 205 { MaybeObject* maybe_result = |
| 201 receiver->UpdateMapCodeCache(name, Code::cast(code)); | 206 receiver->UpdateMapCodeCache(name, Code::cast(code)); |
| 202 if (!maybe_result->ToObject(&result)) return maybe_result; | 207 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 203 } | 208 } |
| 204 } | 209 } |
| 205 return code; | 210 return code; |
| 206 } | 211 } |
| 207 | 212 |
| 208 | 213 |
| 209 MaybeObject* StubCache::ComputeLoadInterceptor(String* name, | 214 MaybeObject* StubCache::ComputeLoadInterceptor(String* name, |
| 210 JSObject* receiver, | 215 JSObject* receiver, |
| 211 JSObject* holder) { | 216 JSObject* holder) { |
| 212 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP); | 217 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP); |
| 213 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::LOAD_IC, INTERCEPTOR); | 218 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::LOAD_IC, INTERCEPTOR); |
| 214 Object* code = receiver->map()->FindInCodeCache(name, flags); | 219 Object* code = receiver->map()->FindInCodeCache(name, flags); |
| 215 if (code->IsUndefined()) { | 220 if (code->IsUndefined()) { |
| 216 LoadStubCompiler compiler; | 221 LoadStubCompiler compiler; |
| 217 { MaybeObject* maybe_code = | 222 { MaybeObject* maybe_code = |
| 218 compiler.CompileLoadInterceptor(receiver, holder, name); | 223 compiler.CompileLoadInterceptor(receiver, holder, name); |
| 219 if (!maybe_code->ToObject(&code)) return maybe_code; | 224 if (!maybe_code->ToObject(&code)) return maybe_code; |
| 220 } | 225 } |
| 221 PROFILE(CodeCreateEvent(Logger::LOAD_IC_TAG, Code::cast(code), name)); | 226 PROFILE(CodeCreateEvent(Logger::LOAD_IC_TAG, Code::cast(code), name)); |
| 227 GDBJIT(AddCode(GDBJITInterface::LOAD_IC, name, Code::cast(code))); |
| 222 Object* result; | 228 Object* result; |
| 223 { MaybeObject* maybe_result = | 229 { MaybeObject* maybe_result = |
| 224 receiver->UpdateMapCodeCache(name, Code::cast(code)); | 230 receiver->UpdateMapCodeCache(name, Code::cast(code)); |
| 225 if (!maybe_result->ToObject(&result)) return maybe_result; | 231 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 226 } | 232 } |
| 227 } | 233 } |
| 228 return code; | 234 return code; |
| 229 } | 235 } |
| 230 | 236 |
| 231 | 237 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 245 if (code->IsUndefined()) { | 251 if (code->IsUndefined()) { |
| 246 LoadStubCompiler compiler; | 252 LoadStubCompiler compiler; |
| 247 { MaybeObject* maybe_code = compiler.CompileLoadGlobal(receiver, | 253 { MaybeObject* maybe_code = compiler.CompileLoadGlobal(receiver, |
| 248 holder, | 254 holder, |
| 249 cell, | 255 cell, |
| 250 name, | 256 name, |
| 251 is_dont_delete); | 257 is_dont_delete); |
| 252 if (!maybe_code->ToObject(&code)) return maybe_code; | 258 if (!maybe_code->ToObject(&code)) return maybe_code; |
| 253 } | 259 } |
| 254 PROFILE(CodeCreateEvent(Logger::LOAD_IC_TAG, Code::cast(code), name)); | 260 PROFILE(CodeCreateEvent(Logger::LOAD_IC_TAG, Code::cast(code), name)); |
| 261 GDBJIT(AddCode(GDBJITInterface::LOAD_IC, name, Code::cast(code))); |
| 255 Object* result; | 262 Object* result; |
| 256 { MaybeObject* maybe_result = | 263 { MaybeObject* maybe_result = |
| 257 receiver->UpdateMapCodeCache(name, Code::cast(code)); | 264 receiver->UpdateMapCodeCache(name, Code::cast(code)); |
| 258 if (!maybe_result->ToObject(&result)) return maybe_result; | 265 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 259 } | 266 } |
| 260 } | 267 } |
| 261 return code; | 268 return code; |
| 262 } | 269 } |
| 263 | 270 |
| 264 | 271 |
| 265 MaybeObject* StubCache::ComputeKeyedLoadField(String* name, | 272 MaybeObject* StubCache::ComputeKeyedLoadField(String* name, |
| 266 JSObject* receiver, | 273 JSObject* receiver, |
| 267 JSObject* holder, | 274 JSObject* holder, |
| 268 int field_index) { | 275 int field_index) { |
| 269 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP); | 276 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP); |
| 270 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, FIELD); | 277 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, FIELD); |
| 271 Object* code = receiver->map()->FindInCodeCache(name, flags); | 278 Object* code = receiver->map()->FindInCodeCache(name, flags); |
| 272 if (code->IsUndefined()) { | 279 if (code->IsUndefined()) { |
| 273 KeyedLoadStubCompiler compiler; | 280 KeyedLoadStubCompiler compiler; |
| 274 { MaybeObject* maybe_code = | 281 { MaybeObject* maybe_code = |
| 275 compiler.CompileLoadField(name, receiver, holder, field_index); | 282 compiler.CompileLoadField(name, receiver, holder, field_index); |
| 276 if (!maybe_code->ToObject(&code)) return maybe_code; | 283 if (!maybe_code->ToObject(&code)) return maybe_code; |
| 277 } | 284 } |
| 278 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), name)); | 285 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), name)); |
| 286 GDBJIT(AddCode(GDBJITInterface::KEYED_LOAD_IC, name, Code::cast(code))); |
| 279 Object* result; | 287 Object* result; |
| 280 { MaybeObject* maybe_result = | 288 { MaybeObject* maybe_result = |
| 281 receiver->UpdateMapCodeCache(name, Code::cast(code)); | 289 receiver->UpdateMapCodeCache(name, Code::cast(code)); |
| 282 if (!maybe_result->ToObject(&result)) return maybe_result; | 290 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 283 } | 291 } |
| 284 } | 292 } |
| 285 return code; | 293 return code; |
| 286 } | 294 } |
| 287 | 295 |
| 288 | 296 |
| 289 MaybeObject* StubCache::ComputeKeyedLoadConstant(String* name, | 297 MaybeObject* StubCache::ComputeKeyedLoadConstant(String* name, |
| 290 JSObject* receiver, | 298 JSObject* receiver, |
| 291 JSObject* holder, | 299 JSObject* holder, |
| 292 Object* value) { | 300 Object* value) { |
| 293 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP); | 301 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP); |
| 294 Code::Flags flags = | 302 Code::Flags flags = |
| 295 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, CONSTANT_FUNCTION); | 303 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, CONSTANT_FUNCTION); |
| 296 Object* code = receiver->map()->FindInCodeCache(name, flags); | 304 Object* code = receiver->map()->FindInCodeCache(name, flags); |
| 297 if (code->IsUndefined()) { | 305 if (code->IsUndefined()) { |
| 298 KeyedLoadStubCompiler compiler; | 306 KeyedLoadStubCompiler compiler; |
| 299 { MaybeObject* maybe_code = | 307 { MaybeObject* maybe_code = |
| 300 compiler.CompileLoadConstant(name, receiver, holder, value); | 308 compiler.CompileLoadConstant(name, receiver, holder, value); |
| 301 if (!maybe_code->ToObject(&code)) return maybe_code; | 309 if (!maybe_code->ToObject(&code)) return maybe_code; |
| 302 } | 310 } |
| 303 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), name)); | 311 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), name)); |
| 312 GDBJIT(AddCode(GDBJITInterface::KEYED_LOAD_IC, name, Code::cast(code))); |
| 304 Object* result; | 313 Object* result; |
| 305 { MaybeObject* maybe_result = | 314 { MaybeObject* maybe_result = |
| 306 receiver->UpdateMapCodeCache(name, Code::cast(code)); | 315 receiver->UpdateMapCodeCache(name, Code::cast(code)); |
| 307 if (!maybe_result->ToObject(&result)) return maybe_result; | 316 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 308 } | 317 } |
| 309 } | 318 } |
| 310 return code; | 319 return code; |
| 311 } | 320 } |
| 312 | 321 |
| 313 | 322 |
| 314 MaybeObject* StubCache::ComputeKeyedLoadInterceptor(String* name, | 323 MaybeObject* StubCache::ComputeKeyedLoadInterceptor(String* name, |
| 315 JSObject* receiver, | 324 JSObject* receiver, |
| 316 JSObject* holder) { | 325 JSObject* holder) { |
| 317 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP); | 326 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP); |
| 318 Code::Flags flags = | 327 Code::Flags flags = |
| 319 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, INTERCEPTOR); | 328 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, INTERCEPTOR); |
| 320 Object* code = receiver->map()->FindInCodeCache(name, flags); | 329 Object* code = receiver->map()->FindInCodeCache(name, flags); |
| 321 if (code->IsUndefined()) { | 330 if (code->IsUndefined()) { |
| 322 KeyedLoadStubCompiler compiler; | 331 KeyedLoadStubCompiler compiler; |
| 323 { MaybeObject* maybe_code = | 332 { MaybeObject* maybe_code = |
| 324 compiler.CompileLoadInterceptor(receiver, holder, name); | 333 compiler.CompileLoadInterceptor(receiver, holder, name); |
| 325 if (!maybe_code->ToObject(&code)) return maybe_code; | 334 if (!maybe_code->ToObject(&code)) return maybe_code; |
| 326 } | 335 } |
| 327 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), name)); | 336 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), name)); |
| 337 GDBJIT(AddCode(GDBJITInterface::KEYED_LOAD_IC, name, Code::cast(code))); |
| 328 Object* result; | 338 Object* result; |
| 329 { MaybeObject* maybe_result = | 339 { MaybeObject* maybe_result = |
| 330 receiver->UpdateMapCodeCache(name, Code::cast(code)); | 340 receiver->UpdateMapCodeCache(name, Code::cast(code)); |
| 331 if (!maybe_result->ToObject(&result)) return maybe_result; | 341 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 332 } | 342 } |
| 333 } | 343 } |
| 334 return code; | 344 return code; |
| 335 } | 345 } |
| 336 | 346 |
| 337 | 347 |
| 338 MaybeObject* StubCache::ComputeKeyedLoadCallback(String* name, | 348 MaybeObject* StubCache::ComputeKeyedLoadCallback(String* name, |
| 339 JSObject* receiver, | 349 JSObject* receiver, |
| 340 JSObject* holder, | 350 JSObject* holder, |
| 341 AccessorInfo* callback) { | 351 AccessorInfo* callback) { |
| 342 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP); | 352 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP); |
| 343 Code::Flags flags = | 353 Code::Flags flags = |
| 344 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, CALLBACKS); | 354 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, CALLBACKS); |
| 345 Object* code = receiver->map()->FindInCodeCache(name, flags); | 355 Object* code = receiver->map()->FindInCodeCache(name, flags); |
| 346 if (code->IsUndefined()) { | 356 if (code->IsUndefined()) { |
| 347 KeyedLoadStubCompiler compiler; | 357 KeyedLoadStubCompiler compiler; |
| 348 { MaybeObject* maybe_code = | 358 { MaybeObject* maybe_code = |
| 349 compiler.CompileLoadCallback(name, receiver, holder, callback); | 359 compiler.CompileLoadCallback(name, receiver, holder, callback); |
| 350 if (!maybe_code->ToObject(&code)) return maybe_code; | 360 if (!maybe_code->ToObject(&code)) return maybe_code; |
| 351 } | 361 } |
| 352 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), name)); | 362 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), name)); |
| 363 GDBJIT(AddCode(GDBJITInterface::KEYED_LOAD_IC, name, Code::cast(code))); |
| 353 Object* result; | 364 Object* result; |
| 354 { MaybeObject* maybe_result = | 365 { MaybeObject* maybe_result = |
| 355 receiver->UpdateMapCodeCache(name, Code::cast(code)); | 366 receiver->UpdateMapCodeCache(name, Code::cast(code)); |
| 356 if (!maybe_result->ToObject(&result)) return maybe_result; | 367 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 357 } | 368 } |
| 358 } | 369 } |
| 359 return code; | 370 return code; |
| 360 } | 371 } |
| 361 | 372 |
| 362 | 373 |
| 363 | 374 |
| 364 MaybeObject* StubCache::ComputeKeyedLoadArrayLength(String* name, | 375 MaybeObject* StubCache::ComputeKeyedLoadArrayLength(String* name, |
| 365 JSArray* receiver) { | 376 JSArray* receiver) { |
| 366 Code::Flags flags = | 377 Code::Flags flags = |
| 367 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, CALLBACKS); | 378 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, CALLBACKS); |
| 368 ASSERT(receiver->IsJSObject()); | 379 ASSERT(receiver->IsJSObject()); |
| 369 Object* code = receiver->map()->FindInCodeCache(name, flags); | 380 Object* code = receiver->map()->FindInCodeCache(name, flags); |
| 370 if (code->IsUndefined()) { | 381 if (code->IsUndefined()) { |
| 371 KeyedLoadStubCompiler compiler; | 382 KeyedLoadStubCompiler compiler; |
| 372 { MaybeObject* maybe_code = compiler.CompileLoadArrayLength(name); | 383 { MaybeObject* maybe_code = compiler.CompileLoadArrayLength(name); |
| 373 if (!maybe_code->ToObject(&code)) return maybe_code; | 384 if (!maybe_code->ToObject(&code)) return maybe_code; |
| 374 } | 385 } |
| 375 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), name)); | 386 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), name)); |
| 387 GDBJIT(AddCode(GDBJITInterface::KEYED_LOAD_IC, name, Code::cast(code))); |
| 376 Object* result; | 388 Object* result; |
| 377 { MaybeObject* maybe_result = | 389 { MaybeObject* maybe_result = |
| 378 receiver->UpdateMapCodeCache(name, Code::cast(code)); | 390 receiver->UpdateMapCodeCache(name, Code::cast(code)); |
| 379 if (!maybe_result->ToObject(&result)) return maybe_result; | 391 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 380 } | 392 } |
| 381 } | 393 } |
| 382 return code; | 394 return code; |
| 383 } | 395 } |
| 384 | 396 |
| 385 | 397 |
| 386 MaybeObject* StubCache::ComputeKeyedLoadStringLength(String* name, | 398 MaybeObject* StubCache::ComputeKeyedLoadStringLength(String* name, |
| 387 String* receiver) { | 399 String* receiver) { |
| 388 Code::Flags flags = | 400 Code::Flags flags = |
| 389 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, CALLBACKS); | 401 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, CALLBACKS); |
| 390 Map* map = receiver->map(); | 402 Map* map = receiver->map(); |
| 391 Object* code = map->FindInCodeCache(name, flags); | 403 Object* code = map->FindInCodeCache(name, flags); |
| 392 if (code->IsUndefined()) { | 404 if (code->IsUndefined()) { |
| 393 KeyedLoadStubCompiler compiler; | 405 KeyedLoadStubCompiler compiler; |
| 394 { MaybeObject* maybe_code = compiler.CompileLoadStringLength(name); | 406 { MaybeObject* maybe_code = compiler.CompileLoadStringLength(name); |
| 395 if (!maybe_code->ToObject(&code)) return maybe_code; | 407 if (!maybe_code->ToObject(&code)) return maybe_code; |
| 396 } | 408 } |
| 397 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), name)); | 409 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), name)); |
| 410 GDBJIT(AddCode(GDBJITInterface::KEYED_LOAD_IC, name, Code::cast(code))); |
| 398 Object* result; | 411 Object* result; |
| 399 { MaybeObject* maybe_result = map->UpdateCodeCache(name, Code::cast(code)); | 412 { MaybeObject* maybe_result = map->UpdateCodeCache(name, Code::cast(code)); |
| 400 if (!maybe_result->ToObject(&result)) return maybe_result; | 413 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 401 } | 414 } |
| 402 } | 415 } |
| 403 return code; | 416 return code; |
| 404 } | 417 } |
| 405 | 418 |
| 406 | 419 |
| 407 MaybeObject* StubCache::ComputeKeyedLoadFunctionPrototype( | 420 MaybeObject* StubCache::ComputeKeyedLoadFunctionPrototype( |
| 408 String* name, | 421 String* name, |
| 409 JSFunction* receiver) { | 422 JSFunction* receiver) { |
| 410 Code::Flags flags = | 423 Code::Flags flags = |
| 411 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, CALLBACKS); | 424 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, CALLBACKS); |
| 412 Object* code = receiver->map()->FindInCodeCache(name, flags); | 425 Object* code = receiver->map()->FindInCodeCache(name, flags); |
| 413 if (code->IsUndefined()) { | 426 if (code->IsUndefined()) { |
| 414 KeyedLoadStubCompiler compiler; | 427 KeyedLoadStubCompiler compiler; |
| 415 { MaybeObject* maybe_code = compiler.CompileLoadFunctionPrototype(name); | 428 { MaybeObject* maybe_code = compiler.CompileLoadFunctionPrototype(name); |
| 416 if (!maybe_code->ToObject(&code)) return maybe_code; | 429 if (!maybe_code->ToObject(&code)) return maybe_code; |
| 417 } | 430 } |
| 418 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), name)); | 431 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), name)); |
| 432 GDBJIT(AddCode(GDBJITInterface::KEYED_LOAD_IC, name, Code::cast(code))); |
| 419 Object* result; | 433 Object* result; |
| 420 { MaybeObject* maybe_result = | 434 { MaybeObject* maybe_result = |
| 421 receiver->UpdateMapCodeCache(name, Code::cast(code)); | 435 receiver->UpdateMapCodeCache(name, Code::cast(code)); |
| 422 if (!maybe_result->ToObject(&result)) return maybe_result; | 436 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 423 } | 437 } |
| 424 } | 438 } |
| 425 return code; | 439 return code; |
| 426 } | 440 } |
| 427 | 441 |
| 428 | 442 |
| 429 MaybeObject* StubCache::ComputeKeyedLoadSpecialized(JSObject* receiver) { | 443 MaybeObject* StubCache::ComputeKeyedLoadSpecialized(JSObject* receiver) { |
| 444 // Using NORMAL as the PropertyType for array element loads is a misuse. The |
| 445 // generated stub always accesses fast elements, not slow-mode fields, but |
| 446 // some property type is required for the stub lookup. Note that overloading |
| 447 // the NORMAL PropertyType is only safe as long as no stubs are generated for |
| 448 // other keyed field loads. This is guaranteed to be the case since all field |
| 449 // keyed loads that are not array elements go through a generic builtin stub. |
| 430 Code::Flags flags = | 450 Code::Flags flags = |
| 431 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, NORMAL); | 451 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, NORMAL); |
| 432 String* name = Heap::KeyedLoadSpecialized_symbol(); | 452 String* name = Heap::KeyedLoadSpecialized_symbol(); |
| 433 Object* code = receiver->map()->FindInCodeCache(name, flags); | 453 Object* code = receiver->map()->FindInCodeCache(name, flags); |
| 434 if (code->IsUndefined()) { | 454 if (code->IsUndefined()) { |
| 435 KeyedLoadStubCompiler compiler; | 455 KeyedLoadStubCompiler compiler; |
| 436 { MaybeObject* maybe_code = compiler.CompileLoadSpecialized(receiver); | 456 { MaybeObject* maybe_code = compiler.CompileLoadSpecialized(receiver); |
| 437 if (!maybe_code->ToObject(&code)) return maybe_code; | 457 if (!maybe_code->ToObject(&code)) return maybe_code; |
| 438 } | 458 } |
| 439 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), 0)); | 459 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), 0)); |
| 440 Object* result; | 460 Object* result; |
| 441 { MaybeObject* maybe_result = | 461 { MaybeObject* maybe_result = |
| 442 receiver->UpdateMapCodeCache(name, Code::cast(code)); | 462 receiver->UpdateMapCodeCache(name, Code::cast(code)); |
| 443 if (!maybe_result->ToObject(&result)) return maybe_result; | 463 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 444 } | 464 } |
| 445 } | 465 } |
| 446 return code; | 466 return code; |
| 447 } | 467 } |
| 448 | 468 |
| 449 | 469 |
| 470 MaybeObject* StubCache::ComputeKeyedLoadPixelArray(JSObject* receiver) { |
| 471 // Using NORMAL as the PropertyType for array element loads is a misuse. The |
| 472 // generated stub always accesses fast elements, not slow-mode fields, but |
| 473 // some property type is required for the stub lookup. Note that overloading |
| 474 // the NORMAL PropertyType is only safe as long as no stubs are generated for |
| 475 // other keyed field loads. This is guaranteed to be the case since all field |
| 476 // keyed loads that are not array elements go through a generic builtin stub. |
| 477 Code::Flags flags = |
| 478 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, NORMAL); |
| 479 String* name = Heap::KeyedLoadPixelArray_symbol(); |
| 480 Object* code = receiver->map()->FindInCodeCache(name, flags); |
| 481 if (code->IsUndefined()) { |
| 482 KeyedLoadStubCompiler compiler; |
| 483 { MaybeObject* maybe_code = compiler.CompileLoadPixelArray(receiver); |
| 484 if (!maybe_code->ToObject(&code)) return maybe_code; |
| 485 } |
| 486 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), 0)); |
| 487 Object* result; |
| 488 { MaybeObject* maybe_result = |
| 489 receiver->UpdateMapCodeCache(name, Code::cast(code)); |
| 490 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 491 } |
| 492 } |
| 493 return code; |
| 494 } |
| 495 |
| 496 |
| 450 MaybeObject* StubCache::ComputeStoreField(String* name, | 497 MaybeObject* StubCache::ComputeStoreField(String* name, |
| 451 JSObject* receiver, | 498 JSObject* receiver, |
| 452 int field_index, | 499 int field_index, |
| 453 Map* transition) { | 500 Map* transition, |
| 501 Code::ExtraICState extra_ic_state) { |
| 454 PropertyType type = (transition == NULL) ? FIELD : MAP_TRANSITION; | 502 PropertyType type = (transition == NULL) ? FIELD : MAP_TRANSITION; |
| 455 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::STORE_IC, type); | 503 Code::Flags flags = Code::ComputeMonomorphicFlags( |
| 504 Code::STORE_IC, type, extra_ic_state); |
| 456 Object* code = receiver->map()->FindInCodeCache(name, flags); | 505 Object* code = receiver->map()->FindInCodeCache(name, flags); |
| 457 if (code->IsUndefined()) { | 506 if (code->IsUndefined()) { |
| 458 StoreStubCompiler compiler; | 507 StoreStubCompiler compiler(extra_ic_state); |
| 459 { MaybeObject* maybe_code = | 508 { MaybeObject* maybe_code = |
| 460 compiler.CompileStoreField(receiver, field_index, transition, name); | 509 compiler.CompileStoreField(receiver, field_index, transition, name); |
| 461 if (!maybe_code->ToObject(&code)) return maybe_code; | 510 if (!maybe_code->ToObject(&code)) return maybe_code; |
| 462 } | 511 } |
| 463 PROFILE(CodeCreateEvent(Logger::STORE_IC_TAG, Code::cast(code), name)); | 512 PROFILE(CodeCreateEvent(Logger::STORE_IC_TAG, Code::cast(code), name)); |
| 513 GDBJIT(AddCode(GDBJITInterface::STORE_IC, name, Code::cast(code))); |
| 464 Object* result; | 514 Object* result; |
| 465 { MaybeObject* maybe_result = | 515 { MaybeObject* maybe_result = |
| 466 receiver->UpdateMapCodeCache(name, Code::cast(code)); | 516 receiver->UpdateMapCodeCache(name, Code::cast(code)); |
| 467 if (!maybe_result->ToObject(&result)) return maybe_result; | 517 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 468 } | 518 } |
| 469 } | 519 } |
| 470 return code; | 520 return code; |
| 471 } | 521 } |
| 472 | 522 |
| 473 | 523 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 485 Object* result; | 535 Object* result; |
| 486 { MaybeObject* maybe_result = | 536 { MaybeObject* maybe_result = |
| 487 receiver->UpdateMapCodeCache(name, Code::cast(code)); | 537 receiver->UpdateMapCodeCache(name, Code::cast(code)); |
| 488 if (!maybe_result->ToObject(&result)) return maybe_result; | 538 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 489 } | 539 } |
| 490 } | 540 } |
| 491 return code; | 541 return code; |
| 492 } | 542 } |
| 493 | 543 |
| 494 | 544 |
| 495 MaybeObject* StubCache::ComputeStoreNormal() { | 545 MaybeObject* StubCache::ComputeKeyedStorePixelArray(JSObject* receiver) { |
| 496 return Builtins::builtin(Builtins::StoreIC_Normal); | 546 // Using NORMAL as the PropertyType for array element stores is a misuse. The |
| 547 // generated stub always accesses fast elements, not slow-mode fields, but |
| 548 // some property type is required for the stub lookup. Note that overloading |
| 549 // the NORMAL PropertyType is only safe as long as no stubs are generated for |
| 550 // other keyed field stores. This is guaranteed to be the case since all field |
| 551 // keyed stores that are not array elements go through a generic builtin stub. |
| 552 Code::Flags flags = |
| 553 Code::ComputeMonomorphicFlags(Code::KEYED_STORE_IC, NORMAL); |
| 554 String* name = Heap::KeyedStorePixelArray_symbol(); |
| 555 Object* code = receiver->map()->FindInCodeCache(name, flags); |
| 556 if (code->IsUndefined()) { |
| 557 KeyedStoreStubCompiler compiler; |
| 558 { MaybeObject* maybe_code = compiler.CompileStorePixelArray(receiver); |
| 559 if (!maybe_code->ToObject(&code)) return maybe_code; |
| 560 } |
| 561 PROFILE(CodeCreateEvent(Logger::KEYED_STORE_IC_TAG, Code::cast(code), 0)); |
| 562 Object* result; |
| 563 { MaybeObject* maybe_result = |
| 564 receiver->UpdateMapCodeCache(name, Code::cast(code)); |
| 565 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 566 } |
| 567 } |
| 568 return code; |
| 569 } |
| 570 |
| 571 |
| 572 namespace { |
| 573 |
| 574 ExternalArrayType ElementsKindToExternalArrayType(JSObject::ElementsKind kind) { |
| 575 switch (kind) { |
| 576 case JSObject::EXTERNAL_BYTE_ELEMENTS: |
| 577 return kExternalByteArray; |
| 578 case JSObject::EXTERNAL_UNSIGNED_BYTE_ELEMENTS: |
| 579 return kExternalUnsignedByteArray; |
| 580 case JSObject::EXTERNAL_SHORT_ELEMENTS: |
| 581 return kExternalShortArray; |
| 582 case JSObject::EXTERNAL_UNSIGNED_SHORT_ELEMENTS: |
| 583 return kExternalUnsignedShortArray; |
| 584 case JSObject::EXTERNAL_INT_ELEMENTS: |
| 585 return kExternalIntArray; |
| 586 case JSObject::EXTERNAL_UNSIGNED_INT_ELEMENTS: |
| 587 return kExternalUnsignedIntArray; |
| 588 case JSObject::EXTERNAL_FLOAT_ELEMENTS: |
| 589 return kExternalFloatArray; |
| 590 default: |
| 591 UNREACHABLE(); |
| 592 return static_cast<ExternalArrayType>(0); |
| 593 } |
| 594 } |
| 595 |
| 596 } // anonymous namespace |
| 597 |
| 598 |
| 599 MaybeObject* StubCache::ComputeKeyedLoadOrStoreExternalArray( |
| 600 JSObject* receiver, |
| 601 bool is_store) { |
| 602 Code::Flags flags = |
| 603 Code::ComputeMonomorphicFlags( |
| 604 is_store ? Code::KEYED_STORE_IC : Code::KEYED_LOAD_IC, |
| 605 NORMAL); |
| 606 ExternalArrayType array_type = |
| 607 ElementsKindToExternalArrayType(receiver->GetElementsKind()); |
| 608 String* name = |
| 609 is_store ? Heap::KeyedStoreExternalArray_symbol() |
| 610 : Heap::KeyedLoadExternalArray_symbol(); |
| 611 // Use the global maps for the particular external array types, |
| 612 // rather than the receiver's map, when looking up the cached code, |
| 613 // so that we actually canonicalize these stubs. |
| 614 Map* map = Heap::MapForExternalArrayType(array_type); |
| 615 Object* code = map->FindInCodeCache(name, flags); |
| 616 if (code->IsUndefined()) { |
| 617 ExternalArrayStubCompiler compiler; |
| 618 { MaybeObject* maybe_code = |
| 619 is_store ? compiler.CompileKeyedStoreStub(array_type, flags) : |
| 620 compiler.CompileKeyedLoadStub(array_type, flags); |
| 621 if (!maybe_code->ToObject(&code)) return maybe_code; |
| 622 } |
| 623 if (is_store) { |
| 624 PROFILE( |
| 625 CodeCreateEvent(Logger::KEYED_STORE_IC_TAG, Code::cast(code), 0)); |
| 626 } else { |
| 627 PROFILE( |
| 628 CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), 0)); |
| 629 } |
| 630 Object* result; |
| 631 { MaybeObject* maybe_result = |
| 632 map->UpdateCodeCache(name, Code::cast(code)); |
| 633 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 634 } |
| 635 } |
| 636 return code; |
| 637 } |
| 638 |
| 639 |
| 640 MaybeObject* StubCache::ComputeStoreNormal(Code::ExtraICState extra_ic_state) { |
| 641 return Builtins::builtin(extra_ic_state == StoreIC::kStoreICStrict |
| 642 ? Builtins::StoreIC_Normal_Strict |
| 643 : Builtins::StoreIC_Normal); |
| 497 } | 644 } |
| 498 | 645 |
| 499 | 646 |
| 500 MaybeObject* StubCache::ComputeStoreGlobal(String* name, | 647 MaybeObject* StubCache::ComputeStoreGlobal(String* name, |
| 501 GlobalObject* receiver, | 648 GlobalObject* receiver, |
| 502 JSGlobalPropertyCell* cell) { | 649 JSGlobalPropertyCell* cell, |
| 503 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::STORE_IC, NORMAL); | 650 Code::ExtraICState extra_ic_state) { |
| 651 Code::Flags flags = Code::ComputeMonomorphicFlags( |
| 652 Code::STORE_IC, NORMAL, extra_ic_state); |
| 504 Object* code = receiver->map()->FindInCodeCache(name, flags); | 653 Object* code = receiver->map()->FindInCodeCache(name, flags); |
| 505 if (code->IsUndefined()) { | 654 if (code->IsUndefined()) { |
| 506 StoreStubCompiler compiler; | 655 StoreStubCompiler compiler(extra_ic_state); |
| 507 { MaybeObject* maybe_code = | 656 { MaybeObject* maybe_code = |
| 508 compiler.CompileStoreGlobal(receiver, cell, name); | 657 compiler.CompileStoreGlobal(receiver, cell, name); |
| 509 if (!maybe_code->ToObject(&code)) return maybe_code; | 658 if (!maybe_code->ToObject(&code)) return maybe_code; |
| 510 } | 659 } |
| 511 PROFILE(CodeCreateEvent(Logger::STORE_IC_TAG, Code::cast(code), name)); | 660 PROFILE(CodeCreateEvent(Logger::STORE_IC_TAG, Code::cast(code), name)); |
| 661 GDBJIT(AddCode(GDBJITInterface::STORE_IC, name, Code::cast(code))); |
| 512 Object* result; | 662 Object* result; |
| 513 { MaybeObject* maybe_result = | 663 { MaybeObject* maybe_result = |
| 514 receiver->UpdateMapCodeCache(name, Code::cast(code)); | 664 receiver->UpdateMapCodeCache(name, Code::cast(code)); |
| 515 if (!maybe_result->ToObject(&result)) return maybe_result; | 665 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 516 } | 666 } |
| 517 } | 667 } |
| 518 return code; | 668 return code; |
| 519 } | 669 } |
| 520 | 670 |
| 521 | 671 |
| 522 MaybeObject* StubCache::ComputeStoreCallback(String* name, | 672 MaybeObject* StubCache::ComputeStoreCallback( |
| 523 JSObject* receiver, | 673 String* name, |
| 524 AccessorInfo* callback) { | 674 JSObject* receiver, |
| 675 AccessorInfo* callback, |
| 676 Code::ExtraICState extra_ic_state) { |
| 525 ASSERT(v8::ToCData<Address>(callback->setter()) != 0); | 677 ASSERT(v8::ToCData<Address>(callback->setter()) != 0); |
| 526 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::STORE_IC, CALLBACKS); | 678 Code::Flags flags = Code::ComputeMonomorphicFlags( |
| 679 Code::STORE_IC, CALLBACKS, extra_ic_state); |
| 527 Object* code = receiver->map()->FindInCodeCache(name, flags); | 680 Object* code = receiver->map()->FindInCodeCache(name, flags); |
| 528 if (code->IsUndefined()) { | 681 if (code->IsUndefined()) { |
| 529 StoreStubCompiler compiler; | 682 StoreStubCompiler compiler(extra_ic_state); |
| 530 { MaybeObject* maybe_code = | 683 { MaybeObject* maybe_code = |
| 531 compiler.CompileStoreCallback(receiver, callback, name); | 684 compiler.CompileStoreCallback(receiver, callback, name); |
| 532 if (!maybe_code->ToObject(&code)) return maybe_code; | 685 if (!maybe_code->ToObject(&code)) return maybe_code; |
| 533 } | 686 } |
| 534 PROFILE(CodeCreateEvent(Logger::STORE_IC_TAG, Code::cast(code), name)); | 687 PROFILE(CodeCreateEvent(Logger::STORE_IC_TAG, Code::cast(code), name)); |
| 688 GDBJIT(AddCode(GDBJITInterface::STORE_IC, name, Code::cast(code))); |
| 535 Object* result; | 689 Object* result; |
| 536 { MaybeObject* maybe_result = | 690 { MaybeObject* maybe_result = |
| 537 receiver->UpdateMapCodeCache(name, Code::cast(code)); | 691 receiver->UpdateMapCodeCache(name, Code::cast(code)); |
| 538 if (!maybe_result->ToObject(&result)) return maybe_result; | 692 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 539 } | 693 } |
| 540 } | 694 } |
| 541 return code; | 695 return code; |
| 542 } | 696 } |
| 543 | 697 |
| 544 | 698 |
| 545 MaybeObject* StubCache::ComputeStoreInterceptor(String* name, | 699 MaybeObject* StubCache::ComputeStoreInterceptor( |
| 546 JSObject* receiver) { | 700 String* name, |
| 547 Code::Flags flags = | 701 JSObject* receiver, |
| 548 Code::ComputeMonomorphicFlags(Code::STORE_IC, INTERCEPTOR); | 702 Code::ExtraICState extra_ic_state) { |
| 703 Code::Flags flags = Code::ComputeMonomorphicFlags( |
| 704 Code::STORE_IC, INTERCEPTOR, extra_ic_state); |
| 549 Object* code = receiver->map()->FindInCodeCache(name, flags); | 705 Object* code = receiver->map()->FindInCodeCache(name, flags); |
| 550 if (code->IsUndefined()) { | 706 if (code->IsUndefined()) { |
| 551 StoreStubCompiler compiler; | 707 StoreStubCompiler compiler(extra_ic_state); |
| 552 { MaybeObject* maybe_code = | 708 { MaybeObject* maybe_code = |
| 553 compiler.CompileStoreInterceptor(receiver, name); | 709 compiler.CompileStoreInterceptor(receiver, name); |
| 554 if (!maybe_code->ToObject(&code)) return maybe_code; | 710 if (!maybe_code->ToObject(&code)) return maybe_code; |
| 555 } | 711 } |
| 556 PROFILE(CodeCreateEvent(Logger::STORE_IC_TAG, Code::cast(code), name)); | 712 PROFILE(CodeCreateEvent(Logger::STORE_IC_TAG, Code::cast(code), name)); |
| 713 GDBJIT(AddCode(GDBJITInterface::STORE_IC, name, Code::cast(code))); |
| 557 Object* result; | 714 Object* result; |
| 558 { MaybeObject* maybe_result = | 715 { MaybeObject* maybe_result = |
| 559 receiver->UpdateMapCodeCache(name, Code::cast(code)); | 716 receiver->UpdateMapCodeCache(name, Code::cast(code)); |
| 560 if (!maybe_result->ToObject(&result)) return maybe_result; | 717 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 561 } | 718 } |
| 562 } | 719 } |
| 563 return code; | 720 return code; |
| 564 } | 721 } |
| 565 | 722 |
| 566 | 723 |
| 567 MaybeObject* StubCache::ComputeKeyedStoreField(String* name, | 724 MaybeObject* StubCache::ComputeKeyedStoreField(String* name, |
| 568 JSObject* receiver, | 725 JSObject* receiver, |
| 569 int field_index, | 726 int field_index, |
| 570 Map* transition) { | 727 Map* transition) { |
| 571 PropertyType type = (transition == NULL) ? FIELD : MAP_TRANSITION; | 728 PropertyType type = (transition == NULL) ? FIELD : MAP_TRANSITION; |
| 572 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::KEYED_STORE_IC, type); | 729 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::KEYED_STORE_IC, type); |
| 573 Object* code = receiver->map()->FindInCodeCache(name, flags); | 730 Object* code = receiver->map()->FindInCodeCache(name, flags); |
| 574 if (code->IsUndefined()) { | 731 if (code->IsUndefined()) { |
| 575 KeyedStoreStubCompiler compiler; | 732 KeyedStoreStubCompiler compiler; |
| 576 { MaybeObject* maybe_code = | 733 { MaybeObject* maybe_code = |
| 577 compiler.CompileStoreField(receiver, field_index, transition, name); | 734 compiler.CompileStoreField(receiver, field_index, transition, name); |
| 578 if (!maybe_code->ToObject(&code)) return maybe_code; | 735 if (!maybe_code->ToObject(&code)) return maybe_code; |
| 579 } | 736 } |
| 580 PROFILE(CodeCreateEvent( | 737 PROFILE(CodeCreateEvent( |
| 581 Logger::KEYED_STORE_IC_TAG, Code::cast(code), name)); | 738 Logger::KEYED_STORE_IC_TAG, Code::cast(code), name)); |
| 739 GDBJIT(AddCode(GDBJITInterface::KEYED_STORE_IC, name, Code::cast(code))); |
| 582 Object* result; | 740 Object* result; |
| 583 { MaybeObject* maybe_result = | 741 { MaybeObject* maybe_result = |
| 584 receiver->UpdateMapCodeCache(name, Code::cast(code)); | 742 receiver->UpdateMapCodeCache(name, Code::cast(code)); |
| 585 if (!maybe_result->ToObject(&result)) return maybe_result; | 743 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 586 } | 744 } |
| 587 } | 745 } |
| 588 return code; | 746 return code; |
| 589 } | 747 } |
| 590 | 748 |
| 591 #define CALL_LOGGER_TAG(kind, type) \ | 749 #define CALL_LOGGER_TAG(kind, type) \ |
| 592 (kind == Code::CALL_IC ? Logger::type : Logger::KEYED_##type) | 750 (kind == Code::CALL_IC ? Logger::type : Logger::KEYED_##type) |
| 593 | 751 |
| 594 MaybeObject* StubCache::ComputeCallConstant(int argc, | 752 MaybeObject* StubCache::ComputeCallConstant(int argc, |
| 595 InLoopFlag in_loop, | 753 InLoopFlag in_loop, |
| 596 Code::Kind kind, | 754 Code::Kind kind, |
| 755 Code::ExtraICState extra_ic_state, |
| 597 String* name, | 756 String* name, |
| 598 Object* object, | 757 Object* object, |
| 599 JSObject* holder, | 758 JSObject* holder, |
| 600 JSFunction* function) { | 759 JSFunction* function) { |
| 601 // Compute the check type and the map. | 760 // Compute the check type and the map. |
| 602 InlineCacheHolderFlag cache_holder = | 761 InlineCacheHolderFlag cache_holder = |
| 603 IC::GetCodeCacheForObject(object, holder); | 762 IC::GetCodeCacheForObject(object, holder); |
| 604 JSObject* map_holder = IC::GetCodeCacheHolder(object, cache_holder); | 763 JSObject* map_holder = IC::GetCodeCacheHolder(object, cache_holder); |
| 605 | 764 |
| 606 // Compute check type based on receiver/holder. | 765 // Compute check type based on receiver/holder. |
| 607 CheckType check = RECEIVER_MAP_CHECK; | 766 CheckType check = RECEIVER_MAP_CHECK; |
| 608 if (object->IsString()) { | 767 if (object->IsString()) { |
| 609 check = STRING_CHECK; | 768 check = STRING_CHECK; |
| 610 } else if (object->IsNumber()) { | 769 } else if (object->IsNumber()) { |
| 611 check = NUMBER_CHECK; | 770 check = NUMBER_CHECK; |
| 612 } else if (object->IsBoolean()) { | 771 } else if (object->IsBoolean()) { |
| 613 check = BOOLEAN_CHECK; | 772 check = BOOLEAN_CHECK; |
| 614 } | 773 } |
| 615 | 774 |
| 616 Code::Flags flags = | 775 Code::Flags flags = Code::ComputeMonomorphicFlags(kind, |
| 617 Code::ComputeMonomorphicFlags(kind, | 776 CONSTANT_FUNCTION, |
| 618 CONSTANT_FUNCTION, | 777 extra_ic_state, |
| 619 cache_holder, | 778 cache_holder, |
| 620 in_loop, | 779 in_loop, |
| 621 argc); | 780 argc); |
| 622 Object* code = map_holder->map()->FindInCodeCache(name, flags); | 781 Object* code = map_holder->map()->FindInCodeCache(name, flags); |
| 623 if (code->IsUndefined()) { | 782 if (code->IsUndefined()) { |
| 624 // If the function hasn't been compiled yet, we cannot do it now | 783 // If the function hasn't been compiled yet, we cannot do it now |
| 625 // because it may cause GC. To avoid this issue, we return an | 784 // because it may cause GC. To avoid this issue, we return an |
| 626 // internal error which will make sure we do not update any | 785 // internal error which will make sure we do not update any |
| 627 // caches. | 786 // caches. |
| 628 if (!function->is_compiled()) return Failure::InternalError(); | 787 if (!function->is_compiled()) return Failure::InternalError(); |
| 629 // Compile the stub - only create stubs for fully compiled functions. | 788 // Compile the stub - only create stubs for fully compiled functions. |
| 630 CallStubCompiler compiler(argc, in_loop, kind, cache_holder); | 789 CallStubCompiler compiler( |
| 790 argc, in_loop, kind, extra_ic_state, cache_holder); |
| 631 { MaybeObject* maybe_code = | 791 { MaybeObject* maybe_code = |
| 632 compiler.CompileCallConstant(object, holder, function, name, check); | 792 compiler.CompileCallConstant(object, holder, function, name, check); |
| 633 if (!maybe_code->ToObject(&code)) return maybe_code; | 793 if (!maybe_code->ToObject(&code)) return maybe_code; |
| 634 } | 794 } |
| 635 Code::cast(code)->set_check_type(check); | 795 Code::cast(code)->set_check_type(check); |
| 636 ASSERT_EQ(flags, Code::cast(code)->flags()); | 796 ASSERT_EQ(flags, Code::cast(code)->flags()); |
| 637 PROFILE(CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_IC_TAG), | 797 PROFILE(CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_IC_TAG), |
| 638 Code::cast(code), name)); | 798 Code::cast(code), name)); |
| 799 GDBJIT(AddCode(GDBJITInterface::CALL_IC, name, Code::cast(code))); |
| 639 Object* result; | 800 Object* result; |
| 640 { MaybeObject* maybe_result = | 801 { MaybeObject* maybe_result = |
| 641 map_holder->UpdateMapCodeCache(name, Code::cast(code)); | 802 map_holder->UpdateMapCodeCache(name, Code::cast(code)); |
| 642 if (!maybe_result->ToObject(&result)) return maybe_result; | 803 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 643 } | 804 } |
| 644 } | 805 } |
| 645 return code; | 806 return code; |
| 646 } | 807 } |
| 647 | 808 |
| 648 | 809 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 660 | 821 |
| 661 // TODO(1233596): We cannot do receiver map check for non-JS objects | 822 // TODO(1233596): We cannot do receiver map check for non-JS objects |
| 662 // because they may be represented as immediates without a | 823 // because they may be represented as immediates without a |
| 663 // map. Instead, we check against the map in the holder. | 824 // map. Instead, we check against the map in the holder. |
| 664 if (object->IsNumber() || object->IsBoolean() || object->IsString()) { | 825 if (object->IsNumber() || object->IsBoolean() || object->IsString()) { |
| 665 object = holder; | 826 object = holder; |
| 666 } | 827 } |
| 667 | 828 |
| 668 Code::Flags flags = Code::ComputeMonomorphicFlags(kind, | 829 Code::Flags flags = Code::ComputeMonomorphicFlags(kind, |
| 669 FIELD, | 830 FIELD, |
| 831 Code::kNoExtraICState, |
| 670 cache_holder, | 832 cache_holder, |
| 671 in_loop, | 833 in_loop, |
| 672 argc); | 834 argc); |
| 673 Object* code = map_holder->map()->FindInCodeCache(name, flags); | 835 Object* code = map_holder->map()->FindInCodeCache(name, flags); |
| 674 if (code->IsUndefined()) { | 836 if (code->IsUndefined()) { |
| 675 CallStubCompiler compiler(argc, in_loop, kind, cache_holder); | 837 CallStubCompiler compiler( |
| 838 argc, in_loop, kind, Code::kNoExtraICState, cache_holder); |
| 676 { MaybeObject* maybe_code = | 839 { MaybeObject* maybe_code = |
| 677 compiler.CompileCallField(JSObject::cast(object), | 840 compiler.CompileCallField(JSObject::cast(object), |
| 678 holder, | 841 holder, |
| 679 index, | 842 index, |
| 680 name); | 843 name); |
| 681 if (!maybe_code->ToObject(&code)) return maybe_code; | 844 if (!maybe_code->ToObject(&code)) return maybe_code; |
| 682 } | 845 } |
| 683 ASSERT_EQ(flags, Code::cast(code)->flags()); | 846 ASSERT_EQ(flags, Code::cast(code)->flags()); |
| 684 PROFILE(CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_IC_TAG), | 847 PROFILE(CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_IC_TAG), |
| 685 Code::cast(code), name)); | 848 Code::cast(code), name)); |
| 849 GDBJIT(AddCode(GDBJITInterface::CALL_IC, name, Code::cast(code))); |
| 686 Object* result; | 850 Object* result; |
| 687 { MaybeObject* maybe_result = | 851 { MaybeObject* maybe_result = |
| 688 map_holder->UpdateMapCodeCache(name, Code::cast(code)); | 852 map_holder->UpdateMapCodeCache(name, Code::cast(code)); |
| 689 if (!maybe_result->ToObject(&result)) return maybe_result; | 853 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 690 } | 854 } |
| 691 } | 855 } |
| 692 return code; | 856 return code; |
| 693 } | 857 } |
| 694 | 858 |
| 695 | 859 |
| 696 MaybeObject* StubCache::ComputeCallInterceptor(int argc, | 860 MaybeObject* StubCache::ComputeCallInterceptor(int argc, |
| 697 Code::Kind kind, | 861 Code::Kind kind, |
| 698 String* name, | 862 String* name, |
| 699 Object* object, | 863 Object* object, |
| 700 JSObject* holder) { | 864 JSObject* holder) { |
| 701 // Compute the check type and the map. | 865 // Compute the check type and the map. |
| 702 InlineCacheHolderFlag cache_holder = | 866 InlineCacheHolderFlag cache_holder = |
| 703 IC::GetCodeCacheForObject(object, holder); | 867 IC::GetCodeCacheForObject(object, holder); |
| 704 JSObject* map_holder = IC::GetCodeCacheHolder(object, cache_holder); | 868 JSObject* map_holder = IC::GetCodeCacheHolder(object, cache_holder); |
| 705 | 869 |
| 706 // TODO(1233596): We cannot do receiver map check for non-JS objects | 870 // TODO(1233596): We cannot do receiver map check for non-JS objects |
| 707 // because they may be represented as immediates without a | 871 // because they may be represented as immediates without a |
| 708 // map. Instead, we check against the map in the holder. | 872 // map. Instead, we check against the map in the holder. |
| 709 if (object->IsNumber() || object->IsBoolean() || object->IsString()) { | 873 if (object->IsNumber() || object->IsBoolean() || object->IsString()) { |
| 710 object = holder; | 874 object = holder; |
| 711 } | 875 } |
| 712 | 876 |
| 713 Code::Flags flags = | 877 Code::Flags flags = Code::ComputeMonomorphicFlags(kind, |
| 714 Code::ComputeMonomorphicFlags(kind, | 878 INTERCEPTOR, |
| 715 INTERCEPTOR, | 879 Code::kNoExtraICState, |
| 716 cache_holder, | 880 cache_holder, |
| 717 NOT_IN_LOOP, | 881 NOT_IN_LOOP, |
| 718 argc); | 882 argc); |
| 719 Object* code = map_holder->map()->FindInCodeCache(name, flags); | 883 Object* code = map_holder->map()->FindInCodeCache(name, flags); |
| 720 if (code->IsUndefined()) { | 884 if (code->IsUndefined()) { |
| 721 CallStubCompiler compiler(argc, NOT_IN_LOOP, kind, cache_holder); | 885 CallStubCompiler compiler( |
| 886 argc, NOT_IN_LOOP, kind, Code::kNoExtraICState, cache_holder); |
| 722 { MaybeObject* maybe_code = | 887 { MaybeObject* maybe_code = |
| 723 compiler.CompileCallInterceptor(JSObject::cast(object), holder, name); | 888 compiler.CompileCallInterceptor(JSObject::cast(object), holder, name); |
| 724 if (!maybe_code->ToObject(&code)) return maybe_code; | 889 if (!maybe_code->ToObject(&code)) return maybe_code; |
| 725 } | 890 } |
| 726 ASSERT_EQ(flags, Code::cast(code)->flags()); | 891 ASSERT_EQ(flags, Code::cast(code)->flags()); |
| 727 PROFILE(CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_IC_TAG), | 892 PROFILE(CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_IC_TAG), |
| 728 Code::cast(code), name)); | 893 Code::cast(code), name)); |
| 894 GDBJIT(AddCode(GDBJITInterface::CALL_IC, name, Code::cast(code))); |
| 729 Object* result; | 895 Object* result; |
| 730 { MaybeObject* maybe_result = | 896 { MaybeObject* maybe_result = |
| 731 map_holder->UpdateMapCodeCache(name, Code::cast(code)); | 897 map_holder->UpdateMapCodeCache(name, Code::cast(code)); |
| 732 if (!maybe_result->ToObject(&result)) return maybe_result; | 898 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 733 } | 899 } |
| 734 } | 900 } |
| 735 return code; | 901 return code; |
| 736 } | 902 } |
| 737 | 903 |
| 738 | 904 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 753 InLoopFlag in_loop, | 919 InLoopFlag in_loop, |
| 754 Code::Kind kind, | 920 Code::Kind kind, |
| 755 String* name, | 921 String* name, |
| 756 JSObject* receiver, | 922 JSObject* receiver, |
| 757 GlobalObject* holder, | 923 GlobalObject* holder, |
| 758 JSGlobalPropertyCell* cell, | 924 JSGlobalPropertyCell* cell, |
| 759 JSFunction* function) { | 925 JSFunction* function) { |
| 760 InlineCacheHolderFlag cache_holder = | 926 InlineCacheHolderFlag cache_holder = |
| 761 IC::GetCodeCacheForObject(receiver, holder); | 927 IC::GetCodeCacheForObject(receiver, holder); |
| 762 JSObject* map_holder = IC::GetCodeCacheHolder(receiver, cache_holder); | 928 JSObject* map_holder = IC::GetCodeCacheHolder(receiver, cache_holder); |
| 763 Code::Flags flags = | 929 Code::Flags flags = Code::ComputeMonomorphicFlags(kind, |
| 764 Code::ComputeMonomorphicFlags(kind, | 930 NORMAL, |
| 765 NORMAL, | 931 Code::kNoExtraICState, |
| 766 cache_holder, | 932 cache_holder, |
| 767 in_loop, | 933 in_loop, |
| 768 argc); | 934 argc); |
| 769 Object* code = map_holder->map()->FindInCodeCache(name, flags); | 935 Object* code = map_holder->map()->FindInCodeCache(name, flags); |
| 770 if (code->IsUndefined()) { | 936 if (code->IsUndefined()) { |
| 771 // If the function hasn't been compiled yet, we cannot do it now | 937 // If the function hasn't been compiled yet, we cannot do it now |
| 772 // because it may cause GC. To avoid this issue, we return an | 938 // because it may cause GC. To avoid this issue, we return an |
| 773 // internal error which will make sure we do not update any | 939 // internal error which will make sure we do not update any |
| 774 // caches. | 940 // caches. |
| 775 if (!function->is_compiled()) return Failure::InternalError(); | 941 if (!function->is_compiled()) return Failure::InternalError(); |
| 776 CallStubCompiler compiler(argc, in_loop, kind, cache_holder); | 942 CallStubCompiler compiler( |
| 943 argc, in_loop, kind, Code::kNoExtraICState, cache_holder); |
| 777 { MaybeObject* maybe_code = | 944 { MaybeObject* maybe_code = |
| 778 compiler.CompileCallGlobal(receiver, holder, cell, function, name); | 945 compiler.CompileCallGlobal(receiver, holder, cell, function, name); |
| 779 if (!maybe_code->ToObject(&code)) return maybe_code; | 946 if (!maybe_code->ToObject(&code)) return maybe_code; |
| 780 } | 947 } |
| 781 ASSERT_EQ(flags, Code::cast(code)->flags()); | 948 ASSERT_EQ(flags, Code::cast(code)->flags()); |
| 782 PROFILE(CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_IC_TAG), | 949 PROFILE(CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_IC_TAG), |
| 783 Code::cast(code), name)); | 950 Code::cast(code), name)); |
| 951 GDBJIT(AddCode(GDBJITInterface::CALL_IC, name, Code::cast(code))); |
| 784 Object* result; | 952 Object* result; |
| 785 { MaybeObject* maybe_result = | 953 { MaybeObject* maybe_result = |
| 786 map_holder->UpdateMapCodeCache(name, Code::cast(code)); | 954 map_holder->UpdateMapCodeCache(name, Code::cast(code)); |
| 787 if (!maybe_result->ToObject(&result)) return maybe_result; | 955 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 788 } | 956 } |
| 789 } | 957 } |
| 790 return code; | 958 return code; |
| 791 } | 959 } |
| 792 | 960 |
| 793 | 961 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 832 CHECK(GetProbeValue(Code::cast(code)->flags()) == code); | 1000 CHECK(GetProbeValue(Code::cast(code)->flags()) == code); |
| 833 } | 1001 } |
| 834 } | 1002 } |
| 835 return maybe_code; | 1003 return maybe_code; |
| 836 } | 1004 } |
| 837 | 1005 |
| 838 | 1006 |
| 839 Code* StubCache::FindCallInitialize(int argc, | 1007 Code* StubCache::FindCallInitialize(int argc, |
| 840 InLoopFlag in_loop, | 1008 InLoopFlag in_loop, |
| 841 Code::Kind kind) { | 1009 Code::Kind kind) { |
| 842 Code::Flags flags = | 1010 Code::Flags flags = Code::ComputeFlags(kind, |
| 843 Code::ComputeFlags(kind, in_loop, UNINITIALIZED, NORMAL, argc); | 1011 in_loop, |
| 1012 UNINITIALIZED, |
| 1013 Code::kNoExtraICState, |
| 1014 NORMAL, |
| 1015 argc); |
| 844 Object* result = ProbeCache(flags)->ToObjectUnchecked(); | 1016 Object* result = ProbeCache(flags)->ToObjectUnchecked(); |
| 845 ASSERT(!result->IsUndefined()); | 1017 ASSERT(!result->IsUndefined()); |
| 846 // This might be called during the marking phase of the collector | 1018 // This might be called during the marking phase of the collector |
| 847 // hence the unchecked cast. | 1019 // hence the unchecked cast. |
| 848 return reinterpret_cast<Code*>(result); | 1020 return reinterpret_cast<Code*>(result); |
| 849 } | 1021 } |
| 850 | 1022 |
| 851 | 1023 |
| 852 MaybeObject* StubCache::ComputeCallInitialize(int argc, | 1024 MaybeObject* StubCache::ComputeCallInitialize(int argc, |
| 853 InLoopFlag in_loop, | 1025 InLoopFlag in_loop, |
| 854 Code::Kind kind) { | 1026 Code::Kind kind) { |
| 855 Code::Flags flags = | 1027 Code::Flags flags = Code::ComputeFlags(kind, |
| 856 Code::ComputeFlags(kind, in_loop, UNINITIALIZED, NORMAL, argc); | 1028 in_loop, |
| 1029 UNINITIALIZED, |
| 1030 Code::kNoExtraICState, |
| 1031 NORMAL, |
| 1032 argc); |
| 857 Object* probe; | 1033 Object* probe; |
| 858 { MaybeObject* maybe_probe = ProbeCache(flags); | 1034 { MaybeObject* maybe_probe = ProbeCache(flags); |
| 859 if (!maybe_probe->ToObject(&probe)) return maybe_probe; | 1035 if (!maybe_probe->ToObject(&probe)) return maybe_probe; |
| 860 } | 1036 } |
| 861 if (!probe->IsUndefined()) return probe; | 1037 if (!probe->IsUndefined()) return probe; |
| 862 StubCompiler compiler; | 1038 StubCompiler compiler; |
| 863 return FillCache(compiler.CompileCallInitialize(flags)); | 1039 return FillCache(compiler.CompileCallInitialize(flags)); |
| 864 } | 1040 } |
| 865 | 1041 |
| 866 | 1042 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 888 ComputeKeyedCallInitialize(argc, NOT_IN_LOOP); | 1064 ComputeKeyedCallInitialize(argc, NOT_IN_LOOP); |
| 889 } | 1065 } |
| 890 CALL_HEAP_FUNCTION( | 1066 CALL_HEAP_FUNCTION( |
| 891 ComputeCallInitialize(argc, in_loop, Code::KEYED_CALL_IC), Code); | 1067 ComputeCallInitialize(argc, in_loop, Code::KEYED_CALL_IC), Code); |
| 892 } | 1068 } |
| 893 | 1069 |
| 894 | 1070 |
| 895 MaybeObject* StubCache::ComputeCallPreMonomorphic(int argc, | 1071 MaybeObject* StubCache::ComputeCallPreMonomorphic(int argc, |
| 896 InLoopFlag in_loop, | 1072 InLoopFlag in_loop, |
| 897 Code::Kind kind) { | 1073 Code::Kind kind) { |
| 898 Code::Flags flags = | 1074 Code::Flags flags = Code::ComputeFlags(kind, |
| 899 Code::ComputeFlags(kind, in_loop, PREMONOMORPHIC, NORMAL, argc); | 1075 in_loop, |
| 1076 PREMONOMORPHIC, |
| 1077 Code::kNoExtraICState, |
| 1078 NORMAL, |
| 1079 argc); |
| 900 Object* probe; | 1080 Object* probe; |
| 901 { MaybeObject* maybe_probe = ProbeCache(flags); | 1081 { MaybeObject* maybe_probe = ProbeCache(flags); |
| 902 if (!maybe_probe->ToObject(&probe)) return maybe_probe; | 1082 if (!maybe_probe->ToObject(&probe)) return maybe_probe; |
| 903 } | 1083 } |
| 904 if (!probe->IsUndefined()) return probe; | 1084 if (!probe->IsUndefined()) return probe; |
| 905 StubCompiler compiler; | 1085 StubCompiler compiler; |
| 906 return FillCache(compiler.CompileCallPreMonomorphic(flags)); | 1086 return FillCache(compiler.CompileCallPreMonomorphic(flags)); |
| 907 } | 1087 } |
| 908 | 1088 |
| 909 | 1089 |
| 910 MaybeObject* StubCache::ComputeCallNormal(int argc, | 1090 MaybeObject* StubCache::ComputeCallNormal(int argc, |
| 911 InLoopFlag in_loop, | 1091 InLoopFlag in_loop, |
| 912 Code::Kind kind) { | 1092 Code::Kind kind) { |
| 913 Code::Flags flags = | 1093 Code::Flags flags = Code::ComputeFlags(kind, |
| 914 Code::ComputeFlags(kind, in_loop, MONOMORPHIC, NORMAL, argc); | 1094 in_loop, |
| 1095 MONOMORPHIC, |
| 1096 Code::kNoExtraICState, |
| 1097 NORMAL, |
| 1098 argc); |
| 915 Object* probe; | 1099 Object* probe; |
| 916 { MaybeObject* maybe_probe = ProbeCache(flags); | 1100 { MaybeObject* maybe_probe = ProbeCache(flags); |
| 917 if (!maybe_probe->ToObject(&probe)) return maybe_probe; | 1101 if (!maybe_probe->ToObject(&probe)) return maybe_probe; |
| 918 } | 1102 } |
| 919 if (!probe->IsUndefined()) return probe; | 1103 if (!probe->IsUndefined()) return probe; |
| 920 StubCompiler compiler; | 1104 StubCompiler compiler; |
| 921 return FillCache(compiler.CompileCallNormal(flags)); | 1105 return FillCache(compiler.CompileCallNormal(flags)); |
| 922 } | 1106 } |
| 923 | 1107 |
| 924 | 1108 |
| 925 MaybeObject* StubCache::ComputeCallMegamorphic(int argc, | 1109 MaybeObject* StubCache::ComputeCallMegamorphic(int argc, |
| 926 InLoopFlag in_loop, | 1110 InLoopFlag in_loop, |
| 927 Code::Kind kind) { | 1111 Code::Kind kind) { |
| 928 Code::Flags flags = | 1112 Code::Flags flags = Code::ComputeFlags(kind, |
| 929 Code::ComputeFlags(kind, in_loop, MEGAMORPHIC, NORMAL, argc); | 1113 in_loop, |
| 1114 MEGAMORPHIC, |
| 1115 Code::kNoExtraICState, |
| 1116 NORMAL, |
| 1117 argc); |
| 930 Object* probe; | 1118 Object* probe; |
| 931 { MaybeObject* maybe_probe = ProbeCache(flags); | 1119 { MaybeObject* maybe_probe = ProbeCache(flags); |
| 932 if (!maybe_probe->ToObject(&probe)) return maybe_probe; | 1120 if (!maybe_probe->ToObject(&probe)) return maybe_probe; |
| 933 } | 1121 } |
| 934 if (!probe->IsUndefined()) return probe; | 1122 if (!probe->IsUndefined()) return probe; |
| 935 StubCompiler compiler; | 1123 StubCompiler compiler; |
| 936 return FillCache(compiler.CompileCallMegamorphic(flags)); | 1124 return FillCache(compiler.CompileCallMegamorphic(flags)); |
| 937 } | 1125 } |
| 938 | 1126 |
| 939 | 1127 |
| 940 MaybeObject* StubCache::ComputeCallMiss(int argc, Code::Kind kind) { | 1128 MaybeObject* StubCache::ComputeCallMiss(int argc, Code::Kind kind) { |
| 941 // MONOMORPHIC_PROTOTYPE_FAILURE state is used to make sure that miss stubs | 1129 // MONOMORPHIC_PROTOTYPE_FAILURE state is used to make sure that miss stubs |
| 942 // and monomorphic stubs are not mixed up together in the stub cache. | 1130 // and monomorphic stubs are not mixed up together in the stub cache. |
| 943 Code::Flags flags = Code::ComputeFlags( | 1131 Code::Flags flags = Code::ComputeFlags(kind, |
| 944 kind, NOT_IN_LOOP, MONOMORPHIC_PROTOTYPE_FAILURE, NORMAL, argc); | 1132 NOT_IN_LOOP, |
| 1133 MONOMORPHIC_PROTOTYPE_FAILURE, |
| 1134 Code::kNoExtraICState, |
| 1135 NORMAL, |
| 1136 argc, |
| 1137 OWN_MAP); |
| 945 Object* probe; | 1138 Object* probe; |
| 946 { MaybeObject* maybe_probe = ProbeCache(flags); | 1139 { MaybeObject* maybe_probe = ProbeCache(flags); |
| 947 if (!maybe_probe->ToObject(&probe)) return maybe_probe; | 1140 if (!maybe_probe->ToObject(&probe)) return maybe_probe; |
| 948 } | 1141 } |
| 949 if (!probe->IsUndefined()) return probe; | 1142 if (!probe->IsUndefined()) return probe; |
| 950 StubCompiler compiler; | 1143 StubCompiler compiler; |
| 951 return FillCache(compiler.CompileCallMiss(flags)); | 1144 return FillCache(compiler.CompileCallMiss(flags)); |
| 952 } | 1145 } |
| 953 | 1146 |
| 954 | 1147 |
| 955 #ifdef ENABLE_DEBUGGER_SUPPORT | 1148 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 956 MaybeObject* StubCache::ComputeCallDebugBreak(int argc, Code::Kind kind) { | 1149 MaybeObject* StubCache::ComputeCallDebugBreak(int argc, Code::Kind kind) { |
| 957 Code::Flags flags = | 1150 Code::Flags flags = Code::ComputeFlags(kind, |
| 958 Code::ComputeFlags(kind, NOT_IN_LOOP, DEBUG_BREAK, NORMAL, argc); | 1151 NOT_IN_LOOP, |
| 1152 DEBUG_BREAK, |
| 1153 Code::kNoExtraICState, |
| 1154 NORMAL, |
| 1155 argc); |
| 959 Object* probe; | 1156 Object* probe; |
| 960 { MaybeObject* maybe_probe = ProbeCache(flags); | 1157 { MaybeObject* maybe_probe = ProbeCache(flags); |
| 961 if (!maybe_probe->ToObject(&probe)) return maybe_probe; | 1158 if (!maybe_probe->ToObject(&probe)) return maybe_probe; |
| 962 } | 1159 } |
| 963 if (!probe->IsUndefined()) return probe; | 1160 if (!probe->IsUndefined()) return probe; |
| 964 StubCompiler compiler; | 1161 StubCompiler compiler; |
| 965 return FillCache(compiler.CompileCallDebugBreak(flags)); | 1162 return FillCache(compiler.CompileCallDebugBreak(flags)); |
| 966 } | 1163 } |
| 967 | 1164 |
| 968 | 1165 |
| 969 MaybeObject* StubCache::ComputeCallDebugPrepareStepIn(int argc, | 1166 MaybeObject* StubCache::ComputeCallDebugPrepareStepIn(int argc, |
| 970 Code::Kind kind) { | 1167 Code::Kind kind) { |
| 971 Code::Flags flags = | 1168 Code::Flags flags = Code::ComputeFlags(kind, |
| 972 Code::ComputeFlags(kind, | 1169 NOT_IN_LOOP, |
| 973 NOT_IN_LOOP, | 1170 DEBUG_PREPARE_STEP_IN, |
| 974 DEBUG_PREPARE_STEP_IN, | 1171 Code::kNoExtraICState, |
| 975 NORMAL, | 1172 NORMAL, |
| 976 argc); | 1173 argc); |
| 977 Object* probe; | 1174 Object* probe; |
| 978 { MaybeObject* maybe_probe = ProbeCache(flags); | 1175 { MaybeObject* maybe_probe = ProbeCache(flags); |
| 979 if (!maybe_probe->ToObject(&probe)) return maybe_probe; | 1176 if (!maybe_probe->ToObject(&probe)) return maybe_probe; |
| 980 } | 1177 } |
| 981 if (!probe->IsUndefined()) return probe; | 1178 if (!probe->IsUndefined()) return probe; |
| 982 StubCompiler compiler; | 1179 StubCompiler compiler; |
| 983 return FillCache(compiler.CompileCallDebugPrepareStepIn(flags)); | 1180 return FillCache(compiler.CompileCallDebugPrepareStepIn(flags)); |
| 984 } | 1181 } |
| 985 #endif | 1182 #endif |
| 986 | 1183 |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1250 Object* result; | 1447 Object* result; |
| 1251 { MaybeObject* maybe_result = | 1448 { MaybeObject* maybe_result = |
| 1252 GetCodeWithFlags(flags, "CompileCallInitialize"); | 1449 GetCodeWithFlags(flags, "CompileCallInitialize"); |
| 1253 if (!maybe_result->ToObject(&result)) return maybe_result; | 1450 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 1254 } | 1451 } |
| 1255 Counters::call_initialize_stubs.Increment(); | 1452 Counters::call_initialize_stubs.Increment(); |
| 1256 Code* code = Code::cast(result); | 1453 Code* code = Code::cast(result); |
| 1257 USE(code); | 1454 USE(code); |
| 1258 PROFILE(CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_INITIALIZE_TAG), | 1455 PROFILE(CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_INITIALIZE_TAG), |
| 1259 code, code->arguments_count())); | 1456 code, code->arguments_count())); |
| 1457 GDBJIT(AddCode(GDBJITInterface::CALL_INITIALIZE, Code::cast(code))); |
| 1260 return result; | 1458 return result; |
| 1261 } | 1459 } |
| 1262 | 1460 |
| 1263 | 1461 |
| 1264 MaybeObject* StubCompiler::CompileCallPreMonomorphic(Code::Flags flags) { | 1462 MaybeObject* StubCompiler::CompileCallPreMonomorphic(Code::Flags flags) { |
| 1265 HandleScope scope; | 1463 HandleScope scope; |
| 1266 int argc = Code::ExtractArgumentsCountFromFlags(flags); | 1464 int argc = Code::ExtractArgumentsCountFromFlags(flags); |
| 1267 // The code of the PreMonomorphic stub is the same as the code | 1465 // The code of the PreMonomorphic stub is the same as the code |
| 1268 // of the Initialized stub. They just differ on the code object flags. | 1466 // of the Initialized stub. They just differ on the code object flags. |
| 1269 Code::Kind kind = Code::ExtractKindFromFlags(flags); | 1467 Code::Kind kind = Code::ExtractKindFromFlags(flags); |
| 1270 if (kind == Code::CALL_IC) { | 1468 if (kind == Code::CALL_IC) { |
| 1271 CallIC::GenerateInitialize(masm(), argc); | 1469 CallIC::GenerateInitialize(masm(), argc); |
| 1272 } else { | 1470 } else { |
| 1273 KeyedCallIC::GenerateInitialize(masm(), argc); | 1471 KeyedCallIC::GenerateInitialize(masm(), argc); |
| 1274 } | 1472 } |
| 1275 Object* result; | 1473 Object* result; |
| 1276 { MaybeObject* maybe_result = | 1474 { MaybeObject* maybe_result = |
| 1277 GetCodeWithFlags(flags, "CompileCallPreMonomorphic"); | 1475 GetCodeWithFlags(flags, "CompileCallPreMonomorphic"); |
| 1278 if (!maybe_result->ToObject(&result)) return maybe_result; | 1476 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 1279 } | 1477 } |
| 1280 Counters::call_premonomorphic_stubs.Increment(); | 1478 Counters::call_premonomorphic_stubs.Increment(); |
| 1281 Code* code = Code::cast(result); | 1479 Code* code = Code::cast(result); |
| 1282 USE(code); | 1480 USE(code); |
| 1283 PROFILE(CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_PRE_MONOMORPHIC_TAG), | 1481 PROFILE(CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_PRE_MONOMORPHIC_TAG), |
| 1284 code, code->arguments_count())); | 1482 code, code->arguments_count())); |
| 1483 GDBJIT(AddCode(GDBJITInterface::CALL_PRE_MONOMORPHIC, Code::cast(code))); |
| 1285 return result; | 1484 return result; |
| 1286 } | 1485 } |
| 1287 | 1486 |
| 1288 | 1487 |
| 1289 MaybeObject* StubCompiler::CompileCallNormal(Code::Flags flags) { | 1488 MaybeObject* StubCompiler::CompileCallNormal(Code::Flags flags) { |
| 1290 HandleScope scope; | 1489 HandleScope scope; |
| 1291 int argc = Code::ExtractArgumentsCountFromFlags(flags); | 1490 int argc = Code::ExtractArgumentsCountFromFlags(flags); |
| 1292 Code::Kind kind = Code::ExtractKindFromFlags(flags); | 1491 Code::Kind kind = Code::ExtractKindFromFlags(flags); |
| 1293 if (kind == Code::CALL_IC) { | 1492 if (kind == Code::CALL_IC) { |
| 1294 CallIC::GenerateNormal(masm(), argc); | 1493 CallIC::GenerateNormal(masm(), argc); |
| 1295 } else { | 1494 } else { |
| 1296 KeyedCallIC::GenerateNormal(masm(), argc); | 1495 KeyedCallIC::GenerateNormal(masm(), argc); |
| 1297 } | 1496 } |
| 1298 Object* result; | 1497 Object* result; |
| 1299 { MaybeObject* maybe_result = GetCodeWithFlags(flags, "CompileCallNormal"); | 1498 { MaybeObject* maybe_result = GetCodeWithFlags(flags, "CompileCallNormal"); |
| 1300 if (!maybe_result->ToObject(&result)) return maybe_result; | 1499 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 1301 } | 1500 } |
| 1302 Counters::call_normal_stubs.Increment(); | 1501 Counters::call_normal_stubs.Increment(); |
| 1303 Code* code = Code::cast(result); | 1502 Code* code = Code::cast(result); |
| 1304 USE(code); | 1503 USE(code); |
| 1305 PROFILE(CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_NORMAL_TAG), | 1504 PROFILE(CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_NORMAL_TAG), |
| 1306 code, code->arguments_count())); | 1505 code, code->arguments_count())); |
| 1506 GDBJIT(AddCode(GDBJITInterface::CALL_NORMAL, Code::cast(code))); |
| 1307 return result; | 1507 return result; |
| 1308 } | 1508 } |
| 1309 | 1509 |
| 1310 | 1510 |
| 1311 MaybeObject* StubCompiler::CompileCallMegamorphic(Code::Flags flags) { | 1511 MaybeObject* StubCompiler::CompileCallMegamorphic(Code::Flags flags) { |
| 1312 HandleScope scope; | 1512 HandleScope scope; |
| 1313 int argc = Code::ExtractArgumentsCountFromFlags(flags); | 1513 int argc = Code::ExtractArgumentsCountFromFlags(flags); |
| 1314 Code::Kind kind = Code::ExtractKindFromFlags(flags); | 1514 Code::Kind kind = Code::ExtractKindFromFlags(flags); |
| 1315 if (kind == Code::CALL_IC) { | 1515 if (kind == Code::CALL_IC) { |
| 1316 CallIC::GenerateMegamorphic(masm(), argc); | 1516 CallIC::GenerateMegamorphic(masm(), argc); |
| 1317 } else { | 1517 } else { |
| 1318 KeyedCallIC::GenerateMegamorphic(masm(), argc); | 1518 KeyedCallIC::GenerateMegamorphic(masm(), argc); |
| 1319 } | 1519 } |
| 1320 | 1520 |
| 1321 Object* result; | 1521 Object* result; |
| 1322 { MaybeObject* maybe_result = | 1522 { MaybeObject* maybe_result = |
| 1323 GetCodeWithFlags(flags, "CompileCallMegamorphic"); | 1523 GetCodeWithFlags(flags, "CompileCallMegamorphic"); |
| 1324 if (!maybe_result->ToObject(&result)) return maybe_result; | 1524 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 1325 } | 1525 } |
| 1326 Counters::call_megamorphic_stubs.Increment(); | 1526 Counters::call_megamorphic_stubs.Increment(); |
| 1327 Code* code = Code::cast(result); | 1527 Code* code = Code::cast(result); |
| 1328 USE(code); | 1528 USE(code); |
| 1329 PROFILE(CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_MEGAMORPHIC_TAG), | 1529 PROFILE(CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_MEGAMORPHIC_TAG), |
| 1330 code, code->arguments_count())); | 1530 code, code->arguments_count())); |
| 1531 GDBJIT(AddCode(GDBJITInterface::CALL_MEGAMORPHIC, Code::cast(code))); |
| 1331 return result; | 1532 return result; |
| 1332 } | 1533 } |
| 1333 | 1534 |
| 1334 | 1535 |
| 1335 MaybeObject* StubCompiler::CompileCallMiss(Code::Flags flags) { | 1536 MaybeObject* StubCompiler::CompileCallMiss(Code::Flags flags) { |
| 1336 HandleScope scope; | 1537 HandleScope scope; |
| 1337 int argc = Code::ExtractArgumentsCountFromFlags(flags); | 1538 int argc = Code::ExtractArgumentsCountFromFlags(flags); |
| 1338 Code::Kind kind = Code::ExtractKindFromFlags(flags); | 1539 Code::Kind kind = Code::ExtractKindFromFlags(flags); |
| 1339 if (kind == Code::CALL_IC) { | 1540 if (kind == Code::CALL_IC) { |
| 1340 CallIC::GenerateMiss(masm(), argc); | 1541 CallIC::GenerateMiss(masm(), argc); |
| 1341 } else { | 1542 } else { |
| 1342 KeyedCallIC::GenerateMiss(masm(), argc); | 1543 KeyedCallIC::GenerateMiss(masm(), argc); |
| 1343 } | 1544 } |
| 1344 Object* result; | 1545 Object* result; |
| 1345 { MaybeObject* maybe_result = GetCodeWithFlags(flags, "CompileCallMiss"); | 1546 { MaybeObject* maybe_result = GetCodeWithFlags(flags, "CompileCallMiss"); |
| 1346 if (!maybe_result->ToObject(&result)) return maybe_result; | 1547 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 1347 } | 1548 } |
| 1348 Counters::call_megamorphic_stubs.Increment(); | 1549 Counters::call_megamorphic_stubs.Increment(); |
| 1349 Code* code = Code::cast(result); | 1550 Code* code = Code::cast(result); |
| 1350 USE(code); | 1551 USE(code); |
| 1351 PROFILE(CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_MISS_TAG), | 1552 PROFILE(CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_MISS_TAG), |
| 1352 code, code->arguments_count())); | 1553 code, code->arguments_count())); |
| 1554 GDBJIT(AddCode(GDBJITInterface::CALL_MISS, Code::cast(code))); |
| 1353 return result; | 1555 return result; |
| 1354 } | 1556 } |
| 1355 | 1557 |
| 1356 | 1558 |
| 1357 #ifdef ENABLE_DEBUGGER_SUPPORT | 1559 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 1358 MaybeObject* StubCompiler::CompileCallDebugBreak(Code::Flags flags) { | 1560 MaybeObject* StubCompiler::CompileCallDebugBreak(Code::Flags flags) { |
| 1359 HandleScope scope; | 1561 HandleScope scope; |
| 1360 Debug::GenerateCallICDebugBreak(masm()); | 1562 Debug::GenerateCallICDebugBreak(masm()); |
| 1361 Object* result; | 1563 Object* result; |
| 1362 { MaybeObject* maybe_result = | 1564 { MaybeObject* maybe_result = |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1442 | 1644 |
| 1443 | 1645 |
| 1444 | 1646 |
| 1445 MaybeObject* LoadStubCompiler::GetCode(PropertyType type, String* name) { | 1647 MaybeObject* LoadStubCompiler::GetCode(PropertyType type, String* name) { |
| 1446 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::LOAD_IC, type); | 1648 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::LOAD_IC, type); |
| 1447 MaybeObject* result = GetCodeWithFlags(flags, name); | 1649 MaybeObject* result = GetCodeWithFlags(flags, name); |
| 1448 if (!result->IsFailure()) { | 1650 if (!result->IsFailure()) { |
| 1449 PROFILE(CodeCreateEvent(Logger::LOAD_IC_TAG, | 1651 PROFILE(CodeCreateEvent(Logger::LOAD_IC_TAG, |
| 1450 Code::cast(result->ToObjectUnchecked()), | 1652 Code::cast(result->ToObjectUnchecked()), |
| 1451 name)); | 1653 name)); |
| 1654 GDBJIT(AddCode(GDBJITInterface::LOAD_IC, |
| 1655 name, |
| 1656 Code::cast(result->ToObjectUnchecked()))); |
| 1452 } | 1657 } |
| 1453 return result; | 1658 return result; |
| 1454 } | 1659 } |
| 1455 | 1660 |
| 1456 | 1661 |
| 1457 MaybeObject* KeyedLoadStubCompiler::GetCode(PropertyType type, String* name) { | 1662 MaybeObject* KeyedLoadStubCompiler::GetCode(PropertyType type, String* name) { |
| 1458 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, type); | 1663 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, type); |
| 1459 MaybeObject* result = GetCodeWithFlags(flags, name); | 1664 MaybeObject* result = GetCodeWithFlags(flags, name); |
| 1460 if (!result->IsFailure()) { | 1665 if (!result->IsFailure()) { |
| 1461 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, | 1666 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, |
| 1462 Code::cast(result->ToObjectUnchecked()), | 1667 Code::cast(result->ToObjectUnchecked()), |
| 1463 name)); | 1668 name)); |
| 1669 GDBJIT(AddCode(GDBJITInterface::LOAD_IC, |
| 1670 name, |
| 1671 Code::cast(result->ToObjectUnchecked()))); |
| 1464 } | 1672 } |
| 1465 return result; | 1673 return result; |
| 1466 } | 1674 } |
| 1467 | 1675 |
| 1468 | 1676 |
| 1469 MaybeObject* StoreStubCompiler::GetCode(PropertyType type, String* name) { | 1677 MaybeObject* StoreStubCompiler::GetCode(PropertyType type, String* name) { |
| 1470 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::STORE_IC, type); | 1678 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::STORE_IC, type, |
| 1679 extra_ic_state_); |
| 1471 MaybeObject* result = GetCodeWithFlags(flags, name); | 1680 MaybeObject* result = GetCodeWithFlags(flags, name); |
| 1472 if (!result->IsFailure()) { | 1681 if (!result->IsFailure()) { |
| 1473 PROFILE(CodeCreateEvent(Logger::STORE_IC_TAG, | 1682 PROFILE(CodeCreateEvent(Logger::STORE_IC_TAG, |
| 1474 Code::cast(result->ToObjectUnchecked()), | 1683 Code::cast(result->ToObjectUnchecked()), |
| 1475 name)); | 1684 name)); |
| 1685 GDBJIT(AddCode(GDBJITInterface::STORE_IC, |
| 1686 name, |
| 1687 Code::cast(result->ToObjectUnchecked()))); |
| 1476 } | 1688 } |
| 1477 return result; | 1689 return result; |
| 1478 } | 1690 } |
| 1479 | 1691 |
| 1480 | 1692 |
| 1481 MaybeObject* KeyedStoreStubCompiler::GetCode(PropertyType type, String* name) { | 1693 MaybeObject* KeyedStoreStubCompiler::GetCode(PropertyType type, String* name) { |
| 1482 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::KEYED_STORE_IC, type); | 1694 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::KEYED_STORE_IC, type); |
| 1483 MaybeObject* result = GetCodeWithFlags(flags, name); | 1695 MaybeObject* result = GetCodeWithFlags(flags, name); |
| 1484 if (!result->IsFailure()) { | 1696 if (!result->IsFailure()) { |
| 1485 PROFILE(CodeCreateEvent(Logger::KEYED_STORE_IC_TAG, | 1697 PROFILE(CodeCreateEvent(Logger::KEYED_STORE_IC_TAG, |
| 1486 Code::cast(result->ToObjectUnchecked()), | 1698 Code::cast(result->ToObjectUnchecked()), |
| 1487 name)); | 1699 name)); |
| 1700 GDBJIT(AddCode(GDBJITInterface::KEYED_STORE_IC, |
| 1701 name, |
| 1702 Code::cast(result->ToObjectUnchecked()))); |
| 1488 } | 1703 } |
| 1489 return result; | 1704 return result; |
| 1490 } | 1705 } |
| 1491 | 1706 |
| 1492 | 1707 |
| 1493 CallStubCompiler::CallStubCompiler(int argc, | 1708 CallStubCompiler::CallStubCompiler(int argc, |
| 1494 InLoopFlag in_loop, | 1709 InLoopFlag in_loop, |
| 1495 Code::Kind kind, | 1710 Code::Kind kind, |
| 1711 Code::ExtraICState extra_ic_state, |
| 1496 InlineCacheHolderFlag cache_holder) | 1712 InlineCacheHolderFlag cache_holder) |
| 1497 : arguments_(argc) | 1713 : arguments_(argc), |
| 1498 , in_loop_(in_loop) | 1714 in_loop_(in_loop), |
| 1499 , kind_(kind) | 1715 kind_(kind), |
| 1500 , cache_holder_(cache_holder) { | 1716 extra_ic_state_(extra_ic_state), |
| 1717 cache_holder_(cache_holder) { |
| 1501 } | 1718 } |
| 1502 | 1719 |
| 1503 | 1720 |
| 1504 bool CallStubCompiler::HasCustomCallGenerator(BuiltinFunctionId id) { | 1721 bool CallStubCompiler::HasCustomCallGenerator(BuiltinFunctionId id) { |
| 1505 #define CALL_GENERATOR_CASE(name) if (id == k##name) return true; | 1722 #define CALL_GENERATOR_CASE(name) if (id == k##name) return true; |
| 1506 CUSTOM_CALL_IC_GENERATORS(CALL_GENERATOR_CASE) | 1723 CUSTOM_CALL_IC_GENERATORS(CALL_GENERATOR_CASE) |
| 1507 #undef CALL_GENERATOR_CASE | 1724 #undef CALL_GENERATOR_CASE |
| 1508 return false; | 1725 return false; |
| 1509 } | 1726 } |
| 1510 | 1727 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1527 #undef CALL_GENERATOR_CASE | 1744 #undef CALL_GENERATOR_CASE |
| 1528 ASSERT(!HasCustomCallGenerator(id)); | 1745 ASSERT(!HasCustomCallGenerator(id)); |
| 1529 return Heap::undefined_value(); | 1746 return Heap::undefined_value(); |
| 1530 } | 1747 } |
| 1531 | 1748 |
| 1532 | 1749 |
| 1533 MaybeObject* CallStubCompiler::GetCode(PropertyType type, String* name) { | 1750 MaybeObject* CallStubCompiler::GetCode(PropertyType type, String* name) { |
| 1534 int argc = arguments_.immediate(); | 1751 int argc = arguments_.immediate(); |
| 1535 Code::Flags flags = Code::ComputeMonomorphicFlags(kind_, | 1752 Code::Flags flags = Code::ComputeMonomorphicFlags(kind_, |
| 1536 type, | 1753 type, |
| 1754 extra_ic_state_, |
| 1537 cache_holder_, | 1755 cache_holder_, |
| 1538 in_loop_, | 1756 in_loop_, |
| 1539 argc); | 1757 argc); |
| 1540 return GetCodeWithFlags(flags, name); | 1758 return GetCodeWithFlags(flags, name); |
| 1541 } | 1759 } |
| 1542 | 1760 |
| 1543 | 1761 |
| 1544 MaybeObject* CallStubCompiler::GetCode(JSFunction* function) { | 1762 MaybeObject* CallStubCompiler::GetCode(JSFunction* function) { |
| 1545 String* function_name = NULL; | 1763 String* function_name = NULL; |
| 1546 if (function->shared()->name()->IsString()) { | 1764 if (function->shared()->name()->IsString()) { |
| 1547 function_name = String::cast(function->shared()->name()); | 1765 function_name = String::cast(function->shared()->name()); |
| 1548 } | 1766 } |
| 1549 return GetCode(CONSTANT_FUNCTION, function_name); | 1767 return GetCode(CONSTANT_FUNCTION, function_name); |
| 1550 } | 1768 } |
| 1551 | 1769 |
| 1552 | 1770 |
| 1553 MaybeObject* ConstructStubCompiler::GetCode() { | 1771 MaybeObject* ConstructStubCompiler::GetCode() { |
| 1554 Code::Flags flags = Code::ComputeFlags(Code::STUB); | 1772 Code::Flags flags = Code::ComputeFlags(Code::STUB); |
| 1555 Object* result; | 1773 Object* result; |
| 1556 { MaybeObject* maybe_result = GetCodeWithFlags(flags, "ConstructStub"); | 1774 { MaybeObject* maybe_result = GetCodeWithFlags(flags, "ConstructStub"); |
| 1557 if (!maybe_result->ToObject(&result)) return maybe_result; | 1775 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 1558 } | 1776 } |
| 1559 Code* code = Code::cast(result); | 1777 Code* code = Code::cast(result); |
| 1560 USE(code); | 1778 USE(code); |
| 1561 PROFILE(CodeCreateEvent(Logger::STUB_TAG, code, "ConstructStub")); | 1779 PROFILE(CodeCreateEvent(Logger::STUB_TAG, code, "ConstructStub")); |
| 1780 GDBJIT(AddCode(GDBJITInterface::STUB, "ConstructStub", Code::cast(code))); |
| 1562 return result; | 1781 return result; |
| 1563 } | 1782 } |
| 1564 | 1783 |
| 1565 | 1784 |
| 1566 CallOptimization::CallOptimization(LookupResult* lookup) { | 1785 CallOptimization::CallOptimization(LookupResult* lookup) { |
| 1567 if (!lookup->IsProperty() || !lookup->IsCacheable() || | 1786 if (!lookup->IsProperty() || !lookup->IsCacheable() || |
| 1568 lookup->type() != CONSTANT_FUNCTION) { | 1787 lookup->type() != CONSTANT_FUNCTION) { |
| 1569 Initialize(NULL); | 1788 Initialize(NULL); |
| 1570 } else { | 1789 } else { |
| 1571 // We only optimize constant function calls. | 1790 // We only optimize constant function calls. |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1623 if (!signature->receiver()->IsUndefined()) { | 1842 if (!signature->receiver()->IsUndefined()) { |
| 1624 expected_receiver_type_ = | 1843 expected_receiver_type_ = |
| 1625 FunctionTemplateInfo::cast(signature->receiver()); | 1844 FunctionTemplateInfo::cast(signature->receiver()); |
| 1626 } | 1845 } |
| 1627 } | 1846 } |
| 1628 | 1847 |
| 1629 is_simple_api_call_ = true; | 1848 is_simple_api_call_ = true; |
| 1630 } | 1849 } |
| 1631 | 1850 |
| 1632 | 1851 |
| 1852 MaybeObject* ExternalArrayStubCompiler::GetCode(Code::Flags flags) { |
| 1853 Object* result; |
| 1854 { MaybeObject* maybe_result = GetCodeWithFlags(flags, "ExternalArrayStub"); |
| 1855 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 1856 } |
| 1857 Code* code = Code::cast(result); |
| 1858 USE(code); |
| 1859 PROFILE(CodeCreateEvent(Logger::STUB_TAG, code, "ExternalArrayStub")); |
| 1860 return result; |
| 1861 } |
| 1862 |
| 1863 |
| 1633 } } // namespace v8::internal | 1864 } } // namespace v8::internal |
| OLD | NEW |