| 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 while (last->GetPrototype() != Heap::null_value()) { | 107 while (last->GetPrototype() != Heap::null_value()) { |
| 108 last = JSObject::cast(last->GetPrototype()); | 108 last = JSObject::cast(last->GetPrototype()); |
| 109 if (last->IsGlobalObject()) cache_name = name; | 109 if (last->IsGlobalObject()) cache_name = name; |
| 110 } | 110 } |
| 111 // Compile the stub that is either shared for all names or | 111 // Compile the stub that is either shared for all names or |
| 112 // name specific if there are global objects involved. | 112 // name specific if there are global objects involved. |
| 113 Code::Flags flags = | 113 Code::Flags flags = |
| 114 Code::ComputeMonomorphicFlags(Code::LOAD_IC, NONEXISTENT); | 114 Code::ComputeMonomorphicFlags(Code::LOAD_IC, NONEXISTENT); |
| 115 Object* code = receiver->map()->FindInCodeCache(cache_name, flags); | 115 Object* code = receiver->map()->FindInCodeCache(cache_name, flags); |
| 116 if (code->IsUndefined()) { | 116 if (code->IsUndefined()) { |
| 117 { TryAllocation t = |
| 118 compiler.CompileLoadNonexistent(cache_name, receiver, last); |
| 119 if (!t->ToObject(&code)) return t; |
| 120 } |
| 117 LoadStubCompiler compiler; | 121 LoadStubCompiler compiler; |
| 118 code = compiler.CompileLoadNonexistent(cache_name, receiver, last); | |
| 119 if (code->IsFailure()) return code; | |
| 120 PROFILE(CodeCreateEvent(Logger::LOAD_IC_TAG, Code::cast(code), cache_name)); | 122 PROFILE(CodeCreateEvent(Logger::LOAD_IC_TAG, Code::cast(code), cache_name)); |
| 121 Object* result = | 123 Object* result; |
| 122 receiver->UpdateMapCodeCache(cache_name, Code::cast(code)); | 124 { TryAllocation t = |
| 123 if (result->IsFailure()) return result; | 125 receiver->UpdateMapCodeCache(cache_name, Code::cast(code)); |
| 126 if (!t->ToObject(&result)) return t; |
| 127 } |
| 124 } | 128 } |
| 125 return code; | 129 return code; |
| 126 } | 130 } |
| 127 | 131 |
| 128 | 132 |
| 129 Object* StubCache::ComputeLoadField(String* name, | 133 Object* StubCache::ComputeLoadField(String* name, |
| 130 JSObject* receiver, | 134 JSObject* receiver, |
| 131 JSObject* holder, | 135 JSObject* holder, |
| 132 int field_index) { | 136 int field_index) { |
| 133 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP); | 137 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP); |
| 134 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::LOAD_IC, FIELD); | 138 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::LOAD_IC, FIELD); |
| 135 Object* code = receiver->map()->FindInCodeCache(name, flags); | 139 Object* code = receiver->map()->FindInCodeCache(name, flags); |
| 136 if (code->IsUndefined()) { | 140 if (code->IsUndefined()) { |
| 141 { TryAllocation t = |
| 142 compiler.CompileLoadField(receiver, holder, field_index, name); |
| 143 if (!t->ToObject(&code)) return t; |
| 144 } |
| 137 LoadStubCompiler compiler; | 145 LoadStubCompiler compiler; |
| 138 code = compiler.CompileLoadField(receiver, holder, field_index, name); | 146 Object* result; |
| 139 if (code->IsFailure()) return code; | 147 { TryAllocation t = receiver->UpdateMapCodeCache(name, Code::cast(code)); |
| 148 if (!t->ToObject(&result)) return t; |
| 149 } |
| 140 PROFILE(CodeCreateEvent(Logger::LOAD_IC_TAG, Code::cast(code), name)); | 150 PROFILE(CodeCreateEvent(Logger::LOAD_IC_TAG, Code::cast(code), name)); |
| 141 Object* result = receiver->UpdateMapCodeCache(name, Code::cast(code)); | |
| 142 if (result->IsFailure()) return result; | |
| 143 } | 151 } |
| 144 return code; | 152 return code; |
| 145 } | 153 } |
| 146 | 154 |
| 147 | 155 |
| 148 Object* StubCache::ComputeLoadCallback(String* name, | 156 Object* StubCache::ComputeLoadCallback(String* name, |
| 149 JSObject* receiver, | 157 JSObject* receiver, |
| 150 JSObject* holder, | 158 JSObject* holder, |
| 151 AccessorInfo* callback) { | 159 AccessorInfo* callback) { |
| 152 ASSERT(v8::ToCData<Address>(callback->getter()) != 0); | 160 ASSERT(v8::ToCData<Address>(callback->getter()) != 0); |
| 153 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP); | 161 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP); |
| 154 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::LOAD_IC, CALLBACKS); | 162 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::LOAD_IC, CALLBACKS); |
| 155 Object* code = receiver->map()->FindInCodeCache(name, flags); | 163 Object* code = receiver->map()->FindInCodeCache(name, flags); |
| 156 if (code->IsUndefined()) { | 164 if (code->IsUndefined()) { |
| 165 { TryAllocation t = |
| 166 compiler.CompileLoadCallback(name, receiver, holder, callback); |
| 167 if (!t->ToObject(&code)) return t; |
| 168 } |
| 157 LoadStubCompiler compiler; | 169 LoadStubCompiler compiler; |
| 158 code = compiler.CompileLoadCallback(name, receiver, holder, callback); | 170 Object* result; |
| 159 if (code->IsFailure()) return code; | 171 { TryAllocation t = receiver->UpdateMapCodeCache(name, Code::cast(code)); |
| 172 if (!t->ToObject(&result)) return t; |
| 173 } |
| 160 PROFILE(CodeCreateEvent(Logger::LOAD_IC_TAG, Code::cast(code), name)); | 174 PROFILE(CodeCreateEvent(Logger::LOAD_IC_TAG, Code::cast(code), name)); |
| 161 Object* result = receiver->UpdateMapCodeCache(name, Code::cast(code)); | |
| 162 if (result->IsFailure()) return result; | |
| 163 } | 175 } |
| 164 return code; | 176 return code; |
| 165 } | 177 } |
| 166 | 178 |
| 167 | 179 |
| 168 Object* StubCache::ComputeLoadConstant(String* name, | 180 Object* StubCache::ComputeLoadConstant(String* name, |
| 169 JSObject* receiver, | 181 JSObject* receiver, |
| 170 JSObject* holder, | 182 JSObject* holder, |
| 171 Object* value) { | 183 Object* value) { |
| 172 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP); | 184 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP); |
| 173 Code::Flags flags = | 185 Code::Flags flags = |
| 174 Code::ComputeMonomorphicFlags(Code::LOAD_IC, CONSTANT_FUNCTION); | 186 Code::ComputeMonomorphicFlags(Code::LOAD_IC, CONSTANT_FUNCTION); |
| 175 Object* code = receiver->map()->FindInCodeCache(name, flags); | 187 Object* code = receiver->map()->FindInCodeCache(name, flags); |
| 176 if (code->IsUndefined()) { | 188 if (code->IsUndefined()) { |
| 189 { TryAllocation t = |
| 190 compiler.CompileLoadConstant(receiver, holder, value, name); |
| 191 if (!t->ToObject(&code)) return t; |
| 192 } |
| 177 LoadStubCompiler compiler; | 193 LoadStubCompiler compiler; |
| 178 code = compiler.CompileLoadConstant(receiver, holder, value, name); | 194 Object* result; |
| 179 if (code->IsFailure()) return code; | 195 { TryAllocation t = receiver->UpdateMapCodeCache(name, Code::cast(code)); |
| 196 if (!t->ToObject(&result)) return t; |
| 197 } |
| 180 PROFILE(CodeCreateEvent(Logger::LOAD_IC_TAG, Code::cast(code), name)); | 198 PROFILE(CodeCreateEvent(Logger::LOAD_IC_TAG, Code::cast(code), name)); |
| 181 Object* result = receiver->UpdateMapCodeCache(name, Code::cast(code)); | |
| 182 if (result->IsFailure()) return result; | |
| 183 } | 199 } |
| 184 return code; | 200 return code; |
| 185 } | 201 } |
| 186 | 202 |
| 187 | 203 |
| 188 Object* StubCache::ComputeLoadInterceptor(String* name, | 204 Object* StubCache::ComputeLoadInterceptor(String* name, |
| 189 JSObject* receiver, | 205 JSObject* receiver, |
| 190 JSObject* holder) { | 206 JSObject* holder) { |
| 191 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP); | 207 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP); |
| 192 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::LOAD_IC, INTERCEPTOR); | 208 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::LOAD_IC, INTERCEPTOR); |
| 193 Object* code = receiver->map()->FindInCodeCache(name, flags); | 209 Object* code = receiver->map()->FindInCodeCache(name, flags); |
| 194 if (code->IsUndefined()) { | 210 if (code->IsUndefined()) { |
| 211 { TryAllocation t = compiler.CompileLoadInterceptor(receiver, holder, name); |
| 212 if (!t->ToObject(&code)) return t; |
| 213 } |
| 195 LoadStubCompiler compiler; | 214 LoadStubCompiler compiler; |
| 196 code = compiler.CompileLoadInterceptor(receiver, holder, name); | 215 Object* result; |
| 197 if (code->IsFailure()) return code; | 216 { TryAllocation t = receiver->UpdateMapCodeCache(name, Code::cast(code)); |
| 217 if (!t->ToObject(&result)) return t; |
| 218 } |
| 198 PROFILE(CodeCreateEvent(Logger::LOAD_IC_TAG, Code::cast(code), name)); | 219 PROFILE(CodeCreateEvent(Logger::LOAD_IC_TAG, Code::cast(code), name)); |
| 199 Object* result = receiver->UpdateMapCodeCache(name, Code::cast(code)); | |
| 200 if (result->IsFailure()) return result; | |
| 201 } | 220 } |
| 202 return code; | 221 return code; |
| 203 } | 222 } |
| 204 | 223 |
| 205 | 224 |
| 206 Object* StubCache::ComputeLoadNormal() { | 225 Object* StubCache::ComputeLoadNormal() { |
| 207 return Builtins::builtin(Builtins::LoadIC_Normal); | 226 return Builtins::builtin(Builtins::LoadIC_Normal); |
| 208 } | 227 } |
| 209 | 228 |
| 210 | 229 |
| 211 Object* StubCache::ComputeLoadGlobal(String* name, | 230 Object* StubCache::ComputeLoadGlobal(String* name, |
| 212 JSObject* receiver, | 231 JSObject* receiver, |
| 213 GlobalObject* holder, | 232 GlobalObject* holder, |
| 214 JSGlobalPropertyCell* cell, | 233 JSGlobalPropertyCell* cell, |
| 215 bool is_dont_delete) { | 234 bool is_dont_delete) { |
| 216 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP); | 235 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP); |
| 217 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::LOAD_IC, NORMAL); | 236 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::LOAD_IC, NORMAL); |
| 218 Object* code = receiver->map()->FindInCodeCache(name, flags); | 237 Object* code = receiver->map()->FindInCodeCache(name, flags); |
| 219 if (code->IsUndefined()) { | 238 if (code->IsUndefined()) { |
| 220 LoadStubCompiler compiler; | 239 LoadStubCompiler compiler; |
| 221 code = compiler.CompileLoadGlobal(receiver, | 240 code = compiler.CompileLoadGlobal(receiver, |
| 222 holder, | 241 holder, |
| 223 cell, | 242 cell, |
| 224 name, | 243 name, |
| 225 is_dont_delete); | 244 is_dont_delete); |
| 226 if (code->IsFailure()) return code; | 245 if (code->IsFailure()) return code; |
| 246 Object* result; |
| 247 { TryAllocation t = receiver->UpdateMapCodeCache(name, Code::cast(code)); |
| 248 if (!t->ToObject(&result)) return t; |
| 249 } |
| 227 PROFILE(CodeCreateEvent(Logger::LOAD_IC_TAG, Code::cast(code), name)); | 250 PROFILE(CodeCreateEvent(Logger::LOAD_IC_TAG, Code::cast(code), name)); |
| 228 Object* result = receiver->UpdateMapCodeCache(name, Code::cast(code)); | |
| 229 if (result->IsFailure()) return result; | |
| 230 } | 251 } |
| 231 return code; | 252 return code; |
| 232 } | 253 } |
| 233 | 254 |
| 234 | 255 |
| 235 Object* StubCache::ComputeKeyedLoadField(String* name, | 256 Object* StubCache::ComputeKeyedLoadField(String* name, |
| 236 JSObject* receiver, | 257 JSObject* receiver, |
| 237 JSObject* holder, | 258 JSObject* holder, |
| 238 int field_index) { | 259 int field_index) { |
| 239 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP); | 260 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP); |
| 240 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, FIELD); | 261 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, FIELD); |
| 241 Object* code = receiver->map()->FindInCodeCache(name, flags); | 262 Object* code = receiver->map()->FindInCodeCache(name, flags); |
| 242 if (code->IsUndefined()) { | 263 if (code->IsUndefined()) { |
| 264 { TryAllocation t = |
| 265 compiler.CompileLoadField(name, receiver, holder, field_index); |
| 266 if (!t->ToObject(&code)) return t; |
| 267 } |
| 243 KeyedLoadStubCompiler compiler; | 268 KeyedLoadStubCompiler compiler; |
| 244 code = compiler.CompileLoadField(name, receiver, holder, field_index); | 269 Object* result; |
| 245 if (code->IsFailure()) return code; | 270 { TryAllocation t = receiver->UpdateMapCodeCache(name, Code::cast(code)); |
| 271 if (!t->ToObject(&result)) return t; |
| 272 } |
| 246 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), name)); | 273 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), name)); |
| 247 Object* result = receiver->UpdateMapCodeCache(name, Code::cast(code)); | |
| 248 if (result->IsFailure()) return result; | |
| 249 } | 274 } |
| 250 return code; | 275 return code; |
| 251 } | 276 } |
| 252 | 277 |
| 253 | 278 |
| 254 Object* StubCache::ComputeKeyedLoadConstant(String* name, | 279 Object* StubCache::ComputeKeyedLoadConstant(String* name, |
| 255 JSObject* receiver, | 280 JSObject* receiver, |
| 256 JSObject* holder, | 281 JSObject* holder, |
| 257 Object* value) { | 282 Object* value) { |
| 258 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP); | 283 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP); |
| 259 Code::Flags flags = | 284 Code::Flags flags = |
| 260 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, CONSTANT_FUNCTION); | 285 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, CONSTANT_FUNCTION); |
| 261 Object* code = receiver->map()->FindInCodeCache(name, flags); | 286 Object* code = receiver->map()->FindInCodeCache(name, flags); |
| 262 if (code->IsUndefined()) { | 287 if (code->IsUndefined()) { |
| 288 { TryAllocation t = |
| 289 compiler.CompileLoadConstant(name, receiver, holder, value); |
| 290 if (!t->ToObject(&code)) return t; |
| 291 } |
| 263 KeyedLoadStubCompiler compiler; | 292 KeyedLoadStubCompiler compiler; |
| 264 code = compiler.CompileLoadConstant(name, receiver, holder, value); | 293 Object* result; |
| 265 if (code->IsFailure()) return code; | 294 { TryAllocation t = receiver->UpdateMapCodeCache(name, Code::cast(code)); |
| 295 if (!t->ToObject(&result)) return t; |
| 296 } |
| 266 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), name)); | 297 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), name)); |
| 267 Object* result = receiver->UpdateMapCodeCache(name, Code::cast(code)); | |
| 268 if (result->IsFailure()) return result; | |
| 269 } | 298 } |
| 270 return code; | 299 return code; |
| 271 } | 300 } |
| 272 | 301 |
| 273 | 302 |
| 274 Object* StubCache::ComputeKeyedLoadInterceptor(String* name, | 303 Object* StubCache::ComputeKeyedLoadInterceptor(String* name, |
| 275 JSObject* receiver, | 304 JSObject* receiver, |
| 276 JSObject* holder) { | 305 JSObject* holder) { |
| 277 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP); | 306 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP); |
| 278 Code::Flags flags = | 307 Code::Flags flags = |
| 279 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, INTERCEPTOR); | 308 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, INTERCEPTOR); |
| 280 Object* code = receiver->map()->FindInCodeCache(name, flags); | 309 Object* code = receiver->map()->FindInCodeCache(name, flags); |
| 281 if (code->IsUndefined()) { | 310 if (code->IsUndefined()) { |
| 311 { TryAllocation t = compiler.CompileLoadInterceptor(receiver, holder, name); |
| 312 if (!t->ToObject(&code)) return t; |
| 313 } |
| 282 KeyedLoadStubCompiler compiler; | 314 KeyedLoadStubCompiler compiler; |
| 283 code = compiler.CompileLoadInterceptor(receiver, holder, name); | 315 Object* result; |
| 284 if (code->IsFailure()) return code; | 316 { TryAllocation t = receiver->UpdateMapCodeCache(name, Code::cast(code)); |
| 317 if (!t->ToObject(&result)) return t; |
| 318 } |
| 285 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), name)); | 319 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), name)); |
| 286 Object* result = receiver->UpdateMapCodeCache(name, Code::cast(code)); | |
| 287 if (result->IsFailure()) return result; | |
| 288 } | 320 } |
| 289 return code; | 321 return code; |
| 290 } | 322 } |
| 291 | 323 |
| 292 | 324 |
| 293 Object* StubCache::ComputeKeyedLoadCallback(String* name, | 325 Object* StubCache::ComputeKeyedLoadCallback(String* name, |
| 294 JSObject* receiver, | 326 JSObject* receiver, |
| 295 JSObject* holder, | 327 JSObject* holder, |
| 296 AccessorInfo* callback) { | 328 AccessorInfo* callback) { |
| 297 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP); | 329 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP); |
| 298 Code::Flags flags = | 330 Code::Flags flags = |
| 299 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, CALLBACKS); | 331 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, CALLBACKS); |
| 300 Object* code = receiver->map()->FindInCodeCache(name, flags); | 332 Object* code = receiver->map()->FindInCodeCache(name, flags); |
| 301 if (code->IsUndefined()) { | 333 if (code->IsUndefined()) { |
| 334 { TryAllocation t = |
| 335 compiler.CompileLoadCallback(name, receiver, holder, callback); |
| 336 if (!t->ToObject(&code)) return t; |
| 337 } |
| 302 KeyedLoadStubCompiler compiler; | 338 KeyedLoadStubCompiler compiler; |
| 303 code = compiler.CompileLoadCallback(name, receiver, holder, callback); | 339 Object* result; |
| 304 if (code->IsFailure()) return code; | 340 { TryAllocation t = receiver->UpdateMapCodeCache(name, Code::cast(code)); |
| 341 if (!t->ToObject(&result)) return t; |
| 342 } |
| 305 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), name)); | 343 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), name)); |
| 306 Object* result = receiver->UpdateMapCodeCache(name, Code::cast(code)); | |
| 307 if (result->IsFailure()) return result; | |
| 308 } | 344 } |
| 309 return code; | 345 return code; |
| 310 } | 346 } |
| 311 | 347 |
| 312 | 348 |
| 313 | 349 |
| 314 Object* StubCache::ComputeKeyedLoadArrayLength(String* name, | 350 Object* StubCache::ComputeKeyedLoadArrayLength(String* name, |
| 315 JSArray* receiver) { | 351 JSArray* receiver) { |
| 316 Code::Flags flags = | 352 Code::Flags flags = |
| 317 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, CALLBACKS); | 353 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, CALLBACKS); |
| 318 ASSERT(receiver->IsJSObject()); | 354 ASSERT(receiver->IsJSObject()); |
| 319 Object* code = receiver->map()->FindInCodeCache(name, flags); | 355 Object* code = receiver->map()->FindInCodeCache(name, flags); |
| 320 if (code->IsUndefined()) { | 356 if (code->IsUndefined()) { |
| 357 { TryAllocation t = compiler.CompileLoadArrayLength(name); |
| 358 if (!t->ToObject(&code)) return t; |
| 359 } |
| 321 KeyedLoadStubCompiler compiler; | 360 KeyedLoadStubCompiler compiler; |
| 322 code = compiler.CompileLoadArrayLength(name); | 361 Object* result; |
| 323 if (code->IsFailure()) return code; | 362 { TryAllocation t = receiver->UpdateMapCodeCache(name, Code::cast(code)); |
| 363 if (!t->ToObject(&result)) return t; |
| 364 } |
| 324 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), name)); | 365 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), name)); |
| 325 Object* result = receiver->UpdateMapCodeCache(name, Code::cast(code)); | |
| 326 if (result->IsFailure()) return result; | |
| 327 } | 366 } |
| 328 return code; | 367 return code; |
| 329 } | 368 } |
| 330 | 369 |
| 331 | 370 |
| 332 Object* StubCache::ComputeKeyedLoadStringLength(String* name, | 371 Object* StubCache::ComputeKeyedLoadStringLength(String* name, |
| 333 String* receiver) { | 372 String* receiver) { |
| 334 Code::Flags flags = | 373 Code::Flags flags = |
| 335 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, CALLBACKS); | 374 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, CALLBACKS); |
| 336 Map* map = receiver->map(); | 375 Map* map = receiver->map(); |
| 337 Object* code = map->FindInCodeCache(name, flags); | 376 Object* code = map->FindInCodeCache(name, flags); |
| 338 if (code->IsUndefined()) { | 377 if (code->IsUndefined()) { |
| 378 { TryAllocation t = compiler.CompileLoadStringLength(name); |
| 379 if (!t->ToObject(&code)) return t; |
| 380 } |
| 339 KeyedLoadStubCompiler compiler; | 381 KeyedLoadStubCompiler compiler; |
| 340 code = compiler.CompileLoadStringLength(name); | 382 Object* result; |
| 341 if (code->IsFailure()) return code; | 383 { TryAllocation t = map->UpdateCodeCache(name, Code::cast(code)); |
| 384 if (!t->ToObject(&result)) return t; |
| 385 } |
| 342 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), name)); | 386 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), name)); |
| 343 Object* result = map->UpdateCodeCache(name, Code::cast(code)); | |
| 344 if (result->IsFailure()) return result; | |
| 345 } | 387 } |
| 346 return code; | 388 return code; |
| 347 } | 389 } |
| 348 | 390 |
| 349 | 391 |
| 350 Object* StubCache::ComputeKeyedLoadFunctionPrototype(String* name, | 392 Object* StubCache::ComputeKeyedLoadFunctionPrototype(String* name, |
| 351 JSFunction* receiver) { | 393 JSFunction* receiver) { |
| 352 Code::Flags flags = | 394 Code::Flags flags = |
| 353 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, CALLBACKS); | 395 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, CALLBACKS); |
| 354 Object* code = receiver->map()->FindInCodeCache(name, flags); | 396 Object* code = receiver->map()->FindInCodeCache(name, flags); |
| 355 if (code->IsUndefined()) { | 397 if (code->IsUndefined()) { |
| 398 { TryAllocation t = compiler.CompileLoadFunctionPrototype(name); |
| 399 if (!t->ToObject(&code)) return t; |
| 400 } |
| 356 KeyedLoadStubCompiler compiler; | 401 KeyedLoadStubCompiler compiler; |
| 357 code = compiler.CompileLoadFunctionPrototype(name); | 402 Object* result; |
| 358 if (code->IsFailure()) return code; | 403 { TryAllocation t = receiver->UpdateMapCodeCache(name, Code::cast(code)); |
| 404 if (!t->ToObject(&result)) return t; |
| 405 } |
| 359 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), name)); | 406 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), name)); |
| 360 Object* result = receiver->UpdateMapCodeCache(name, Code::cast(code)); | |
| 361 if (result->IsFailure()) return result; | |
| 362 } | 407 } |
| 363 return code; | 408 return code; |
| 364 } | 409 } |
| 365 | 410 |
| 366 | 411 |
| 367 Object* StubCache::ComputeStoreField(String* name, | 412 Object* StubCache::ComputeStoreField(String* name, |
| 368 JSObject* receiver, | 413 JSObject* receiver, |
| 369 int field_index, | 414 int field_index, |
| 370 Map* transition) { | 415 Map* transition) { |
| 371 PropertyType type = (transition == NULL) ? FIELD : MAP_TRANSITION; | 416 PropertyType type = (transition == NULL) ? FIELD : MAP_TRANSITION; |
| 372 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::STORE_IC, type); | 417 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::STORE_IC, type); |
| 373 Object* code = receiver->map()->FindInCodeCache(name, flags); | 418 Object* code = receiver->map()->FindInCodeCache(name, flags); |
| 374 if (code->IsUndefined()) { | 419 if (code->IsUndefined()) { |
| 420 { TryAllocation t = |
| 421 compiler.CompileStoreField(receiver, field_index, transition, name); |
| 422 if (!t->ToObject(&code)) return t; |
| 423 } |
| 375 StoreStubCompiler compiler; | 424 StoreStubCompiler compiler; |
| 376 code = compiler.CompileStoreField(receiver, field_index, transition, name); | 425 Object* result; |
| 377 if (code->IsFailure()) return code; | 426 { TryAllocation t = receiver->UpdateMapCodeCache(name, Code::cast(code)); |
| 427 if (!t->ToObject(&result)) return t; |
| 428 } |
| 378 PROFILE(CodeCreateEvent(Logger::STORE_IC_TAG, Code::cast(code), name)); | 429 PROFILE(CodeCreateEvent(Logger::STORE_IC_TAG, Code::cast(code), name)); |
| 379 Object* result = receiver->UpdateMapCodeCache(name, Code::cast(code)); | |
| 380 if (result->IsFailure()) return result; | |
| 381 } | 430 } |
| 382 return code; | 431 return code; |
| 383 } | 432 } |
| 384 | 433 |
| 385 | 434 |
| 386 Object* StubCache::ComputeStoreNormal() { | 435 Object* StubCache::ComputeStoreNormal() { |
| 387 return Builtins::builtin(Builtins::StoreIC_Normal); | 436 return Builtins::builtin(Builtins::StoreIC_Normal); |
| 388 } | 437 } |
| 389 | 438 |
| 390 | 439 |
| 391 Object* StubCache::ComputeStoreGlobal(String* name, | 440 Object* StubCache::ComputeStoreGlobal(String* name, |
| 392 GlobalObject* receiver, | 441 GlobalObject* receiver, |
| 393 JSGlobalPropertyCell* cell) { | 442 JSGlobalPropertyCell* cell) { |
| 394 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::STORE_IC, NORMAL); | 443 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::STORE_IC, NORMAL); |
| 395 Object* code = receiver->map()->FindInCodeCache(name, flags); | 444 Object* code = receiver->map()->FindInCodeCache(name, flags); |
| 396 if (code->IsUndefined()) { | 445 if (code->IsUndefined()) { |
| 446 { TryAllocation t = compiler.CompileStoreGlobal(receiver, cell, name); |
| 447 if (!t->ToObject(&code)) return t; |
| 448 } |
| 397 StoreStubCompiler compiler; | 449 StoreStubCompiler compiler; |
| 398 code = compiler.CompileStoreGlobal(receiver, cell, name); | 450 Object* result; |
| 399 if (code->IsFailure()) return code; | 451 { TryAllocation t = receiver->UpdateMapCodeCache(name, Code::cast(code)); |
| 452 if (!t->ToObject(&result)) return t; |
| 453 } |
| 400 PROFILE(CodeCreateEvent(Logger::STORE_IC_TAG, Code::cast(code), name)); | 454 PROFILE(CodeCreateEvent(Logger::STORE_IC_TAG, Code::cast(code), name)); |
| 401 Object* result = receiver->UpdateMapCodeCache(name, Code::cast(code)); | |
| 402 if (result->IsFailure()) return result; | |
| 403 } | 455 } |
| 404 return code; | 456 return code; |
| 405 } | 457 } |
| 406 | 458 |
| 407 | 459 |
| 408 Object* StubCache::ComputeStoreCallback(String* name, | 460 Object* StubCache::ComputeStoreCallback(String* name, |
| 409 JSObject* receiver, | 461 JSObject* receiver, |
| 410 AccessorInfo* callback) { | 462 AccessorInfo* callback) { |
| 411 ASSERT(v8::ToCData<Address>(callback->setter()) != 0); | 463 ASSERT(v8::ToCData<Address>(callback->setter()) != 0); |
| 412 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::STORE_IC, CALLBACKS); | 464 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::STORE_IC, CALLBACKS); |
| 413 Object* code = receiver->map()->FindInCodeCache(name, flags); | 465 Object* code = receiver->map()->FindInCodeCache(name, flags); |
| 414 if (code->IsUndefined()) { | 466 if (code->IsUndefined()) { |
| 467 { TryAllocation t = compiler.CompileStoreCallback(receiver, callback, name); |
| 468 if (!t->ToObject(&code)) return t; |
| 469 } |
| 415 StoreStubCompiler compiler; | 470 StoreStubCompiler compiler; |
| 416 code = compiler.CompileStoreCallback(receiver, callback, name); | 471 Object* result; |
| 417 if (code->IsFailure()) return code; | 472 { TryAllocation t = receiver->UpdateMapCodeCache(name, Code::cast(code)); |
| 473 if (!t->ToObject(&result)) return t; |
| 474 } |
| 418 PROFILE(CodeCreateEvent(Logger::STORE_IC_TAG, Code::cast(code), name)); | 475 PROFILE(CodeCreateEvent(Logger::STORE_IC_TAG, Code::cast(code), name)); |
| 419 Object* result = receiver->UpdateMapCodeCache(name, Code::cast(code)); | |
| 420 if (result->IsFailure()) return result; | |
| 421 } | 476 } |
| 422 return code; | 477 return code; |
| 423 } | 478 } |
| 424 | 479 |
| 425 | 480 |
| 426 Object* StubCache::ComputeStoreInterceptor(String* name, | 481 Object* StubCache::ComputeStoreInterceptor(String* name, |
| 427 JSObject* receiver) { | 482 JSObject* receiver) { |
| 428 Code::Flags flags = | 483 Code::Flags flags = |
| 429 Code::ComputeMonomorphicFlags(Code::STORE_IC, INTERCEPTOR); | 484 Code::ComputeMonomorphicFlags(Code::STORE_IC, INTERCEPTOR); |
| 430 Object* code = receiver->map()->FindInCodeCache(name, flags); | 485 Object* code = receiver->map()->FindInCodeCache(name, flags); |
| 431 if (code->IsUndefined()) { | 486 if (code->IsUndefined()) { |
| 487 { TryAllocation t = compiler.CompileStoreInterceptor(receiver, name); |
| 488 if (!t->ToObject(&code)) return t; |
| 489 } |
| 432 StoreStubCompiler compiler; | 490 StoreStubCompiler compiler; |
| 433 code = compiler.CompileStoreInterceptor(receiver, name); | 491 Object* result; |
| 434 if (code->IsFailure()) return code; | 492 { TryAllocation t = receiver->UpdateMapCodeCache(name, Code::cast(code)); |
| 493 if (!t->ToObject(&result)) return t; |
| 494 } |
| 435 PROFILE(CodeCreateEvent(Logger::STORE_IC_TAG, Code::cast(code), name)); | 495 PROFILE(CodeCreateEvent(Logger::STORE_IC_TAG, Code::cast(code), name)); |
| 436 Object* result = receiver->UpdateMapCodeCache(name, Code::cast(code)); | |
| 437 if (result->IsFailure()) return result; | |
| 438 } | 496 } |
| 439 return code; | 497 return code; |
| 440 } | 498 } |
| 441 | 499 |
| 442 | 500 |
| 443 Object* StubCache::ComputeKeyedStoreField(String* name, JSObject* receiver, | 501 Object* StubCache::ComputeKeyedStoreField(String* name, JSObject* receiver, |
| 444 int field_index, Map* transition) { | 502 int field_index, Map* transition) { |
| 445 PropertyType type = (transition == NULL) ? FIELD : MAP_TRANSITION; | 503 PropertyType type = (transition == NULL) ? FIELD : MAP_TRANSITION; |
| 446 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::KEYED_STORE_IC, type); | 504 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::KEYED_STORE_IC, type); |
| 447 Object* code = receiver->map()->FindInCodeCache(name, flags); | 505 Object* code = receiver->map()->FindInCodeCache(name, flags); |
| 448 if (code->IsUndefined()) { | 506 if (code->IsUndefined()) { |
| 507 { TryAllocation t = |
| 508 compiler.CompileStoreField(receiver, field_index, transition, name); |
| 509 if (!t->ToObject(&code)) return t; |
| 510 } |
| 449 KeyedStoreStubCompiler compiler; | 511 KeyedStoreStubCompiler compiler; |
| 450 code = compiler.CompileStoreField(receiver, field_index, transition, name); | |
| 451 if (code->IsFailure()) return code; | |
| 452 PROFILE(CodeCreateEvent( | 512 PROFILE(CodeCreateEvent( |
| 513 Object* result; |
| 514 { TryAllocation t = receiver->UpdateMapCodeCache(name, Code::cast(code)); |
| 515 if (!t->ToObject(&result)) return t; |
| 516 } |
| 453 Logger::KEYED_STORE_IC_TAG, Code::cast(code), name)); | 517 Logger::KEYED_STORE_IC_TAG, Code::cast(code), name)); |
| 454 Object* result = receiver->UpdateMapCodeCache(name, Code::cast(code)); | |
| 455 if (result->IsFailure()) return result; | |
| 456 } | 518 } |
| 457 return code; | 519 return code; |
| 458 } | 520 } |
| 459 | 521 |
| 460 #define CALL_LOGGER_TAG(kind, type) \ | 522 #define CALL_LOGGER_TAG(kind, type) \ |
| 461 (kind == Code::CALL_IC ? Logger::type : Logger::KEYED_##type) | 523 (kind == Code::CALL_IC ? Logger::type : Logger::KEYED_##type) |
| 462 | 524 |
| 463 Object* StubCache::ComputeCallConstant(int argc, | 525 Object* StubCache::ComputeCallConstant(int argc, |
| 464 InLoopFlag in_loop, | 526 InLoopFlag in_loop, |
| 465 Code::Kind kind, | 527 Code::Kind kind, |
| (...skipping 23 matching lines...) Expand all Loading... |
| 489 in_loop, | 551 in_loop, |
| 490 argc); | 552 argc); |
| 491 Object* code = map_holder->map()->FindInCodeCache(name, flags); | 553 Object* code = map_holder->map()->FindInCodeCache(name, flags); |
| 492 if (code->IsUndefined()) { | 554 if (code->IsUndefined()) { |
| 493 // If the function hasn't been compiled yet, we cannot do it now | 555 // If the function hasn't been compiled yet, we cannot do it now |
| 494 // because it may cause GC. To avoid this issue, we return an | 556 // because it may cause GC. To avoid this issue, we return an |
| 495 // internal error which will make sure we do not update any | 557 // internal error which will make sure we do not update any |
| 496 // caches. | 558 // caches. |
| 497 if (!function->is_compiled()) return Failure::InternalError(); | 559 if (!function->is_compiled()) return Failure::InternalError(); |
| 498 // Compile the stub - only create stubs for fully compiled functions. | 560 // Compile the stub - only create stubs for fully compiled functions. |
| 561 { TryAllocation t = |
| 562 compiler.CompileCallConstant(object, holder, function, name, check); |
| 563 if (!t->ToObject(&code)) return t; |
| 564 } |
| 499 CallStubCompiler compiler(argc, in_loop, kind, cache_holder); | 565 CallStubCompiler compiler(argc, in_loop, kind, cache_holder); |
| 500 code = compiler.CompileCallConstant(object, holder, function, name, check); | |
| 501 if (code->IsFailure()) return code; | |
| 502 ASSERT_EQ(flags, Code::cast(code)->flags()); | 566 ASSERT_EQ(flags, Code::cast(code)->flags()); |
| 503 PROFILE(CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_IC_TAG), | 567 PROFILE(CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_IC_TAG), |
| 568 Object* result; |
| 569 { TryAllocation t = map_holder->UpdateMapCodeCache(name, Code::cast(code)); |
| 570 if (!t->ToObject(&result)) return t; |
| 571 } |
| 504 Code::cast(code), name)); | 572 Code::cast(code), name)); |
| 505 Object* result = map_holder->UpdateMapCodeCache(name, Code::cast(code)); | |
| 506 if (result->IsFailure()) return result; | |
| 507 } | 573 } |
| 508 return code; | 574 return code; |
| 509 } | 575 } |
| 510 | 576 |
| 511 | 577 |
| 512 Object* StubCache::ComputeCallField(int argc, | 578 Object* StubCache::ComputeCallField(int argc, |
| 513 InLoopFlag in_loop, | 579 InLoopFlag in_loop, |
| 514 Code::Kind kind, | 580 Code::Kind kind, |
| 515 String* name, | 581 String* name, |
| 516 Object* object, | 582 Object* object, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 536 Object* code = map_holder->map()->FindInCodeCache(name, flags); | 602 Object* code = map_holder->map()->FindInCodeCache(name, flags); |
| 537 if (code->IsUndefined()) { | 603 if (code->IsUndefined()) { |
| 538 CallStubCompiler compiler(argc, in_loop, kind, cache_holder); | 604 CallStubCompiler compiler(argc, in_loop, kind, cache_holder); |
| 539 code = compiler.CompileCallField(JSObject::cast(object), | 605 code = compiler.CompileCallField(JSObject::cast(object), |
| 540 holder, | 606 holder, |
| 541 index, | 607 index, |
| 542 name); | 608 name); |
| 543 if (code->IsFailure()) return code; | 609 if (code->IsFailure()) return code; |
| 544 ASSERT_EQ(flags, Code::cast(code)->flags()); | 610 ASSERT_EQ(flags, Code::cast(code)->flags()); |
| 545 PROFILE(CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_IC_TAG), | 611 PROFILE(CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_IC_TAG), |
| 612 Object* result; |
| 613 { TryAllocation t = map_holder->UpdateMapCodeCache(name, Code::cast(code)); |
| 614 if (!t->ToObject(&result)) return t; |
| 615 } |
| 546 Code::cast(code), name)); | 616 Code::cast(code), name)); |
| 547 Object* result = map_holder->UpdateMapCodeCache(name, Code::cast(code)); | |
| 548 if (result->IsFailure()) return result; | |
| 549 } | 617 } |
| 550 return code; | 618 return code; |
| 551 } | 619 } |
| 552 | 620 |
| 553 | 621 |
| 554 Object* StubCache::ComputeCallInterceptor(int argc, | 622 Object* StubCache::ComputeCallInterceptor(int argc, |
| 555 Code::Kind kind, | 623 Code::Kind kind, |
| 556 String* name, | 624 String* name, |
| 557 Object* object, | 625 Object* object, |
| 558 JSObject* holder) { | 626 JSObject* holder) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 576 argc); | 644 argc); |
| 577 Object* code = map_holder->map()->FindInCodeCache(name, flags); | 645 Object* code = map_holder->map()->FindInCodeCache(name, flags); |
| 578 if (code->IsUndefined()) { | 646 if (code->IsUndefined()) { |
| 579 CallStubCompiler compiler(argc, NOT_IN_LOOP, kind, cache_holder); | 647 CallStubCompiler compiler(argc, NOT_IN_LOOP, kind, cache_holder); |
| 580 code = compiler.CompileCallInterceptor(JSObject::cast(object), | 648 code = compiler.CompileCallInterceptor(JSObject::cast(object), |
| 581 holder, | 649 holder, |
| 582 name); | 650 name); |
| 583 if (code->IsFailure()) return code; | 651 if (code->IsFailure()) return code; |
| 584 ASSERT_EQ(flags, Code::cast(code)->flags()); | 652 ASSERT_EQ(flags, Code::cast(code)->flags()); |
| 585 PROFILE(CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_IC_TAG), | 653 PROFILE(CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_IC_TAG), |
| 654 Object* result; |
| 655 { TryAllocation t = map_holder->UpdateMapCodeCache(name, Code::cast(code)); |
| 656 if (!t->ToObject(&result)) return t; |
| 657 } |
| 586 Code::cast(code), name)); | 658 Code::cast(code), name)); |
| 587 Object* result = map_holder->UpdateMapCodeCache(name, Code::cast(code)); | |
| 588 if (result->IsFailure()) return result; | |
| 589 } | 659 } |
| 590 return code; | 660 return code; |
| 591 } | 661 } |
| 592 | 662 |
| 593 | 663 |
| 594 Object* StubCache::ComputeCallNormal(int argc, | 664 Object* StubCache::ComputeCallNormal(int argc, |
| 595 InLoopFlag in_loop, | 665 InLoopFlag in_loop, |
| 596 Code::Kind kind, | 666 Code::Kind kind, |
| 597 String* name, | 667 String* name, |
| 668 Object* code; |
| 669 { TryAllocation t = ComputeCallNormal(argc, in_loop, kind); |
| 670 if (!t->ToObject(&code)) return t; |
| 671 } |
| 598 JSObject* receiver) { | 672 JSObject* receiver) { |
| 599 Object* code = ComputeCallNormal(argc, in_loop, kind); | |
| 600 if (code->IsFailure()) return code; | |
| 601 return code; | 673 return code; |
| 602 } | 674 } |
| 603 | 675 |
| 604 | 676 |
| 605 Object* StubCache::ComputeCallGlobal(int argc, | 677 Object* StubCache::ComputeCallGlobal(int argc, |
| 606 InLoopFlag in_loop, | 678 InLoopFlag in_loop, |
| 607 Code::Kind kind, | 679 Code::Kind kind, |
| 608 String* name, | 680 String* name, |
| 609 JSObject* receiver, | 681 JSObject* receiver, |
| 610 GlobalObject* holder, | 682 GlobalObject* holder, |
| 611 JSGlobalPropertyCell* cell, | 683 JSGlobalPropertyCell* cell, |
| 612 JSFunction* function) { | 684 JSFunction* function) { |
| 613 InlineCacheHolderFlag cache_holder = | 685 InlineCacheHolderFlag cache_holder = |
| 614 IC::GetCodeCacheForObject(receiver, holder); | 686 IC::GetCodeCacheForObject(receiver, holder); |
| 615 JSObject* map_holder = IC::GetCodeCacheHolder(receiver, cache_holder); | 687 JSObject* map_holder = IC::GetCodeCacheHolder(receiver, cache_holder); |
| 616 Code::Flags flags = | 688 Code::Flags flags = |
| 617 Code::ComputeMonomorphicFlags(kind, | 689 Code::ComputeMonomorphicFlags(kind, |
| 618 NORMAL, | 690 NORMAL, |
| 619 cache_holder, | 691 cache_holder, |
| 620 in_loop, | 692 in_loop, |
| 621 argc); | 693 argc); |
| 622 Object* code = map_holder->map()->FindInCodeCache(name, flags); | 694 Object* code = map_holder->map()->FindInCodeCache(name, flags); |
| 623 if (code->IsUndefined()) { | 695 if (code->IsUndefined()) { |
| 624 // If the function hasn't been compiled yet, we cannot do it now | 696 // 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 | 697 // because it may cause GC. To avoid this issue, we return an |
| 626 // internal error which will make sure we do not update any | 698 // internal error which will make sure we do not update any |
| 627 // caches. | 699 // caches. |
| 628 if (!function->is_compiled()) return Failure::InternalError(); | 700 if (!function->is_compiled()) return Failure::InternalError(); |
| 701 { TryAllocation t = |
| 702 compiler.CompileCallGlobal(receiver, holder, cell, function, name); |
| 703 if (!t->ToObject(&code)) return t; |
| 704 } |
| 629 CallStubCompiler compiler(argc, in_loop, kind, cache_holder); | 705 CallStubCompiler compiler(argc, in_loop, kind, cache_holder); |
| 630 code = compiler.CompileCallGlobal(receiver, holder, cell, function, name); | |
| 631 if (code->IsFailure()) return code; | |
| 632 ASSERT_EQ(flags, Code::cast(code)->flags()); | 706 ASSERT_EQ(flags, Code::cast(code)->flags()); |
| 633 PROFILE(CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_IC_TAG), | 707 PROFILE(CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_IC_TAG), |
| 708 Object* result; |
| 709 { TryAllocation t = map_holder->UpdateMapCodeCache(name, Code::cast(code)); |
| 710 if (!t->ToObject(&result)) return t; |
| 711 } |
| 634 Code::cast(code), name)); | 712 Code::cast(code), name)); |
| 635 Object* result = map_holder->UpdateMapCodeCache(name, Code::cast(code)); | |
| 636 if (result->IsFailure()) return result; | |
| 637 } | 713 } |
| 638 return code; | 714 return code; |
| 639 } | 715 } |
| 640 | 716 |
| 641 | 717 |
| 642 static Object* GetProbeValue(Code::Flags flags) { | 718 static Object* GetProbeValue(Code::Flags flags) { |
| 643 // Use raw_unchecked... so we don't get assert failures during GC. | 719 // Use raw_unchecked... so we don't get assert failures during GC. |
| 644 NumberDictionary* dictionary = Heap::raw_unchecked_non_monomorphic_cache(); | 720 NumberDictionary* dictionary = Heap::raw_unchecked_non_monomorphic_cache(); |
| 645 int entry = dictionary->FindEntry(flags); | 721 int entry = dictionary->FindEntry(flags); |
| 646 if (entry != -1) return dictionary->ValueAt(entry); | 722 if (entry != -1) return dictionary->ValueAt(entry); |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 947 RETURN_IF_SCHEDULED_EXCEPTION(); | 1023 RETURN_IF_SCHEDULED_EXCEPTION(); |
| 948 return result; | 1024 return result; |
| 949 } | 1025 } |
| 950 | 1026 |
| 951 | 1027 |
| 952 /** | 1028 /** |
| 953 * Loads a property with an interceptor performing post interceptor | 1029 * Loads a property with an interceptor performing post interceptor |
| 954 * lookup if interceptor failed. | 1030 * lookup if interceptor failed. |
| 955 */ | 1031 */ |
| 956 Object* LoadPropertyWithInterceptorForLoad(Arguments args) { | 1032 Object* LoadPropertyWithInterceptorForLoad(Arguments args) { |
| 1033 Object* result; |
| 1034 { TryAllocation t = LoadWithInterceptor(&args, &attr); |
| 1035 if (!t->ToObject(&result)) return t; |
| 1036 } |
| 957 PropertyAttributes attr = NONE; | 1037 PropertyAttributes attr = NONE; |
| 958 Object* result = LoadWithInterceptor(&args, &attr); | |
| 959 if (result->IsFailure()) return result; | |
| 960 | 1038 |
| 961 // If the property is present, return it. | 1039 // If the property is present, return it. |
| 962 if (attr != ABSENT) return result; | 1040 if (attr != ABSENT) return result; |
| 963 return ThrowReferenceError(String::cast(args[0])); | 1041 return ThrowReferenceError(String::cast(args[0])); |
| 964 } | 1042 } |
| 965 | 1043 |
| 966 | 1044 |
| 967 Object* LoadPropertyWithInterceptorForCall(Arguments args) { | 1045 Object* LoadPropertyWithInterceptorForCall(Arguments args) { |
| 968 PropertyAttributes attr; | 1046 PropertyAttributes attr; |
| 969 Object* result = LoadWithInterceptor(&args, &attr); | 1047 Object* result = LoadWithInterceptor(&args, &attr); |
| (...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1354 expected_receiver_type_ = | 1432 expected_receiver_type_ = |
| 1355 FunctionTemplateInfo::cast(signature->receiver()); | 1433 FunctionTemplateInfo::cast(signature->receiver()); |
| 1356 } | 1434 } |
| 1357 } | 1435 } |
| 1358 | 1436 |
| 1359 is_simple_api_call_ = true; | 1437 is_simple_api_call_ = true; |
| 1360 } | 1438 } |
| 1361 | 1439 |
| 1362 | 1440 |
| 1363 } } // namespace v8::internal | 1441 } } // namespace v8::internal |
| OLD | NEW |