| 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 Code::Flags flags = | 120 Code::Flags flags = |
| 120 Code::ComputeMonomorphicFlags(Code::LOAD_IC, NONEXISTENT); | 121 Code::ComputeMonomorphicFlags(Code::LOAD_IC, NONEXISTENT); |
| 121 Object* code = receiver->map()->FindInCodeCache(cache_name, flags); | 122 Object* code = receiver->map()->FindInCodeCache(cache_name, flags); |
| 122 if (code->IsUndefined()) { | 123 if (code->IsUndefined()) { |
| 123 LoadStubCompiler compiler; | 124 LoadStubCompiler compiler; |
| 124 { MaybeObject* maybe_code = | 125 { MaybeObject* maybe_code = |
| 125 compiler.CompileLoadNonexistent(cache_name, receiver, last); | 126 compiler.CompileLoadNonexistent(cache_name, receiver, last); |
| 126 if (!maybe_code->ToObject(&code)) return maybe_code; | 127 if (!maybe_code->ToObject(&code)) return maybe_code; |
| 127 } | 128 } |
| 128 PROFILE(CodeCreateEvent(Logger::LOAD_IC_TAG, Code::cast(code), cache_name)); | 129 PROFILE(CodeCreateEvent(Logger::LOAD_IC_TAG, Code::cast(code), cache_name)); |
| 130 GDBJIT(AddCode(GDBJITInterface::LOAD_IC, cache_name, Code::cast(code))); |
| 129 Object* result; | 131 Object* result; |
| 130 { MaybeObject* maybe_result = | 132 { MaybeObject* maybe_result = |
| 131 receiver->UpdateMapCodeCache(cache_name, Code::cast(code)); | 133 receiver->UpdateMapCodeCache(cache_name, Code::cast(code)); |
| 132 if (!maybe_result->ToObject(&result)) return maybe_result; | 134 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 133 } | 135 } |
| 134 } | 136 } |
| 135 return code; | 137 return code; |
| 136 } | 138 } |
| 137 | 139 |
| 138 | 140 |
| 139 MaybeObject* StubCache::ComputeLoadField(String* name, | 141 MaybeObject* StubCache::ComputeLoadField(String* name, |
| 140 JSObject* receiver, | 142 JSObject* receiver, |
| 141 JSObject* holder, | 143 JSObject* holder, |
| 142 int field_index) { | 144 int field_index) { |
| 143 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP); | 145 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP); |
| 144 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::LOAD_IC, FIELD); | 146 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::LOAD_IC, FIELD); |
| 145 Object* code = receiver->map()->FindInCodeCache(name, flags); | 147 Object* code = receiver->map()->FindInCodeCache(name, flags); |
| 146 if (code->IsUndefined()) { | 148 if (code->IsUndefined()) { |
| 147 LoadStubCompiler compiler; | 149 LoadStubCompiler compiler; |
| 148 { MaybeObject* maybe_code = | 150 { MaybeObject* maybe_code = |
| 149 compiler.CompileLoadField(receiver, holder, field_index, name); | 151 compiler.CompileLoadField(receiver, holder, field_index, name); |
| 150 if (!maybe_code->ToObject(&code)) return maybe_code; | 152 if (!maybe_code->ToObject(&code)) return maybe_code; |
| 151 } | 153 } |
| 152 PROFILE(CodeCreateEvent(Logger::LOAD_IC_TAG, Code::cast(code), name)); | 154 PROFILE(CodeCreateEvent(Logger::LOAD_IC_TAG, Code::cast(code), name)); |
| 155 GDBJIT(AddCode(GDBJITInterface::LOAD_IC, name, Code::cast(code))); |
| 153 Object* result; | 156 Object* result; |
| 154 { MaybeObject* maybe_result = | 157 { MaybeObject* maybe_result = |
| 155 receiver->UpdateMapCodeCache(name, Code::cast(code)); | 158 receiver->UpdateMapCodeCache(name, Code::cast(code)); |
| 156 if (!maybe_result->ToObject(&result)) return maybe_result; | 159 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 157 } | 160 } |
| 158 } | 161 } |
| 159 return code; | 162 return code; |
| 160 } | 163 } |
| 161 | 164 |
| 162 | 165 |
| 163 MaybeObject* StubCache::ComputeLoadCallback(String* name, | 166 MaybeObject* StubCache::ComputeLoadCallback(String* name, |
| 164 JSObject* receiver, | 167 JSObject* receiver, |
| 165 JSObject* holder, | 168 JSObject* holder, |
| 166 AccessorInfo* callback) { | 169 AccessorInfo* callback) { |
| 167 ASSERT(v8::ToCData<Address>(callback->getter()) != 0); | 170 ASSERT(v8::ToCData<Address>(callback->getter()) != 0); |
| 168 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP); | 171 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP); |
| 169 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::LOAD_IC, CALLBACKS); | 172 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::LOAD_IC, CALLBACKS); |
| 170 Object* code = receiver->map()->FindInCodeCache(name, flags); | 173 Object* code = receiver->map()->FindInCodeCache(name, flags); |
| 171 if (code->IsUndefined()) { | 174 if (code->IsUndefined()) { |
| 172 LoadStubCompiler compiler; | 175 LoadStubCompiler compiler; |
| 173 { MaybeObject* maybe_code = | 176 { MaybeObject* maybe_code = |
| 174 compiler.CompileLoadCallback(name, receiver, holder, callback); | 177 compiler.CompileLoadCallback(name, receiver, holder, callback); |
| 175 if (!maybe_code->ToObject(&code)) return maybe_code; | 178 if (!maybe_code->ToObject(&code)) return maybe_code; |
| 176 } | 179 } |
| 177 PROFILE(CodeCreateEvent(Logger::LOAD_IC_TAG, Code::cast(code), name)); | 180 PROFILE(CodeCreateEvent(Logger::LOAD_IC_TAG, Code::cast(code), name)); |
| 181 GDBJIT(AddCode(GDBJITInterface::LOAD_IC, name, Code::cast(code))); |
| 178 Object* result; | 182 Object* result; |
| 179 { MaybeObject* maybe_result = | 183 { MaybeObject* maybe_result = |
| 180 receiver->UpdateMapCodeCache(name, Code::cast(code)); | 184 receiver->UpdateMapCodeCache(name, Code::cast(code)); |
| 181 if (!maybe_result->ToObject(&result)) return maybe_result; | 185 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 182 } | 186 } |
| 183 } | 187 } |
| 184 return code; | 188 return code; |
| 185 } | 189 } |
| 186 | 190 |
| 187 | 191 |
| 188 MaybeObject* StubCache::ComputeLoadConstant(String* name, | 192 MaybeObject* StubCache::ComputeLoadConstant(String* name, |
| 189 JSObject* receiver, | 193 JSObject* receiver, |
| 190 JSObject* holder, | 194 JSObject* holder, |
| 191 Object* value) { | 195 Object* value) { |
| 192 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP); | 196 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP); |
| 193 Code::Flags flags = | 197 Code::Flags flags = |
| 194 Code::ComputeMonomorphicFlags(Code::LOAD_IC, CONSTANT_FUNCTION); | 198 Code::ComputeMonomorphicFlags(Code::LOAD_IC, CONSTANT_FUNCTION); |
| 195 Object* code = receiver->map()->FindInCodeCache(name, flags); | 199 Object* code = receiver->map()->FindInCodeCache(name, flags); |
| 196 if (code->IsUndefined()) { | 200 if (code->IsUndefined()) { |
| 197 LoadStubCompiler compiler; | 201 LoadStubCompiler compiler; |
| 198 { MaybeObject* maybe_code = | 202 { MaybeObject* maybe_code = |
| 199 compiler.CompileLoadConstant(receiver, holder, value, name); | 203 compiler.CompileLoadConstant(receiver, holder, value, name); |
| 200 if (!maybe_code->ToObject(&code)) return maybe_code; | 204 if (!maybe_code->ToObject(&code)) return maybe_code; |
| 201 } | 205 } |
| 202 PROFILE(CodeCreateEvent(Logger::LOAD_IC_TAG, Code::cast(code), name)); | 206 PROFILE(CodeCreateEvent(Logger::LOAD_IC_TAG, Code::cast(code), name)); |
| 207 GDBJIT(AddCode(GDBJITInterface::LOAD_IC, name, Code::cast(code))); |
| 203 Object* result; | 208 Object* result; |
| 204 { MaybeObject* maybe_result = | 209 { MaybeObject* maybe_result = |
| 205 receiver->UpdateMapCodeCache(name, Code::cast(code)); | 210 receiver->UpdateMapCodeCache(name, Code::cast(code)); |
| 206 if (!maybe_result->ToObject(&result)) return maybe_result; | 211 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 207 } | 212 } |
| 208 } | 213 } |
| 209 return code; | 214 return code; |
| 210 } | 215 } |
| 211 | 216 |
| 212 | 217 |
| 213 MaybeObject* StubCache::ComputeLoadInterceptor(String* name, | 218 MaybeObject* StubCache::ComputeLoadInterceptor(String* name, |
| 214 JSObject* receiver, | 219 JSObject* receiver, |
| 215 JSObject* holder) { | 220 JSObject* holder) { |
| 216 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP); | 221 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP); |
| 217 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::LOAD_IC, INTERCEPTOR); | 222 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::LOAD_IC, INTERCEPTOR); |
| 218 Object* code = receiver->map()->FindInCodeCache(name, flags); | 223 Object* code = receiver->map()->FindInCodeCache(name, flags); |
| 219 if (code->IsUndefined()) { | 224 if (code->IsUndefined()) { |
| 220 LoadStubCompiler compiler; | 225 LoadStubCompiler compiler; |
| 221 { MaybeObject* maybe_code = | 226 { MaybeObject* maybe_code = |
| 222 compiler.CompileLoadInterceptor(receiver, holder, name); | 227 compiler.CompileLoadInterceptor(receiver, holder, name); |
| 223 if (!maybe_code->ToObject(&code)) return maybe_code; | 228 if (!maybe_code->ToObject(&code)) return maybe_code; |
| 224 } | 229 } |
| 225 PROFILE(CodeCreateEvent(Logger::LOAD_IC_TAG, Code::cast(code), name)); | 230 PROFILE(CodeCreateEvent(Logger::LOAD_IC_TAG, Code::cast(code), name)); |
| 231 GDBJIT(AddCode(GDBJITInterface::LOAD_IC, name, Code::cast(code))); |
| 226 Object* result; | 232 Object* result; |
| 227 { MaybeObject* maybe_result = | 233 { MaybeObject* maybe_result = |
| 228 receiver->UpdateMapCodeCache(name, Code::cast(code)); | 234 receiver->UpdateMapCodeCache(name, Code::cast(code)); |
| 229 if (!maybe_result->ToObject(&result)) return maybe_result; | 235 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 230 } | 236 } |
| 231 } | 237 } |
| 232 return code; | 238 return code; |
| 233 } | 239 } |
| 234 | 240 |
| 235 | 241 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 249 if (code->IsUndefined()) { | 255 if (code->IsUndefined()) { |
| 250 LoadStubCompiler compiler; | 256 LoadStubCompiler compiler; |
| 251 { MaybeObject* maybe_code = compiler.CompileLoadGlobal(receiver, | 257 { MaybeObject* maybe_code = compiler.CompileLoadGlobal(receiver, |
| 252 holder, | 258 holder, |
| 253 cell, | 259 cell, |
| 254 name, | 260 name, |
| 255 is_dont_delete); | 261 is_dont_delete); |
| 256 if (!maybe_code->ToObject(&code)) return maybe_code; | 262 if (!maybe_code->ToObject(&code)) return maybe_code; |
| 257 } | 263 } |
| 258 PROFILE(CodeCreateEvent(Logger::LOAD_IC_TAG, Code::cast(code), name)); | 264 PROFILE(CodeCreateEvent(Logger::LOAD_IC_TAG, Code::cast(code), name)); |
| 265 GDBJIT(AddCode(GDBJITInterface::LOAD_IC, name, Code::cast(code))); |
| 259 Object* result; | 266 Object* result; |
| 260 { MaybeObject* maybe_result = | 267 { MaybeObject* maybe_result = |
| 261 receiver->UpdateMapCodeCache(name, Code::cast(code)); | 268 receiver->UpdateMapCodeCache(name, Code::cast(code)); |
| 262 if (!maybe_result->ToObject(&result)) return maybe_result; | 269 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 263 } | 270 } |
| 264 } | 271 } |
| 265 return code; | 272 return code; |
| 266 } | 273 } |
| 267 | 274 |
| 268 | 275 |
| 269 MaybeObject* StubCache::ComputeKeyedLoadField(String* name, | 276 MaybeObject* StubCache::ComputeKeyedLoadField(String* name, |
| 270 JSObject* receiver, | 277 JSObject* receiver, |
| 271 JSObject* holder, | 278 JSObject* holder, |
| 272 int field_index) { | 279 int field_index) { |
| 273 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP); | 280 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP); |
| 274 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, FIELD); | 281 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, FIELD); |
| 275 Object* code = receiver->map()->FindInCodeCache(name, flags); | 282 Object* code = receiver->map()->FindInCodeCache(name, flags); |
| 276 if (code->IsUndefined()) { | 283 if (code->IsUndefined()) { |
| 277 KeyedLoadStubCompiler compiler; | 284 KeyedLoadStubCompiler compiler; |
| 278 { MaybeObject* maybe_code = | 285 { MaybeObject* maybe_code = |
| 279 compiler.CompileLoadField(name, receiver, holder, field_index); | 286 compiler.CompileLoadField(name, receiver, holder, field_index); |
| 280 if (!maybe_code->ToObject(&code)) return maybe_code; | 287 if (!maybe_code->ToObject(&code)) return maybe_code; |
| 281 } | 288 } |
| 282 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), name)); | 289 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), name)); |
| 290 GDBJIT(AddCode(GDBJITInterface::KEYED_LOAD_IC, name, Code::cast(code))); |
| 283 Object* result; | 291 Object* result; |
| 284 { MaybeObject* maybe_result = | 292 { MaybeObject* maybe_result = |
| 285 receiver->UpdateMapCodeCache(name, Code::cast(code)); | 293 receiver->UpdateMapCodeCache(name, Code::cast(code)); |
| 286 if (!maybe_result->ToObject(&result)) return maybe_result; | 294 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 287 } | 295 } |
| 288 } | 296 } |
| 289 return code; | 297 return code; |
| 290 } | 298 } |
| 291 | 299 |
| 292 | 300 |
| 293 MaybeObject* StubCache::ComputeKeyedLoadConstant(String* name, | 301 MaybeObject* StubCache::ComputeKeyedLoadConstant(String* name, |
| 294 JSObject* receiver, | 302 JSObject* receiver, |
| 295 JSObject* holder, | 303 JSObject* holder, |
| 296 Object* value) { | 304 Object* value) { |
| 297 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP); | 305 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP); |
| 298 Code::Flags flags = | 306 Code::Flags flags = |
| 299 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, CONSTANT_FUNCTION); | 307 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, CONSTANT_FUNCTION); |
| 300 Object* code = receiver->map()->FindInCodeCache(name, flags); | 308 Object* code = receiver->map()->FindInCodeCache(name, flags); |
| 301 if (code->IsUndefined()) { | 309 if (code->IsUndefined()) { |
| 302 KeyedLoadStubCompiler compiler; | 310 KeyedLoadStubCompiler compiler; |
| 303 { MaybeObject* maybe_code = | 311 { MaybeObject* maybe_code = |
| 304 compiler.CompileLoadConstant(name, receiver, holder, value); | 312 compiler.CompileLoadConstant(name, receiver, holder, value); |
| 305 if (!maybe_code->ToObject(&code)) return maybe_code; | 313 if (!maybe_code->ToObject(&code)) return maybe_code; |
| 306 } | 314 } |
| 307 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), name)); | 315 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), name)); |
| 316 GDBJIT(AddCode(GDBJITInterface::KEYED_LOAD_IC, name, Code::cast(code))); |
| 308 Object* result; | 317 Object* result; |
| 309 { MaybeObject* maybe_result = | 318 { MaybeObject* maybe_result = |
| 310 receiver->UpdateMapCodeCache(name, Code::cast(code)); | 319 receiver->UpdateMapCodeCache(name, Code::cast(code)); |
| 311 if (!maybe_result->ToObject(&result)) return maybe_result; | 320 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 312 } | 321 } |
| 313 } | 322 } |
| 314 return code; | 323 return code; |
| 315 } | 324 } |
| 316 | 325 |
| 317 | 326 |
| 318 MaybeObject* StubCache::ComputeKeyedLoadInterceptor(String* name, | 327 MaybeObject* StubCache::ComputeKeyedLoadInterceptor(String* name, |
| 319 JSObject* receiver, | 328 JSObject* receiver, |
| 320 JSObject* holder) { | 329 JSObject* holder) { |
| 321 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP); | 330 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP); |
| 322 Code::Flags flags = | 331 Code::Flags flags = |
| 323 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, INTERCEPTOR); | 332 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, INTERCEPTOR); |
| 324 Object* code = receiver->map()->FindInCodeCache(name, flags); | 333 Object* code = receiver->map()->FindInCodeCache(name, flags); |
| 325 if (code->IsUndefined()) { | 334 if (code->IsUndefined()) { |
| 326 KeyedLoadStubCompiler compiler; | 335 KeyedLoadStubCompiler compiler; |
| 327 { MaybeObject* maybe_code = | 336 { MaybeObject* maybe_code = |
| 328 compiler.CompileLoadInterceptor(receiver, holder, name); | 337 compiler.CompileLoadInterceptor(receiver, holder, name); |
| 329 if (!maybe_code->ToObject(&code)) return maybe_code; | 338 if (!maybe_code->ToObject(&code)) return maybe_code; |
| 330 } | 339 } |
| 331 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), name)); | 340 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), name)); |
| 341 GDBJIT(AddCode(GDBJITInterface::KEYED_LOAD_IC, name, Code::cast(code))); |
| 332 Object* result; | 342 Object* result; |
| 333 { MaybeObject* maybe_result = | 343 { MaybeObject* maybe_result = |
| 334 receiver->UpdateMapCodeCache(name, Code::cast(code)); | 344 receiver->UpdateMapCodeCache(name, Code::cast(code)); |
| 335 if (!maybe_result->ToObject(&result)) return maybe_result; | 345 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 336 } | 346 } |
| 337 } | 347 } |
| 338 return code; | 348 return code; |
| 339 } | 349 } |
| 340 | 350 |
| 341 | 351 |
| 342 MaybeObject* StubCache::ComputeKeyedLoadCallback(String* name, | 352 MaybeObject* StubCache::ComputeKeyedLoadCallback(String* name, |
| 343 JSObject* receiver, | 353 JSObject* receiver, |
| 344 JSObject* holder, | 354 JSObject* holder, |
| 345 AccessorInfo* callback) { | 355 AccessorInfo* callback) { |
| 346 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP); | 356 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP); |
| 347 Code::Flags flags = | 357 Code::Flags flags = |
| 348 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, CALLBACKS); | 358 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, CALLBACKS); |
| 349 Object* code = receiver->map()->FindInCodeCache(name, flags); | 359 Object* code = receiver->map()->FindInCodeCache(name, flags); |
| 350 if (code->IsUndefined()) { | 360 if (code->IsUndefined()) { |
| 351 KeyedLoadStubCompiler compiler; | 361 KeyedLoadStubCompiler compiler; |
| 352 { MaybeObject* maybe_code = | 362 { MaybeObject* maybe_code = |
| 353 compiler.CompileLoadCallback(name, receiver, holder, callback); | 363 compiler.CompileLoadCallback(name, receiver, holder, callback); |
| 354 if (!maybe_code->ToObject(&code)) return maybe_code; | 364 if (!maybe_code->ToObject(&code)) return maybe_code; |
| 355 } | 365 } |
| 356 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), name)); | 366 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), name)); |
| 367 GDBJIT(AddCode(GDBJITInterface::KEYED_LOAD_IC, name, Code::cast(code))); |
| 357 Object* result; | 368 Object* result; |
| 358 { MaybeObject* maybe_result = | 369 { MaybeObject* maybe_result = |
| 359 receiver->UpdateMapCodeCache(name, Code::cast(code)); | 370 receiver->UpdateMapCodeCache(name, Code::cast(code)); |
| 360 if (!maybe_result->ToObject(&result)) return maybe_result; | 371 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 361 } | 372 } |
| 362 } | 373 } |
| 363 return code; | 374 return code; |
| 364 } | 375 } |
| 365 | 376 |
| 366 | 377 |
| 367 | 378 |
| 368 MaybeObject* StubCache::ComputeKeyedLoadArrayLength(String* name, | 379 MaybeObject* StubCache::ComputeKeyedLoadArrayLength(String* name, |
| 369 JSArray* receiver) { | 380 JSArray* receiver) { |
| 370 Code::Flags flags = | 381 Code::Flags flags = |
| 371 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, CALLBACKS); | 382 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, CALLBACKS); |
| 372 ASSERT(receiver->IsJSObject()); | 383 ASSERT(receiver->IsJSObject()); |
| 373 Object* code = receiver->map()->FindInCodeCache(name, flags); | 384 Object* code = receiver->map()->FindInCodeCache(name, flags); |
| 374 if (code->IsUndefined()) { | 385 if (code->IsUndefined()) { |
| 375 KeyedLoadStubCompiler compiler; | 386 KeyedLoadStubCompiler compiler; |
| 376 { MaybeObject* maybe_code = compiler.CompileLoadArrayLength(name); | 387 { MaybeObject* maybe_code = compiler.CompileLoadArrayLength(name); |
| 377 if (!maybe_code->ToObject(&code)) return maybe_code; | 388 if (!maybe_code->ToObject(&code)) return maybe_code; |
| 378 } | 389 } |
| 379 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), name)); | 390 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), name)); |
| 391 GDBJIT(AddCode(GDBJITInterface::KEYED_LOAD_IC, name, Code::cast(code))); |
| 380 Object* result; | 392 Object* result; |
| 381 { MaybeObject* maybe_result = | 393 { MaybeObject* maybe_result = |
| 382 receiver->UpdateMapCodeCache(name, Code::cast(code)); | 394 receiver->UpdateMapCodeCache(name, Code::cast(code)); |
| 383 if (!maybe_result->ToObject(&result)) return maybe_result; | 395 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 384 } | 396 } |
| 385 } | 397 } |
| 386 return code; | 398 return code; |
| 387 } | 399 } |
| 388 | 400 |
| 389 | 401 |
| 390 MaybeObject* StubCache::ComputeKeyedLoadStringLength(String* name, | 402 MaybeObject* StubCache::ComputeKeyedLoadStringLength(String* name, |
| 391 String* receiver) { | 403 String* receiver) { |
| 392 Code::Flags flags = | 404 Code::Flags flags = |
| 393 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, CALLBACKS); | 405 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, CALLBACKS); |
| 394 Map* map = receiver->map(); | 406 Map* map = receiver->map(); |
| 395 Object* code = map->FindInCodeCache(name, flags); | 407 Object* code = map->FindInCodeCache(name, flags); |
| 396 if (code->IsUndefined()) { | 408 if (code->IsUndefined()) { |
| 397 KeyedLoadStubCompiler compiler; | 409 KeyedLoadStubCompiler compiler; |
| 398 { MaybeObject* maybe_code = compiler.CompileLoadStringLength(name); | 410 { MaybeObject* maybe_code = compiler.CompileLoadStringLength(name); |
| 399 if (!maybe_code->ToObject(&code)) return maybe_code; | 411 if (!maybe_code->ToObject(&code)) return maybe_code; |
| 400 } | 412 } |
| 401 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), name)); | 413 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), name)); |
| 414 GDBJIT(AddCode(GDBJITInterface::KEYED_LOAD_IC, name, Code::cast(code))); |
| 402 Object* result; | 415 Object* result; |
| 403 { MaybeObject* maybe_result = map->UpdateCodeCache(name, Code::cast(code)); | 416 { MaybeObject* maybe_result = map->UpdateCodeCache(name, Code::cast(code)); |
| 404 if (!maybe_result->ToObject(&result)) return maybe_result; | 417 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 405 } | 418 } |
| 406 } | 419 } |
| 407 return code; | 420 return code; |
| 408 } | 421 } |
| 409 | 422 |
| 410 | 423 |
| 411 MaybeObject* StubCache::ComputeKeyedLoadFunctionPrototype( | 424 MaybeObject* StubCache::ComputeKeyedLoadFunctionPrototype( |
| 412 String* name, | 425 String* name, |
| 413 JSFunction* receiver) { | 426 JSFunction* receiver) { |
| 414 Code::Flags flags = | 427 Code::Flags flags = |
| 415 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, CALLBACKS); | 428 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, CALLBACKS); |
| 416 Object* code = receiver->map()->FindInCodeCache(name, flags); | 429 Object* code = receiver->map()->FindInCodeCache(name, flags); |
| 417 if (code->IsUndefined()) { | 430 if (code->IsUndefined()) { |
| 418 KeyedLoadStubCompiler compiler; | 431 KeyedLoadStubCompiler compiler; |
| 419 { MaybeObject* maybe_code = compiler.CompileLoadFunctionPrototype(name); | 432 { MaybeObject* maybe_code = compiler.CompileLoadFunctionPrototype(name); |
| 420 if (!maybe_code->ToObject(&code)) return maybe_code; | 433 if (!maybe_code->ToObject(&code)) return maybe_code; |
| 421 } | 434 } |
| 422 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), name)); | 435 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), name)); |
| 436 GDBJIT(AddCode(GDBJITInterface::KEYED_LOAD_IC, name, Code::cast(code))); |
| 423 Object* result; | 437 Object* result; |
| 424 { MaybeObject* maybe_result = | 438 { MaybeObject* maybe_result = |
| 425 receiver->UpdateMapCodeCache(name, Code::cast(code)); | 439 receiver->UpdateMapCodeCache(name, Code::cast(code)); |
| 426 if (!maybe_result->ToObject(&result)) return maybe_result; | 440 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 427 } | 441 } |
| 428 } | 442 } |
| 429 return code; | 443 return code; |
| 430 } | 444 } |
| 431 | 445 |
| 432 | 446 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 458 PropertyType type = (transition == NULL) ? FIELD : MAP_TRANSITION; | 472 PropertyType type = (transition == NULL) ? FIELD : MAP_TRANSITION; |
| 459 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::STORE_IC, type); | 473 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::STORE_IC, type); |
| 460 Object* code = receiver->map()->FindInCodeCache(name, flags); | 474 Object* code = receiver->map()->FindInCodeCache(name, flags); |
| 461 if (code->IsUndefined()) { | 475 if (code->IsUndefined()) { |
| 462 StoreStubCompiler compiler; | 476 StoreStubCompiler compiler; |
| 463 { MaybeObject* maybe_code = | 477 { MaybeObject* maybe_code = |
| 464 compiler.CompileStoreField(receiver, field_index, transition, name); | 478 compiler.CompileStoreField(receiver, field_index, transition, name); |
| 465 if (!maybe_code->ToObject(&code)) return maybe_code; | 479 if (!maybe_code->ToObject(&code)) return maybe_code; |
| 466 } | 480 } |
| 467 PROFILE(CodeCreateEvent(Logger::STORE_IC_TAG, Code::cast(code), name)); | 481 PROFILE(CodeCreateEvent(Logger::STORE_IC_TAG, Code::cast(code), name)); |
| 482 GDBJIT(AddCode(GDBJITInterface::STORE_IC, name, Code::cast(code))); |
| 468 Object* result; | 483 Object* result; |
| 469 { MaybeObject* maybe_result = | 484 { MaybeObject* maybe_result = |
| 470 receiver->UpdateMapCodeCache(name, Code::cast(code)); | 485 receiver->UpdateMapCodeCache(name, Code::cast(code)); |
| 471 if (!maybe_result->ToObject(&result)) return maybe_result; | 486 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 472 } | 487 } |
| 473 } | 488 } |
| 474 return code; | 489 return code; |
| 475 } | 490 } |
| 476 | 491 |
| 477 | 492 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 489 Object* result; | 504 Object* result; |
| 490 { MaybeObject* maybe_result = | 505 { MaybeObject* maybe_result = |
| 491 receiver->UpdateMapCodeCache(name, Code::cast(code)); | 506 receiver->UpdateMapCodeCache(name, Code::cast(code)); |
| 492 if (!maybe_result->ToObject(&result)) return maybe_result; | 507 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 493 } | 508 } |
| 494 } | 509 } |
| 495 return code; | 510 return code; |
| 496 } | 511 } |
| 497 | 512 |
| 498 | 513 |
| 514 namespace { |
| 515 |
| 516 ExternalArrayType ElementsKindToExternalArrayType(JSObject::ElementsKind kind) { |
| 517 switch (kind) { |
| 518 case JSObject::EXTERNAL_BYTE_ELEMENTS: |
| 519 return kExternalByteArray; |
| 520 case JSObject::EXTERNAL_UNSIGNED_BYTE_ELEMENTS: |
| 521 return kExternalUnsignedByteArray; |
| 522 case JSObject::EXTERNAL_SHORT_ELEMENTS: |
| 523 return kExternalShortArray; |
| 524 case JSObject::EXTERNAL_UNSIGNED_SHORT_ELEMENTS: |
| 525 return kExternalUnsignedShortArray; |
| 526 case JSObject::EXTERNAL_INT_ELEMENTS: |
| 527 return kExternalIntArray; |
| 528 case JSObject::EXTERNAL_UNSIGNED_INT_ELEMENTS: |
| 529 return kExternalUnsignedIntArray; |
| 530 case JSObject::EXTERNAL_FLOAT_ELEMENTS: |
| 531 return kExternalFloatArray; |
| 532 default: |
| 533 UNREACHABLE(); |
| 534 return static_cast<ExternalArrayType>(0); |
| 535 } |
| 536 } |
| 537 |
| 538 } // anonymous namespace |
| 539 |
| 540 |
| 541 MaybeObject* StubCache::ComputeKeyedLoadOrStoreExternalArray( |
| 542 JSObject* receiver, |
| 543 bool is_store) { |
| 544 Code::Flags flags = |
| 545 Code::ComputeMonomorphicFlags( |
| 546 is_store ? Code::KEYED_STORE_IC : Code::KEYED_LOAD_IC, |
| 547 NORMAL); |
| 548 ExternalArrayType array_type = |
| 549 ElementsKindToExternalArrayType(receiver->GetElementsKind()); |
| 550 String* name = |
| 551 is_store ? isolate_->heap()->KeyedStoreExternalArray_symbol() |
| 552 : isolate_->heap()->KeyedLoadExternalArray_symbol(); |
| 553 // Use the global maps for the particular external array types, |
| 554 // rather than the receiver's map, when looking up the cached code, |
| 555 // so that we actually canonicalize these stubs. |
| 556 Map* map = isolate_->heap()->MapForExternalArrayType(array_type); |
| 557 Object* code = map->FindInCodeCache(name, flags); |
| 558 if (code->IsUndefined()) { |
| 559 ExternalArrayStubCompiler compiler; |
| 560 { MaybeObject* maybe_code = |
| 561 is_store ? compiler.CompileKeyedStoreStub(array_type, flags) : |
| 562 compiler.CompileKeyedLoadStub(array_type, flags); |
| 563 if (!maybe_code->ToObject(&code)) return maybe_code; |
| 564 } |
| 565 if (is_store) { |
| 566 PROFILE( |
| 567 CodeCreateEvent(Logger::KEYED_STORE_IC_TAG, Code::cast(code), 0)); |
| 568 } else { |
| 569 PROFILE( |
| 570 CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), 0)); |
| 571 } |
| 572 Object* result; |
| 573 { MaybeObject* maybe_result = |
| 574 map->UpdateCodeCache(name, Code::cast(code)); |
| 575 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 576 } |
| 577 } |
| 578 return code; |
| 579 } |
| 580 |
| 581 |
| 499 MaybeObject* StubCache::ComputeStoreNormal() { | 582 MaybeObject* StubCache::ComputeStoreNormal() { |
| 500 return isolate_->builtins()->builtin(Builtins::StoreIC_Normal); | 583 return isolate_->builtins()->builtin(Builtins::StoreIC_Normal); |
| 501 } | 584 } |
| 502 | 585 |
| 503 | 586 |
| 504 MaybeObject* StubCache::ComputeStoreGlobal(String* name, | 587 MaybeObject* StubCache::ComputeStoreGlobal(String* name, |
| 505 GlobalObject* receiver, | 588 GlobalObject* receiver, |
| 506 JSGlobalPropertyCell* cell) { | 589 JSGlobalPropertyCell* cell) { |
| 507 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::STORE_IC, NORMAL); | 590 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::STORE_IC, NORMAL); |
| 508 Object* code = receiver->map()->FindInCodeCache(name, flags); | 591 Object* code = receiver->map()->FindInCodeCache(name, flags); |
| 509 if (code->IsUndefined()) { | 592 if (code->IsUndefined()) { |
| 510 StoreStubCompiler compiler; | 593 StoreStubCompiler compiler; |
| 511 { MaybeObject* maybe_code = | 594 { MaybeObject* maybe_code = |
| 512 compiler.CompileStoreGlobal(receiver, cell, name); | 595 compiler.CompileStoreGlobal(receiver, cell, name); |
| 513 if (!maybe_code->ToObject(&code)) return maybe_code; | 596 if (!maybe_code->ToObject(&code)) return maybe_code; |
| 514 } | 597 } |
| 515 PROFILE(CodeCreateEvent(Logger::STORE_IC_TAG, Code::cast(code), name)); | 598 PROFILE(CodeCreateEvent(Logger::STORE_IC_TAG, Code::cast(code), name)); |
| 599 GDBJIT(AddCode(GDBJITInterface::STORE_IC, name, Code::cast(code))); |
| 516 Object* result; | 600 Object* result; |
| 517 { MaybeObject* maybe_result = | 601 { MaybeObject* maybe_result = |
| 518 receiver->UpdateMapCodeCache(name, Code::cast(code)); | 602 receiver->UpdateMapCodeCache(name, Code::cast(code)); |
| 519 if (!maybe_result->ToObject(&result)) return maybe_result; | 603 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 520 } | 604 } |
| 521 } | 605 } |
| 522 return code; | 606 return code; |
| 523 } | 607 } |
| 524 | 608 |
| 525 | 609 |
| 526 MaybeObject* StubCache::ComputeStoreCallback(String* name, | 610 MaybeObject* StubCache::ComputeStoreCallback(String* name, |
| 527 JSObject* receiver, | 611 JSObject* receiver, |
| 528 AccessorInfo* callback) { | 612 AccessorInfo* callback) { |
| 529 ASSERT(v8::ToCData<Address>(callback->setter()) != 0); | 613 ASSERT(v8::ToCData<Address>(callback->setter()) != 0); |
| 530 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::STORE_IC, CALLBACKS); | 614 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::STORE_IC, CALLBACKS); |
| 531 Object* code = receiver->map()->FindInCodeCache(name, flags); | 615 Object* code = receiver->map()->FindInCodeCache(name, flags); |
| 532 if (code->IsUndefined()) { | 616 if (code->IsUndefined()) { |
| 533 StoreStubCompiler compiler; | 617 StoreStubCompiler compiler; |
| 534 { MaybeObject* maybe_code = | 618 { MaybeObject* maybe_code = |
| 535 compiler.CompileStoreCallback(receiver, callback, name); | 619 compiler.CompileStoreCallback(receiver, callback, name); |
| 536 if (!maybe_code->ToObject(&code)) return maybe_code; | 620 if (!maybe_code->ToObject(&code)) return maybe_code; |
| 537 } | 621 } |
| 538 PROFILE(CodeCreateEvent(Logger::STORE_IC_TAG, Code::cast(code), name)); | 622 PROFILE(CodeCreateEvent(Logger::STORE_IC_TAG, Code::cast(code), name)); |
| 623 GDBJIT(AddCode(GDBJITInterface::STORE_IC, name, Code::cast(code))); |
| 539 Object* result; | 624 Object* result; |
| 540 { MaybeObject* maybe_result = | 625 { MaybeObject* maybe_result = |
| 541 receiver->UpdateMapCodeCache(name, Code::cast(code)); | 626 receiver->UpdateMapCodeCache(name, Code::cast(code)); |
| 542 if (!maybe_result->ToObject(&result)) return maybe_result; | 627 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 543 } | 628 } |
| 544 } | 629 } |
| 545 return code; | 630 return code; |
| 546 } | 631 } |
| 547 | 632 |
| 548 | 633 |
| 549 MaybeObject* StubCache::ComputeStoreInterceptor(String* name, | 634 MaybeObject* StubCache::ComputeStoreInterceptor(String* name, |
| 550 JSObject* receiver) { | 635 JSObject* receiver) { |
| 551 Code::Flags flags = | 636 Code::Flags flags = |
| 552 Code::ComputeMonomorphicFlags(Code::STORE_IC, INTERCEPTOR); | 637 Code::ComputeMonomorphicFlags(Code::STORE_IC, INTERCEPTOR); |
| 553 Object* code = receiver->map()->FindInCodeCache(name, flags); | 638 Object* code = receiver->map()->FindInCodeCache(name, flags); |
| 554 if (code->IsUndefined()) { | 639 if (code->IsUndefined()) { |
| 555 StoreStubCompiler compiler; | 640 StoreStubCompiler compiler; |
| 556 { MaybeObject* maybe_code = | 641 { MaybeObject* maybe_code = |
| 557 compiler.CompileStoreInterceptor(receiver, name); | 642 compiler.CompileStoreInterceptor(receiver, name); |
| 558 if (!maybe_code->ToObject(&code)) return maybe_code; | 643 if (!maybe_code->ToObject(&code)) return maybe_code; |
| 559 } | 644 } |
| 560 PROFILE(CodeCreateEvent(Logger::STORE_IC_TAG, Code::cast(code), name)); | 645 PROFILE(CodeCreateEvent(Logger::STORE_IC_TAG, Code::cast(code), name)); |
| 646 GDBJIT(AddCode(GDBJITInterface::STORE_IC, name, Code::cast(code))); |
| 561 Object* result; | 647 Object* result; |
| 562 { MaybeObject* maybe_result = | 648 { MaybeObject* maybe_result = |
| 563 receiver->UpdateMapCodeCache(name, Code::cast(code)); | 649 receiver->UpdateMapCodeCache(name, Code::cast(code)); |
| 564 if (!maybe_result->ToObject(&result)) return maybe_result; | 650 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 565 } | 651 } |
| 566 } | 652 } |
| 567 return code; | 653 return code; |
| 568 } | 654 } |
| 569 | 655 |
| 570 | 656 |
| 571 MaybeObject* StubCache::ComputeKeyedStoreField(String* name, | 657 MaybeObject* StubCache::ComputeKeyedStoreField(String* name, |
| 572 JSObject* receiver, | 658 JSObject* receiver, |
| 573 int field_index, | 659 int field_index, |
| 574 Map* transition) { | 660 Map* transition) { |
| 575 PropertyType type = (transition == NULL) ? FIELD : MAP_TRANSITION; | 661 PropertyType type = (transition == NULL) ? FIELD : MAP_TRANSITION; |
| 576 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::KEYED_STORE_IC, type); | 662 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::KEYED_STORE_IC, type); |
| 577 Object* code = receiver->map()->FindInCodeCache(name, flags); | 663 Object* code = receiver->map()->FindInCodeCache(name, flags); |
| 578 if (code->IsUndefined()) { | 664 if (code->IsUndefined()) { |
| 579 KeyedStoreStubCompiler compiler; | 665 KeyedStoreStubCompiler compiler; |
| 580 { MaybeObject* maybe_code = | 666 { MaybeObject* maybe_code = |
| 581 compiler.CompileStoreField(receiver, field_index, transition, name); | 667 compiler.CompileStoreField(receiver, field_index, transition, name); |
| 582 if (!maybe_code->ToObject(&code)) return maybe_code; | 668 if (!maybe_code->ToObject(&code)) return maybe_code; |
| 583 } | 669 } |
| 584 PROFILE(CodeCreateEvent( | 670 PROFILE(CodeCreateEvent( |
| 585 Logger::KEYED_STORE_IC_TAG, Code::cast(code), name)); | 671 Logger::KEYED_STORE_IC_TAG, Code::cast(code), name)); |
| 672 GDBJIT(AddCode(GDBJITInterface::KEYED_STORE_IC, name, Code::cast(code))); |
| 586 Object* result; | 673 Object* result; |
| 587 { MaybeObject* maybe_result = | 674 { MaybeObject* maybe_result = |
| 588 receiver->UpdateMapCodeCache(name, Code::cast(code)); | 675 receiver->UpdateMapCodeCache(name, Code::cast(code)); |
| 589 if (!maybe_result->ToObject(&result)) return maybe_result; | 676 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 590 } | 677 } |
| 591 } | 678 } |
| 592 return code; | 679 return code; |
| 593 } | 680 } |
| 594 | 681 |
| 595 #define CALL_LOGGER_TAG(kind, type) \ | 682 #define CALL_LOGGER_TAG(kind, type) \ |
| 596 (kind == Code::CALL_IC ? Logger::type : Logger::KEYED_##type) | 683 (kind == Code::CALL_IC ? Logger::type : Logger::KEYED_##type) |
| 597 | 684 |
| 598 MaybeObject* StubCache::ComputeCallConstant(int argc, | 685 MaybeObject* StubCache::ComputeCallConstant(int argc, |
| 599 InLoopFlag in_loop, | 686 InLoopFlag in_loop, |
| 600 Code::Kind kind, | 687 Code::Kind kind, |
| 688 Code::ExtraICState extra_ic_state, |
| 601 String* name, | 689 String* name, |
| 602 Object* object, | 690 Object* object, |
| 603 JSObject* holder, | 691 JSObject* holder, |
| 604 JSFunction* function) { | 692 JSFunction* function) { |
| 605 // Compute the check type and the map. | 693 // Compute the check type and the map. |
| 606 InlineCacheHolderFlag cache_holder = | 694 InlineCacheHolderFlag cache_holder = |
| 607 IC::GetCodeCacheForObject(object, holder); | 695 IC::GetCodeCacheForObject(object, holder); |
| 608 JSObject* map_holder = IC::GetCodeCacheHolder(object, cache_holder); | 696 JSObject* map_holder = IC::GetCodeCacheHolder(object, cache_holder); |
| 609 | 697 |
| 610 // Compute check type based on receiver/holder. | 698 // Compute check type based on receiver/holder. |
| 611 CheckType check = RECEIVER_MAP_CHECK; | 699 CheckType check = RECEIVER_MAP_CHECK; |
| 612 if (object->IsString()) { | 700 if (object->IsString()) { |
| 613 check = STRING_CHECK; | 701 check = STRING_CHECK; |
| 614 } else if (object->IsNumber()) { | 702 } else if (object->IsNumber()) { |
| 615 check = NUMBER_CHECK; | 703 check = NUMBER_CHECK; |
| 616 } else if (object->IsBoolean()) { | 704 } else if (object->IsBoolean()) { |
| 617 check = BOOLEAN_CHECK; | 705 check = BOOLEAN_CHECK; |
| 618 } | 706 } |
| 619 | 707 |
| 620 Code::Flags flags = | 708 Code::Flags flags = Code::ComputeMonomorphicFlags(kind, |
| 621 Code::ComputeMonomorphicFlags(kind, | 709 CONSTANT_FUNCTION, |
| 622 CONSTANT_FUNCTION, | 710 extra_ic_state, |
| 623 cache_holder, | 711 cache_holder, |
| 624 in_loop, | 712 in_loop, |
| 625 argc); | 713 argc); |
| 626 Object* code = map_holder->map()->FindInCodeCache(name, flags); | 714 Object* code = map_holder->map()->FindInCodeCache(name, flags); |
| 627 if (code->IsUndefined()) { | 715 if (code->IsUndefined()) { |
| 628 // If the function hasn't been compiled yet, we cannot do it now | 716 // If the function hasn't been compiled yet, we cannot do it now |
| 629 // because it may cause GC. To avoid this issue, we return an | 717 // because it may cause GC. To avoid this issue, we return an |
| 630 // internal error which will make sure we do not update any | 718 // internal error which will make sure we do not update any |
| 631 // caches. | 719 // caches. |
| 632 if (!function->is_compiled()) return Failure::InternalError(); | 720 if (!function->is_compiled()) return Failure::InternalError(); |
| 633 // Compile the stub - only create stubs for fully compiled functions. | 721 // Compile the stub - only create stubs for fully compiled functions. |
| 634 CallStubCompiler compiler(argc, in_loop, kind, cache_holder); | 722 CallStubCompiler compiler( |
| 723 argc, in_loop, kind, extra_ic_state, cache_holder); |
| 635 { MaybeObject* maybe_code = | 724 { MaybeObject* maybe_code = |
| 636 compiler.CompileCallConstant(object, holder, function, name, check); | 725 compiler.CompileCallConstant(object, holder, function, name, check); |
| 637 if (!maybe_code->ToObject(&code)) return maybe_code; | 726 if (!maybe_code->ToObject(&code)) return maybe_code; |
| 638 } | 727 } |
| 639 Code::cast(code)->set_check_type(check); | 728 Code::cast(code)->set_check_type(check); |
| 640 ASSERT_EQ(flags, Code::cast(code)->flags()); | 729 ASSERT_EQ(flags, Code::cast(code)->flags()); |
| 641 PROFILE(CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_IC_TAG), | 730 PROFILE(CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_IC_TAG), |
| 642 Code::cast(code), name)); | 731 Code::cast(code), name)); |
| 732 GDBJIT(AddCode(GDBJITInterface::CALL_IC, name, Code::cast(code))); |
| 643 Object* result; | 733 Object* result; |
| 644 { MaybeObject* maybe_result = | 734 { MaybeObject* maybe_result = |
| 645 map_holder->UpdateMapCodeCache(name, Code::cast(code)); | 735 map_holder->UpdateMapCodeCache(name, Code::cast(code)); |
| 646 if (!maybe_result->ToObject(&result)) return maybe_result; | 736 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 647 } | 737 } |
| 648 } | 738 } |
| 649 return code; | 739 return code; |
| 650 } | 740 } |
| 651 | 741 |
| 652 | 742 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 664 | 754 |
| 665 // TODO(1233596): We cannot do receiver map check for non-JS objects | 755 // TODO(1233596): We cannot do receiver map check for non-JS objects |
| 666 // because they may be represented as immediates without a | 756 // because they may be represented as immediates without a |
| 667 // map. Instead, we check against the map in the holder. | 757 // map. Instead, we check against the map in the holder. |
| 668 if (object->IsNumber() || object->IsBoolean() || object->IsString()) { | 758 if (object->IsNumber() || object->IsBoolean() || object->IsString()) { |
| 669 object = holder; | 759 object = holder; |
| 670 } | 760 } |
| 671 | 761 |
| 672 Code::Flags flags = Code::ComputeMonomorphicFlags(kind, | 762 Code::Flags flags = Code::ComputeMonomorphicFlags(kind, |
| 673 FIELD, | 763 FIELD, |
| 764 Code::kNoExtraICState, |
| 674 cache_holder, | 765 cache_holder, |
| 675 in_loop, | 766 in_loop, |
| 676 argc); | 767 argc); |
| 677 Object* code = map_holder->map()->FindInCodeCache(name, flags); | 768 Object* code = map_holder->map()->FindInCodeCache(name, flags); |
| 678 if (code->IsUndefined()) { | 769 if (code->IsUndefined()) { |
| 679 CallStubCompiler compiler(argc, in_loop, kind, cache_holder); | 770 CallStubCompiler compiler( |
| 771 argc, in_loop, kind, Code::kNoExtraICState, cache_holder); |
| 680 { MaybeObject* maybe_code = | 772 { MaybeObject* maybe_code = |
| 681 compiler.CompileCallField(JSObject::cast(object), | 773 compiler.CompileCallField(JSObject::cast(object), |
| 682 holder, | 774 holder, |
| 683 index, | 775 index, |
| 684 name); | 776 name); |
| 685 if (!maybe_code->ToObject(&code)) return maybe_code; | 777 if (!maybe_code->ToObject(&code)) return maybe_code; |
| 686 } | 778 } |
| 687 ASSERT_EQ(flags, Code::cast(code)->flags()); | 779 ASSERT_EQ(flags, Code::cast(code)->flags()); |
| 688 PROFILE(CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_IC_TAG), | 780 PROFILE(CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_IC_TAG), |
| 689 Code::cast(code), name)); | 781 Code::cast(code), name)); |
| 782 GDBJIT(AddCode(GDBJITInterface::CALL_IC, name, Code::cast(code))); |
| 690 Object* result; | 783 Object* result; |
| 691 { MaybeObject* maybe_result = | 784 { MaybeObject* maybe_result = |
| 692 map_holder->UpdateMapCodeCache(name, Code::cast(code)); | 785 map_holder->UpdateMapCodeCache(name, Code::cast(code)); |
| 693 if (!maybe_result->ToObject(&result)) return maybe_result; | 786 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 694 } | 787 } |
| 695 } | 788 } |
| 696 return code; | 789 return code; |
| 697 } | 790 } |
| 698 | 791 |
| 699 | 792 |
| 700 MaybeObject* StubCache::ComputeCallInterceptor(int argc, | 793 MaybeObject* StubCache::ComputeCallInterceptor(int argc, |
| 701 Code::Kind kind, | 794 Code::Kind kind, |
| 702 String* name, | 795 String* name, |
| 703 Object* object, | 796 Object* object, |
| 704 JSObject* holder) { | 797 JSObject* holder) { |
| 705 // Compute the check type and the map. | 798 // Compute the check type and the map. |
| 706 InlineCacheHolderFlag cache_holder = | 799 InlineCacheHolderFlag cache_holder = |
| 707 IC::GetCodeCacheForObject(object, holder); | 800 IC::GetCodeCacheForObject(object, holder); |
| 708 JSObject* map_holder = IC::GetCodeCacheHolder(object, cache_holder); | 801 JSObject* map_holder = IC::GetCodeCacheHolder(object, cache_holder); |
| 709 | 802 |
| 710 // TODO(1233596): We cannot do receiver map check for non-JS objects | 803 // TODO(1233596): We cannot do receiver map check for non-JS objects |
| 711 // because they may be represented as immediates without a | 804 // because they may be represented as immediates without a |
| 712 // map. Instead, we check against the map in the holder. | 805 // map. Instead, we check against the map in the holder. |
| 713 if (object->IsNumber() || object->IsBoolean() || object->IsString()) { | 806 if (object->IsNumber() || object->IsBoolean() || object->IsString()) { |
| 714 object = holder; | 807 object = holder; |
| 715 } | 808 } |
| 716 | 809 |
| 717 Code::Flags flags = | 810 Code::Flags flags = Code::ComputeMonomorphicFlags(kind, |
| 718 Code::ComputeMonomorphicFlags(kind, | 811 INTERCEPTOR, |
| 719 INTERCEPTOR, | 812 Code::kNoExtraICState, |
| 720 cache_holder, | 813 cache_holder, |
| 721 NOT_IN_LOOP, | 814 NOT_IN_LOOP, |
| 722 argc); | 815 argc); |
| 723 Object* code = map_holder->map()->FindInCodeCache(name, flags); | 816 Object* code = map_holder->map()->FindInCodeCache(name, flags); |
| 724 if (code->IsUndefined()) { | 817 if (code->IsUndefined()) { |
| 725 CallStubCompiler compiler(argc, NOT_IN_LOOP, kind, cache_holder); | 818 CallStubCompiler compiler( |
| 819 argc, NOT_IN_LOOP, kind, Code::kNoExtraICState, cache_holder); |
| 726 { MaybeObject* maybe_code = | 820 { MaybeObject* maybe_code = |
| 727 compiler.CompileCallInterceptor(JSObject::cast(object), holder, name); | 821 compiler.CompileCallInterceptor(JSObject::cast(object), holder, name); |
| 728 if (!maybe_code->ToObject(&code)) return maybe_code; | 822 if (!maybe_code->ToObject(&code)) return maybe_code; |
| 729 } | 823 } |
| 730 ASSERT_EQ(flags, Code::cast(code)->flags()); | 824 ASSERT_EQ(flags, Code::cast(code)->flags()); |
| 731 PROFILE(CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_IC_TAG), | 825 PROFILE(CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_IC_TAG), |
| 732 Code::cast(code), name)); | 826 Code::cast(code), name)); |
| 827 GDBJIT(AddCode(GDBJITInterface::CALL_IC, name, Code::cast(code))); |
| 733 Object* result; | 828 Object* result; |
| 734 { MaybeObject* maybe_result = | 829 { MaybeObject* maybe_result = |
| 735 map_holder->UpdateMapCodeCache(name, Code::cast(code)); | 830 map_holder->UpdateMapCodeCache(name, Code::cast(code)); |
| 736 if (!maybe_result->ToObject(&result)) return maybe_result; | 831 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 737 } | 832 } |
| 738 } | 833 } |
| 739 return code; | 834 return code; |
| 740 } | 835 } |
| 741 | 836 |
| 742 | 837 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 757 InLoopFlag in_loop, | 852 InLoopFlag in_loop, |
| 758 Code::Kind kind, | 853 Code::Kind kind, |
| 759 String* name, | 854 String* name, |
| 760 JSObject* receiver, | 855 JSObject* receiver, |
| 761 GlobalObject* holder, | 856 GlobalObject* holder, |
| 762 JSGlobalPropertyCell* cell, | 857 JSGlobalPropertyCell* cell, |
| 763 JSFunction* function) { | 858 JSFunction* function) { |
| 764 InlineCacheHolderFlag cache_holder = | 859 InlineCacheHolderFlag cache_holder = |
| 765 IC::GetCodeCacheForObject(receiver, holder); | 860 IC::GetCodeCacheForObject(receiver, holder); |
| 766 JSObject* map_holder = IC::GetCodeCacheHolder(receiver, cache_holder); | 861 JSObject* map_holder = IC::GetCodeCacheHolder(receiver, cache_holder); |
| 767 Code::Flags flags = | 862 Code::Flags flags = Code::ComputeMonomorphicFlags(kind, |
| 768 Code::ComputeMonomorphicFlags(kind, | 863 NORMAL, |
| 769 NORMAL, | 864 Code::kNoExtraICState, |
| 770 cache_holder, | 865 cache_holder, |
| 771 in_loop, | 866 in_loop, |
| 772 argc); | 867 argc); |
| 773 Object* code = map_holder->map()->FindInCodeCache(name, flags); | 868 Object* code = map_holder->map()->FindInCodeCache(name, flags); |
| 774 if (code->IsUndefined()) { | 869 if (code->IsUndefined()) { |
| 775 // If the function hasn't been compiled yet, we cannot do it now | 870 // If the function hasn't been compiled yet, we cannot do it now |
| 776 // because it may cause GC. To avoid this issue, we return an | 871 // because it may cause GC. To avoid this issue, we return an |
| 777 // internal error which will make sure we do not update any | 872 // internal error which will make sure we do not update any |
| 778 // caches. | 873 // caches. |
| 779 if (!function->is_compiled()) return Failure::InternalError(); | 874 if (!function->is_compiled()) return Failure::InternalError(); |
| 780 CallStubCompiler compiler(argc, in_loop, kind, cache_holder); | 875 CallStubCompiler compiler( |
| 876 argc, in_loop, kind, Code::kNoExtraICState, cache_holder); |
| 781 { MaybeObject* maybe_code = | 877 { MaybeObject* maybe_code = |
| 782 compiler.CompileCallGlobal(receiver, holder, cell, function, name); | 878 compiler.CompileCallGlobal(receiver, holder, cell, function, name); |
| 783 if (!maybe_code->ToObject(&code)) return maybe_code; | 879 if (!maybe_code->ToObject(&code)) return maybe_code; |
| 784 } | 880 } |
| 785 ASSERT_EQ(flags, Code::cast(code)->flags()); | 881 ASSERT_EQ(flags, Code::cast(code)->flags()); |
| 786 PROFILE(CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_IC_TAG), | 882 PROFILE(CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_IC_TAG), |
| 787 Code::cast(code), name)); | 883 Code::cast(code), name)); |
| 884 GDBJIT(AddCode(GDBJITInterface::CALL_IC, name, Code::cast(code))); |
| 788 Object* result; | 885 Object* result; |
| 789 { MaybeObject* maybe_result = | 886 { MaybeObject* maybe_result = |
| 790 map_holder->UpdateMapCodeCache(name, Code::cast(code)); | 887 map_holder->UpdateMapCodeCache(name, Code::cast(code)); |
| 791 if (!maybe_result->ToObject(&result)) return maybe_result; | 888 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 792 } | 889 } |
| 793 } | 890 } |
| 794 return code; | 891 return code; |
| 795 } | 892 } |
| 796 | 893 |
| 797 | 894 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 839 CHECK(GetProbeValue(isolate, Code::cast(code)->flags()) == code); | 936 CHECK(GetProbeValue(isolate, Code::cast(code)->flags()) == code); |
| 840 } | 937 } |
| 841 } | 938 } |
| 842 return maybe_code; | 939 return maybe_code; |
| 843 } | 940 } |
| 844 | 941 |
| 845 | 942 |
| 846 Code* StubCache::FindCallInitialize(int argc, | 943 Code* StubCache::FindCallInitialize(int argc, |
| 847 InLoopFlag in_loop, | 944 InLoopFlag in_loop, |
| 848 Code::Kind kind) { | 945 Code::Kind kind) { |
| 849 Code::Flags flags = | 946 Code::Flags flags = Code::ComputeFlags(kind, |
| 850 Code::ComputeFlags(kind, in_loop, UNINITIALIZED, NORMAL, argc); | 947 in_loop, |
| 948 UNINITIALIZED, |
| 949 Code::kNoExtraICState, |
| 950 NORMAL, |
| 951 argc); |
| 851 Object* result = ProbeCache(isolate_, flags)->ToObjectUnchecked(); | 952 Object* result = ProbeCache(isolate_, flags)->ToObjectUnchecked(); |
| 852 ASSERT(result != isolate_->heap()->undefined_value()); | 953 ASSERT(result != isolate_->heap()->undefined_value()); |
| 853 // This might be called during the marking phase of the collector | 954 // This might be called during the marking phase of the collector |
| 854 // hence the unchecked cast. | 955 // hence the unchecked cast. |
| 855 return reinterpret_cast<Code*>(result); | 956 return reinterpret_cast<Code*>(result); |
| 856 } | 957 } |
| 857 | 958 |
| 858 | 959 |
| 859 MaybeObject* StubCache::ComputeCallInitialize(int argc, | 960 MaybeObject* StubCache::ComputeCallInitialize(int argc, |
| 860 InLoopFlag in_loop, | 961 InLoopFlag in_loop, |
| 861 Code::Kind kind) { | 962 Code::Kind kind) { |
| 862 Code::Flags flags = | 963 Code::Flags flags = Code::ComputeFlags(kind, |
| 863 Code::ComputeFlags(kind, in_loop, UNINITIALIZED, NORMAL, argc); | 964 in_loop, |
| 965 UNINITIALIZED, |
| 966 Code::kNoExtraICState, |
| 967 NORMAL, |
| 968 argc); |
| 864 Object* probe; | 969 Object* probe; |
| 865 { MaybeObject* maybe_probe = ProbeCache(isolate_, flags); | 970 { MaybeObject* maybe_probe = ProbeCache(isolate_, flags); |
| 866 if (!maybe_probe->ToObject(&probe)) return maybe_probe; | 971 if (!maybe_probe->ToObject(&probe)) return maybe_probe; |
| 867 } | 972 } |
| 868 if (!probe->IsUndefined()) return probe; | 973 if (!probe->IsUndefined()) return probe; |
| 869 StubCompiler compiler; | 974 StubCompiler compiler; |
| 870 return FillCache(isolate_, compiler.CompileCallInitialize(flags)); | 975 return FillCache(isolate_, compiler.CompileCallInitialize(flags)); |
| 871 } | 976 } |
| 872 | 977 |
| 873 | 978 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 897 } | 1002 } |
| 898 CALL_HEAP_FUNCTION( | 1003 CALL_HEAP_FUNCTION( |
| 899 isolate_, | 1004 isolate_, |
| 900 ComputeCallInitialize(argc, in_loop, Code::KEYED_CALL_IC), Code); | 1005 ComputeCallInitialize(argc, in_loop, Code::KEYED_CALL_IC), Code); |
| 901 } | 1006 } |
| 902 | 1007 |
| 903 | 1008 |
| 904 MaybeObject* StubCache::ComputeCallPreMonomorphic(int argc, | 1009 MaybeObject* StubCache::ComputeCallPreMonomorphic(int argc, |
| 905 InLoopFlag in_loop, | 1010 InLoopFlag in_loop, |
| 906 Code::Kind kind) { | 1011 Code::Kind kind) { |
| 907 Code::Flags flags = | 1012 Code::Flags flags = Code::ComputeFlags(kind, |
| 908 Code::ComputeFlags(kind, in_loop, PREMONOMORPHIC, NORMAL, argc); | 1013 in_loop, |
| 1014 PREMONOMORPHIC, |
| 1015 Code::kNoExtraICState, |
| 1016 NORMAL, |
| 1017 argc); |
| 909 Object* probe; | 1018 Object* probe; |
| 910 { MaybeObject* maybe_probe = ProbeCache(isolate_, flags); | 1019 { MaybeObject* maybe_probe = ProbeCache(isolate_, flags); |
| 911 if (!maybe_probe->ToObject(&probe)) return maybe_probe; | 1020 if (!maybe_probe->ToObject(&probe)) return maybe_probe; |
| 912 } | 1021 } |
| 913 if (!probe->IsUndefined()) return probe; | 1022 if (!probe->IsUndefined()) return probe; |
| 914 StubCompiler compiler; | 1023 StubCompiler compiler; |
| 915 return FillCache(isolate_, compiler.CompileCallPreMonomorphic(flags)); | 1024 return FillCache(isolate_, compiler.CompileCallPreMonomorphic(flags)); |
| 916 } | 1025 } |
| 917 | 1026 |
| 918 | 1027 |
| 919 MaybeObject* StubCache::ComputeCallNormal(int argc, | 1028 MaybeObject* StubCache::ComputeCallNormal(int argc, |
| 920 InLoopFlag in_loop, | 1029 InLoopFlag in_loop, |
| 921 Code::Kind kind) { | 1030 Code::Kind kind) { |
| 922 Code::Flags flags = | 1031 Code::Flags flags = Code::ComputeFlags(kind, |
| 923 Code::ComputeFlags(kind, in_loop, MONOMORPHIC, NORMAL, argc); | 1032 in_loop, |
| 1033 MONOMORPHIC, |
| 1034 Code::kNoExtraICState, |
| 1035 NORMAL, |
| 1036 argc); |
| 924 Object* probe; | 1037 Object* probe; |
| 925 { MaybeObject* maybe_probe = ProbeCache(isolate_, flags); | 1038 { MaybeObject* maybe_probe = ProbeCache(isolate_, flags); |
| 926 if (!maybe_probe->ToObject(&probe)) return maybe_probe; | 1039 if (!maybe_probe->ToObject(&probe)) return maybe_probe; |
| 927 } | 1040 } |
| 928 if (!probe->IsUndefined()) return probe; | 1041 if (!probe->IsUndefined()) return probe; |
| 929 StubCompiler compiler; | 1042 StubCompiler compiler; |
| 930 return FillCache(isolate_, compiler.CompileCallNormal(flags)); | 1043 return FillCache(isolate_, compiler.CompileCallNormal(flags)); |
| 931 } | 1044 } |
| 932 | 1045 |
| 933 | 1046 |
| 934 MaybeObject* StubCache::ComputeCallMegamorphic(int argc, | 1047 MaybeObject* StubCache::ComputeCallMegamorphic(int argc, |
| 935 InLoopFlag in_loop, | 1048 InLoopFlag in_loop, |
| 936 Code::Kind kind) { | 1049 Code::Kind kind) { |
| 937 Code::Flags flags = | 1050 Code::Flags flags = Code::ComputeFlags(kind, |
| 938 Code::ComputeFlags(kind, in_loop, MEGAMORPHIC, NORMAL, argc); | 1051 in_loop, |
| 1052 MEGAMORPHIC, |
| 1053 Code::kNoExtraICState, |
| 1054 NORMAL, |
| 1055 argc); |
| 939 Object* probe; | 1056 Object* probe; |
| 940 { MaybeObject* maybe_probe = ProbeCache(isolate_, flags); | 1057 { MaybeObject* maybe_probe = ProbeCache(isolate_, flags); |
| 941 if (!maybe_probe->ToObject(&probe)) return maybe_probe; | 1058 if (!maybe_probe->ToObject(&probe)) return maybe_probe; |
| 942 } | 1059 } |
| 943 if (!probe->IsUndefined()) return probe; | 1060 if (!probe->IsUndefined()) return probe; |
| 944 StubCompiler compiler; | 1061 StubCompiler compiler; |
| 945 return FillCache(isolate_, compiler.CompileCallMegamorphic(flags)); | 1062 return FillCache(isolate_, compiler.CompileCallMegamorphic(flags)); |
| 946 } | 1063 } |
| 947 | 1064 |
| 948 | 1065 |
| 949 MaybeObject* StubCache::ComputeCallMiss(int argc, Code::Kind kind) { | 1066 MaybeObject* StubCache::ComputeCallMiss(int argc, Code::Kind kind) { |
| 950 // MONOMORPHIC_PROTOTYPE_FAILURE state is used to make sure that miss stubs | 1067 // MONOMORPHIC_PROTOTYPE_FAILURE state is used to make sure that miss stubs |
| 951 // and monomorphic stubs are not mixed up together in the stub cache. | 1068 // and monomorphic stubs are not mixed up together in the stub cache. |
| 952 Code::Flags flags = Code::ComputeFlags( | 1069 Code::Flags flags = Code::ComputeFlags(kind, |
| 953 kind, NOT_IN_LOOP, MONOMORPHIC_PROTOTYPE_FAILURE, NORMAL, argc); | 1070 NOT_IN_LOOP, |
| 1071 MONOMORPHIC_PROTOTYPE_FAILURE, |
| 1072 Code::kNoExtraICState, |
| 1073 NORMAL, |
| 1074 argc, |
| 1075 OWN_MAP); |
| 954 Object* probe; | 1076 Object* probe; |
| 955 { MaybeObject* maybe_probe = ProbeCache(isolate_, flags); | 1077 { MaybeObject* maybe_probe = ProbeCache(isolate_, flags); |
| 956 if (!maybe_probe->ToObject(&probe)) return maybe_probe; | 1078 if (!maybe_probe->ToObject(&probe)) return maybe_probe; |
| 957 } | 1079 } |
| 958 if (!probe->IsUndefined()) return probe; | 1080 if (!probe->IsUndefined()) return probe; |
| 959 StubCompiler compiler; | 1081 StubCompiler compiler; |
| 960 return FillCache(isolate_, compiler.CompileCallMiss(flags)); | 1082 return FillCache(isolate_, compiler.CompileCallMiss(flags)); |
| 961 } | 1083 } |
| 962 | 1084 |
| 963 | 1085 |
| 964 #ifdef ENABLE_DEBUGGER_SUPPORT | 1086 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 965 MaybeObject* StubCache::ComputeCallDebugBreak(int argc, Code::Kind kind) { | 1087 MaybeObject* StubCache::ComputeCallDebugBreak(int argc, Code::Kind kind) { |
| 966 Code::Flags flags = | 1088 Code::Flags flags = Code::ComputeFlags(kind, |
| 967 Code::ComputeFlags(kind, NOT_IN_LOOP, DEBUG_BREAK, NORMAL, argc); | 1089 NOT_IN_LOOP, |
| 1090 DEBUG_BREAK, |
| 1091 Code::kNoExtraICState, |
| 1092 NORMAL, |
| 1093 argc); |
| 968 Object* probe; | 1094 Object* probe; |
| 969 { MaybeObject* maybe_probe = ProbeCache(isolate_, flags); | 1095 { MaybeObject* maybe_probe = ProbeCache(isolate_, flags); |
| 970 if (!maybe_probe->ToObject(&probe)) return maybe_probe; | 1096 if (!maybe_probe->ToObject(&probe)) return maybe_probe; |
| 971 } | 1097 } |
| 972 if (!probe->IsUndefined()) return probe; | 1098 if (!probe->IsUndefined()) return probe; |
| 973 StubCompiler compiler; | 1099 StubCompiler compiler; |
| 974 return FillCache(isolate_, compiler.CompileCallDebugBreak(flags)); | 1100 return FillCache(isolate_, compiler.CompileCallDebugBreak(flags)); |
| 975 } | 1101 } |
| 976 | 1102 |
| 977 | 1103 |
| 978 MaybeObject* StubCache::ComputeCallDebugPrepareStepIn(int argc, | 1104 MaybeObject* StubCache::ComputeCallDebugPrepareStepIn(int argc, |
| 979 Code::Kind kind) { | 1105 Code::Kind kind) { |
| 980 Code::Flags flags = | 1106 Code::Flags flags = Code::ComputeFlags(kind, |
| 981 Code::ComputeFlags(kind, | 1107 NOT_IN_LOOP, |
| 982 NOT_IN_LOOP, | 1108 DEBUG_PREPARE_STEP_IN, |
| 983 DEBUG_PREPARE_STEP_IN, | 1109 Code::kNoExtraICState, |
| 984 NORMAL, | 1110 NORMAL, |
| 985 argc); | 1111 argc); |
| 986 Object* probe; | 1112 Object* probe; |
| 987 { MaybeObject* maybe_probe = ProbeCache(isolate_, flags); | 1113 { MaybeObject* maybe_probe = ProbeCache(isolate_, flags); |
| 988 if (!maybe_probe->ToObject(&probe)) return maybe_probe; | 1114 if (!maybe_probe->ToObject(&probe)) return maybe_probe; |
| 989 } | 1115 } |
| 990 if (!probe->IsUndefined()) return probe; | 1116 if (!probe->IsUndefined()) return probe; |
| 991 StubCompiler compiler; | 1117 StubCompiler compiler; |
| 992 return FillCache(isolate_, compiler.CompileCallDebugPrepareStepIn(flags)); | 1118 return FillCache(isolate_, compiler.CompileCallDebugPrepareStepIn(flags)); |
| 993 } | 1119 } |
| 994 #endif | 1120 #endif |
| 995 | 1121 |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1270 Object* result; | 1396 Object* result; |
| 1271 { MaybeObject* maybe_result = | 1397 { MaybeObject* maybe_result = |
| 1272 GetCodeWithFlags(flags, "CompileCallInitialize"); | 1398 GetCodeWithFlags(flags, "CompileCallInitialize"); |
| 1273 if (!maybe_result->ToObject(&result)) return maybe_result; | 1399 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 1274 } | 1400 } |
| 1275 COUNTERS->call_initialize_stubs()->Increment(); | 1401 COUNTERS->call_initialize_stubs()->Increment(); |
| 1276 Code* code = Code::cast(result); | 1402 Code* code = Code::cast(result); |
| 1277 USE(code); | 1403 USE(code); |
| 1278 PROFILE(CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_INITIALIZE_TAG), | 1404 PROFILE(CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_INITIALIZE_TAG), |
| 1279 code, code->arguments_count())); | 1405 code, code->arguments_count())); |
| 1406 GDBJIT(AddCode(GDBJITInterface::CALL_INITIALIZE, Code::cast(code))); |
| 1280 return result; | 1407 return result; |
| 1281 } | 1408 } |
| 1282 | 1409 |
| 1283 | 1410 |
| 1284 MaybeObject* StubCompiler::CompileCallPreMonomorphic(Code::Flags flags) { | 1411 MaybeObject* StubCompiler::CompileCallPreMonomorphic(Code::Flags flags) { |
| 1285 HandleScope scope; | 1412 HandleScope scope; |
| 1286 int argc = Code::ExtractArgumentsCountFromFlags(flags); | 1413 int argc = Code::ExtractArgumentsCountFromFlags(flags); |
| 1287 // The code of the PreMonomorphic stub is the same as the code | 1414 // The code of the PreMonomorphic stub is the same as the code |
| 1288 // of the Initialized stub. They just differ on the code object flags. | 1415 // of the Initialized stub. They just differ on the code object flags. |
| 1289 Code::Kind kind = Code::ExtractKindFromFlags(flags); | 1416 Code::Kind kind = Code::ExtractKindFromFlags(flags); |
| 1290 if (kind == Code::CALL_IC) { | 1417 if (kind == Code::CALL_IC) { |
| 1291 CallIC::GenerateInitialize(masm(), argc); | 1418 CallIC::GenerateInitialize(masm(), argc); |
| 1292 } else { | 1419 } else { |
| 1293 KeyedCallIC::GenerateInitialize(masm(), argc); | 1420 KeyedCallIC::GenerateInitialize(masm(), argc); |
| 1294 } | 1421 } |
| 1295 Object* result; | 1422 Object* result; |
| 1296 { MaybeObject* maybe_result = | 1423 { MaybeObject* maybe_result = |
| 1297 GetCodeWithFlags(flags, "CompileCallPreMonomorphic"); | 1424 GetCodeWithFlags(flags, "CompileCallPreMonomorphic"); |
| 1298 if (!maybe_result->ToObject(&result)) return maybe_result; | 1425 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 1299 } | 1426 } |
| 1300 COUNTERS->call_premonomorphic_stubs()->Increment(); | 1427 COUNTERS->call_premonomorphic_stubs()->Increment(); |
| 1301 Code* code = Code::cast(result); | 1428 Code* code = Code::cast(result); |
| 1302 USE(code); | 1429 USE(code); |
| 1303 PROFILE(CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_PRE_MONOMORPHIC_TAG), | 1430 PROFILE(CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_PRE_MONOMORPHIC_TAG), |
| 1304 code, code->arguments_count())); | 1431 code, code->arguments_count())); |
| 1432 GDBJIT(AddCode(GDBJITInterface::CALL_PRE_MONOMORPHIC, Code::cast(code))); |
| 1305 return result; | 1433 return result; |
| 1306 } | 1434 } |
| 1307 | 1435 |
| 1308 | 1436 |
| 1309 MaybeObject* StubCompiler::CompileCallNormal(Code::Flags flags) { | 1437 MaybeObject* StubCompiler::CompileCallNormal(Code::Flags flags) { |
| 1310 HandleScope scope; | 1438 HandleScope scope; |
| 1311 int argc = Code::ExtractArgumentsCountFromFlags(flags); | 1439 int argc = Code::ExtractArgumentsCountFromFlags(flags); |
| 1312 Code::Kind kind = Code::ExtractKindFromFlags(flags); | 1440 Code::Kind kind = Code::ExtractKindFromFlags(flags); |
| 1313 if (kind == Code::CALL_IC) { | 1441 if (kind == Code::CALL_IC) { |
| 1314 CallIC::GenerateNormal(masm(), argc); | 1442 CallIC::GenerateNormal(masm(), argc); |
| 1315 } else { | 1443 } else { |
| 1316 KeyedCallIC::GenerateNormal(masm(), argc); | 1444 KeyedCallIC::GenerateNormal(masm(), argc); |
| 1317 } | 1445 } |
| 1318 Object* result; | 1446 Object* result; |
| 1319 { MaybeObject* maybe_result = GetCodeWithFlags(flags, "CompileCallNormal"); | 1447 { MaybeObject* maybe_result = GetCodeWithFlags(flags, "CompileCallNormal"); |
| 1320 if (!maybe_result->ToObject(&result)) return maybe_result; | 1448 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 1321 } | 1449 } |
| 1322 COUNTERS->call_normal_stubs()->Increment(); | 1450 COUNTERS->call_normal_stubs()->Increment(); |
| 1323 Code* code = Code::cast(result); | 1451 Code* code = Code::cast(result); |
| 1324 USE(code); | 1452 USE(code); |
| 1325 PROFILE(CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_NORMAL_TAG), | 1453 PROFILE(CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_NORMAL_TAG), |
| 1326 code, code->arguments_count())); | 1454 code, code->arguments_count())); |
| 1455 GDBJIT(AddCode(GDBJITInterface::CALL_NORMAL, Code::cast(code))); |
| 1327 return result; | 1456 return result; |
| 1328 } | 1457 } |
| 1329 | 1458 |
| 1330 | 1459 |
| 1331 MaybeObject* StubCompiler::CompileCallMegamorphic(Code::Flags flags) { | 1460 MaybeObject* StubCompiler::CompileCallMegamorphic(Code::Flags flags) { |
| 1332 HandleScope scope; | 1461 HandleScope scope; |
| 1333 int argc = Code::ExtractArgumentsCountFromFlags(flags); | 1462 int argc = Code::ExtractArgumentsCountFromFlags(flags); |
| 1334 Code::Kind kind = Code::ExtractKindFromFlags(flags); | 1463 Code::Kind kind = Code::ExtractKindFromFlags(flags); |
| 1335 if (kind == Code::CALL_IC) { | 1464 if (kind == Code::CALL_IC) { |
| 1336 CallIC::GenerateMegamorphic(masm(), argc); | 1465 CallIC::GenerateMegamorphic(masm(), argc); |
| 1337 } else { | 1466 } else { |
| 1338 KeyedCallIC::GenerateMegamorphic(masm(), argc); | 1467 KeyedCallIC::GenerateMegamorphic(masm(), argc); |
| 1339 } | 1468 } |
| 1340 Object* result; | 1469 Object* result; |
| 1341 { MaybeObject* maybe_result = | 1470 { MaybeObject* maybe_result = |
| 1342 GetCodeWithFlags(flags, "CompileCallMegamorphic"); | 1471 GetCodeWithFlags(flags, "CompileCallMegamorphic"); |
| 1343 if (!maybe_result->ToObject(&result)) return maybe_result; | 1472 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 1344 } | 1473 } |
| 1345 COUNTERS->call_megamorphic_stubs()->Increment(); | 1474 COUNTERS->call_megamorphic_stubs()->Increment(); |
| 1346 Code* code = Code::cast(result); | 1475 Code* code = Code::cast(result); |
| 1347 USE(code); | 1476 USE(code); |
| 1348 PROFILE(CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_MEGAMORPHIC_TAG), | 1477 PROFILE(CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_MEGAMORPHIC_TAG), |
| 1349 code, code->arguments_count())); | 1478 code, code->arguments_count())); |
| 1479 GDBJIT(AddCode(GDBJITInterface::CALL_MEGAMORPHIC, Code::cast(code))); |
| 1350 return result; | 1480 return result; |
| 1351 } | 1481 } |
| 1352 | 1482 |
| 1353 | 1483 |
| 1354 MaybeObject* StubCompiler::CompileCallMiss(Code::Flags flags) { | 1484 MaybeObject* StubCompiler::CompileCallMiss(Code::Flags flags) { |
| 1355 HandleScope scope; | 1485 HandleScope scope; |
| 1356 int argc = Code::ExtractArgumentsCountFromFlags(flags); | 1486 int argc = Code::ExtractArgumentsCountFromFlags(flags); |
| 1357 Code::Kind kind = Code::ExtractKindFromFlags(flags); | 1487 Code::Kind kind = Code::ExtractKindFromFlags(flags); |
| 1358 if (kind == Code::CALL_IC) { | 1488 if (kind == Code::CALL_IC) { |
| 1359 CallIC::GenerateMiss(masm(), argc); | 1489 CallIC::GenerateMiss(masm(), argc); |
| 1360 } else { | 1490 } else { |
| 1361 KeyedCallIC::GenerateMiss(masm(), argc); | 1491 KeyedCallIC::GenerateMiss(masm(), argc); |
| 1362 } | 1492 } |
| 1363 Object* result; | 1493 Object* result; |
| 1364 { MaybeObject* maybe_result = GetCodeWithFlags(flags, "CompileCallMiss"); | 1494 { MaybeObject* maybe_result = GetCodeWithFlags(flags, "CompileCallMiss"); |
| 1365 if (!maybe_result->ToObject(&result)) return maybe_result; | 1495 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 1366 } | 1496 } |
| 1367 COUNTERS->call_megamorphic_stubs()->Increment(); | 1497 COUNTERS->call_megamorphic_stubs()->Increment(); |
| 1368 Code* code = Code::cast(result); | 1498 Code* code = Code::cast(result); |
| 1369 USE(code); | 1499 USE(code); |
| 1370 PROFILE(CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_MISS_TAG), | 1500 PROFILE(CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_MISS_TAG), |
| 1371 code, code->arguments_count())); | 1501 code, code->arguments_count())); |
| 1502 GDBJIT(AddCode(GDBJITInterface::CALL_MISS, Code::cast(code))); |
| 1372 return result; | 1503 return result; |
| 1373 } | 1504 } |
| 1374 | 1505 |
| 1375 | 1506 |
| 1376 #ifdef ENABLE_DEBUGGER_SUPPORT | 1507 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 1377 MaybeObject* StubCompiler::CompileCallDebugBreak(Code::Flags flags) { | 1508 MaybeObject* StubCompiler::CompileCallDebugBreak(Code::Flags flags) { |
| 1378 HandleScope scope; | 1509 HandleScope scope; |
| 1379 Debug::GenerateCallICDebugBreak(masm()); | 1510 Debug::GenerateCallICDebugBreak(masm()); |
| 1380 Object* result; | 1511 Object* result; |
| 1381 { MaybeObject* maybe_result = | 1512 { MaybeObject* maybe_result = |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1461 | 1592 |
| 1462 | 1593 |
| 1463 | 1594 |
| 1464 MaybeObject* LoadStubCompiler::GetCode(PropertyType type, String* name) { | 1595 MaybeObject* LoadStubCompiler::GetCode(PropertyType type, String* name) { |
| 1465 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::LOAD_IC, type); | 1596 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::LOAD_IC, type); |
| 1466 MaybeObject* result = GetCodeWithFlags(flags, name); | 1597 MaybeObject* result = GetCodeWithFlags(flags, name); |
| 1467 if (!result->IsFailure()) { | 1598 if (!result->IsFailure()) { |
| 1468 PROFILE(CodeCreateEvent(Logger::LOAD_IC_TAG, | 1599 PROFILE(CodeCreateEvent(Logger::LOAD_IC_TAG, |
| 1469 Code::cast(result->ToObjectUnchecked()), | 1600 Code::cast(result->ToObjectUnchecked()), |
| 1470 name)); | 1601 name)); |
| 1602 GDBJIT(AddCode(GDBJITInterface::LOAD_IC, |
| 1603 name, |
| 1604 Code::cast(result->ToObjectUnchecked()))); |
| 1471 } | 1605 } |
| 1472 return result; | 1606 return result; |
| 1473 } | 1607 } |
| 1474 | 1608 |
| 1475 | 1609 |
| 1476 MaybeObject* KeyedLoadStubCompiler::GetCode(PropertyType type, String* name) { | 1610 MaybeObject* KeyedLoadStubCompiler::GetCode(PropertyType type, String* name) { |
| 1477 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, type); | 1611 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, type); |
| 1478 MaybeObject* result = GetCodeWithFlags(flags, name); | 1612 MaybeObject* result = GetCodeWithFlags(flags, name); |
| 1479 if (!result->IsFailure()) { | 1613 if (!result->IsFailure()) { |
| 1480 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, | 1614 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, |
| 1481 Code::cast(result->ToObjectUnchecked()), | 1615 Code::cast(result->ToObjectUnchecked()), |
| 1482 name)); | 1616 name)); |
| 1617 GDBJIT(AddCode(GDBJITInterface::LOAD_IC, |
| 1618 name, |
| 1619 Code::cast(result->ToObjectUnchecked()))); |
| 1483 } | 1620 } |
| 1484 return result; | 1621 return result; |
| 1485 } | 1622 } |
| 1486 | 1623 |
| 1487 | 1624 |
| 1488 MaybeObject* StoreStubCompiler::GetCode(PropertyType type, String* name) { | 1625 MaybeObject* StoreStubCompiler::GetCode(PropertyType type, String* name) { |
| 1489 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::STORE_IC, type); | 1626 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::STORE_IC, type); |
| 1490 MaybeObject* result = GetCodeWithFlags(flags, name); | 1627 MaybeObject* result = GetCodeWithFlags(flags, name); |
| 1491 if (!result->IsFailure()) { | 1628 if (!result->IsFailure()) { |
| 1492 PROFILE(CodeCreateEvent(Logger::STORE_IC_TAG, | 1629 PROFILE(CodeCreateEvent(Logger::STORE_IC_TAG, |
| 1493 Code::cast(result->ToObjectUnchecked()), | 1630 Code::cast(result->ToObjectUnchecked()), |
| 1494 name)); | 1631 name)); |
| 1632 GDBJIT(AddCode(GDBJITInterface::STORE_IC, |
| 1633 name, |
| 1634 Code::cast(result->ToObjectUnchecked()))); |
| 1495 } | 1635 } |
| 1496 return result; | 1636 return result; |
| 1497 } | 1637 } |
| 1498 | 1638 |
| 1499 | 1639 |
| 1500 MaybeObject* KeyedStoreStubCompiler::GetCode(PropertyType type, String* name) { | 1640 MaybeObject* KeyedStoreStubCompiler::GetCode(PropertyType type, String* name) { |
| 1501 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::KEYED_STORE_IC, type); | 1641 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::KEYED_STORE_IC, type); |
| 1502 MaybeObject* result = GetCodeWithFlags(flags, name); | 1642 MaybeObject* result = GetCodeWithFlags(flags, name); |
| 1503 if (!result->IsFailure()) { | 1643 if (!result->IsFailure()) { |
| 1504 PROFILE(CodeCreateEvent(Logger::KEYED_STORE_IC_TAG, | 1644 PROFILE(CodeCreateEvent(Logger::KEYED_STORE_IC_TAG, |
| 1505 Code::cast(result->ToObjectUnchecked()), | 1645 Code::cast(result->ToObjectUnchecked()), |
| 1506 name)); | 1646 name)); |
| 1647 GDBJIT(AddCode(GDBJITInterface::KEYED_STORE_IC, |
| 1648 name, |
| 1649 Code::cast(result->ToObjectUnchecked()))); |
| 1507 } | 1650 } |
| 1508 return result; | 1651 return result; |
| 1509 } | 1652 } |
| 1510 | 1653 |
| 1511 | 1654 |
| 1512 CallStubCompiler::CallStubCompiler(int argc, | 1655 CallStubCompiler::CallStubCompiler(int argc, |
| 1513 InLoopFlag in_loop, | 1656 InLoopFlag in_loop, |
| 1514 Code::Kind kind, | 1657 Code::Kind kind, |
| 1658 Code::ExtraICState extra_ic_state, |
| 1515 InlineCacheHolderFlag cache_holder) | 1659 InlineCacheHolderFlag cache_holder) |
| 1516 : arguments_(argc) | 1660 : arguments_(argc), |
| 1517 , in_loop_(in_loop) | 1661 in_loop_(in_loop), |
| 1518 , kind_(kind) | 1662 kind_(kind), |
| 1519 , cache_holder_(cache_holder) { | 1663 extra_ic_state_(extra_ic_state), |
| 1664 cache_holder_(cache_holder) { |
| 1520 } | 1665 } |
| 1521 | 1666 |
| 1522 | 1667 |
| 1523 bool CallStubCompiler::HasCustomCallGenerator(BuiltinFunctionId id) { | 1668 bool CallStubCompiler::HasCustomCallGenerator(BuiltinFunctionId id) { |
| 1524 #define CALL_GENERATOR_CASE(name) if (id == k##name) return true; | 1669 #define CALL_GENERATOR_CASE(name) if (id == k##name) return true; |
| 1525 CUSTOM_CALL_IC_GENERATORS(CALL_GENERATOR_CASE) | 1670 CUSTOM_CALL_IC_GENERATORS(CALL_GENERATOR_CASE) |
| 1526 #undef CALL_GENERATOR_CASE | 1671 #undef CALL_GENERATOR_CASE |
| 1527 return false; | 1672 return false; |
| 1528 } | 1673 } |
| 1529 | 1674 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1546 #undef CALL_GENERATOR_CASE | 1691 #undef CALL_GENERATOR_CASE |
| 1547 ASSERT(!HasCustomCallGenerator(id)); | 1692 ASSERT(!HasCustomCallGenerator(id)); |
| 1548 return HEAP->undefined_value(); | 1693 return HEAP->undefined_value(); |
| 1549 } | 1694 } |
| 1550 | 1695 |
| 1551 | 1696 |
| 1552 MaybeObject* CallStubCompiler::GetCode(PropertyType type, String* name) { | 1697 MaybeObject* CallStubCompiler::GetCode(PropertyType type, String* name) { |
| 1553 int argc = arguments_.immediate(); | 1698 int argc = arguments_.immediate(); |
| 1554 Code::Flags flags = Code::ComputeMonomorphicFlags(kind_, | 1699 Code::Flags flags = Code::ComputeMonomorphicFlags(kind_, |
| 1555 type, | 1700 type, |
| 1701 extra_ic_state_, |
| 1556 cache_holder_, | 1702 cache_holder_, |
| 1557 in_loop_, | 1703 in_loop_, |
| 1558 argc); | 1704 argc); |
| 1559 return GetCodeWithFlags(flags, name); | 1705 return GetCodeWithFlags(flags, name); |
| 1560 } | 1706 } |
| 1561 | 1707 |
| 1562 | 1708 |
| 1563 MaybeObject* CallStubCompiler::GetCode(JSFunction* function) { | 1709 MaybeObject* CallStubCompiler::GetCode(JSFunction* function) { |
| 1564 String* function_name = NULL; | 1710 String* function_name = NULL; |
| 1565 if (function->shared()->name()->IsString()) { | 1711 if (function->shared()->name()->IsString()) { |
| 1566 function_name = String::cast(function->shared()->name()); | 1712 function_name = String::cast(function->shared()->name()); |
| 1567 } | 1713 } |
| 1568 return GetCode(CONSTANT_FUNCTION, function_name); | 1714 return GetCode(CONSTANT_FUNCTION, function_name); |
| 1569 } | 1715 } |
| 1570 | 1716 |
| 1571 | 1717 |
| 1572 MaybeObject* ConstructStubCompiler::GetCode() { | 1718 MaybeObject* ConstructStubCompiler::GetCode() { |
| 1573 Code::Flags flags = Code::ComputeFlags(Code::STUB); | 1719 Code::Flags flags = Code::ComputeFlags(Code::STUB); |
| 1574 Object* result; | 1720 Object* result; |
| 1575 { MaybeObject* maybe_result = GetCodeWithFlags(flags, "ConstructStub"); | 1721 { MaybeObject* maybe_result = GetCodeWithFlags(flags, "ConstructStub"); |
| 1576 if (!maybe_result->ToObject(&result)) return maybe_result; | 1722 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 1577 } | 1723 } |
| 1578 Code* code = Code::cast(result); | 1724 Code* code = Code::cast(result); |
| 1579 USE(code); | 1725 USE(code); |
| 1580 PROFILE(CodeCreateEvent(Logger::STUB_TAG, code, "ConstructStub")); | 1726 PROFILE(CodeCreateEvent(Logger::STUB_TAG, code, "ConstructStub")); |
| 1727 GDBJIT(AddCode(GDBJITInterface::STUB, "ConstructStub", Code::cast(code))); |
| 1581 return result; | 1728 return result; |
| 1582 } | 1729 } |
| 1583 | 1730 |
| 1584 | 1731 |
| 1585 CallOptimization::CallOptimization(LookupResult* lookup) { | 1732 CallOptimization::CallOptimization(LookupResult* lookup) { |
| 1586 if (!lookup->IsProperty() || !lookup->IsCacheable() || | 1733 if (!lookup->IsProperty() || !lookup->IsCacheable() || |
| 1587 lookup->type() != CONSTANT_FUNCTION) { | 1734 lookup->type() != CONSTANT_FUNCTION) { |
| 1588 Initialize(NULL); | 1735 Initialize(NULL); |
| 1589 } else { | 1736 } else { |
| 1590 // We only optimize constant function calls. | 1737 // We only optimize constant function calls. |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1642 if (!signature->receiver()->IsUndefined()) { | 1789 if (!signature->receiver()->IsUndefined()) { |
| 1643 expected_receiver_type_ = | 1790 expected_receiver_type_ = |
| 1644 FunctionTemplateInfo::cast(signature->receiver()); | 1791 FunctionTemplateInfo::cast(signature->receiver()); |
| 1645 } | 1792 } |
| 1646 } | 1793 } |
| 1647 | 1794 |
| 1648 is_simple_api_call_ = true; | 1795 is_simple_api_call_ = true; |
| 1649 } | 1796 } |
| 1650 | 1797 |
| 1651 | 1798 |
| 1799 MaybeObject* ExternalArrayStubCompiler::GetCode(Code::Flags flags) { |
| 1800 Object* result; |
| 1801 { MaybeObject* maybe_result = GetCodeWithFlags(flags, "ExternalArrayStub"); |
| 1802 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 1803 } |
| 1804 Code* code = Code::cast(result); |
| 1805 USE(code); |
| 1806 PROFILE(CodeCreateEvent(Logger::STUB_TAG, code, "ExternalArrayStub")); |
| 1807 return result; |
| 1808 } |
| 1809 |
| 1810 |
| 1652 } } // namespace v8::internal | 1811 } } // namespace v8::internal |
| OLD | NEW |