| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 | 411 |
| 412 static void FillCache(Isolate* isolate, Handle<Code> code) { | 412 static void FillCache(Isolate* isolate, Handle<Code> code) { |
| 413 Handle<UnseededNumberDictionary> dictionary = | 413 Handle<UnseededNumberDictionary> dictionary = |
| 414 UnseededNumberDictionary::Set(isolate->factory()->non_monomorphic_cache(), | 414 UnseededNumberDictionary::Set(isolate->factory()->non_monomorphic_cache(), |
| 415 code->flags(), | 415 code->flags(), |
| 416 code); | 416 code); |
| 417 isolate->heap()->public_set_non_monomorphic_cache(*dictionary); | 417 isolate->heap()->public_set_non_monomorphic_cache(*dictionary); |
| 418 } | 418 } |
| 419 | 419 |
| 420 | 420 |
| 421 Code* StubCache::FindCallInitialize(int argc, | 421 Code* StubCache::FindCallInitialize(int argc, Code::Kind kind) { |
| 422 ContextualMode mode, | |
| 423 Code::Kind kind) { | |
| 424 ExtraICState extra_state = | 422 ExtraICState extra_state = |
| 425 CallICBase::StringStubState::encode(DEFAULT_STRING_STUB) | | 423 CallICBase::StringStubState::encode(DEFAULT_STRING_STUB); |
| 426 CallICBase::Contextual::encode(mode); | |
| 427 Code::Flags flags = | 424 Code::Flags flags = |
| 428 Code::ComputeFlags(kind, UNINITIALIZED, extra_state, Code::NORMAL, argc); | 425 Code::ComputeFlags(kind, UNINITIALIZED, extra_state, Code::NORMAL, argc); |
| 429 UnseededNumberDictionary* dictionary = | 426 UnseededNumberDictionary* dictionary = |
| 430 isolate()->heap()->non_monomorphic_cache(); | 427 isolate()->heap()->non_monomorphic_cache(); |
| 431 int entry = dictionary->FindEntry(isolate(), flags); | 428 int entry = dictionary->FindEntry(isolate(), flags); |
| 432 ASSERT(entry != -1); | 429 ASSERT(entry != -1); |
| 433 Object* code = dictionary->ValueAt(entry); | 430 Object* code = dictionary->ValueAt(entry); |
| 434 // This might be called during the marking phase of the collector | 431 // This might be called during the marking phase of the collector |
| 435 // hence the unchecked cast. | 432 // hence the unchecked cast. |
| 436 return reinterpret_cast<Code*>(code); | 433 return reinterpret_cast<Code*>(code); |
| 437 } | 434 } |
| 438 | 435 |
| 439 | 436 |
| 440 Code* StubCache::FindPreMonomorphicIC(Code::Kind kind, ExtraICState state) { | 437 Code* StubCache::FindPreMonomorphicIC(Code::Kind kind, ExtraICState state) { |
| 441 Code::Flags flags = Code::ComputeFlags(kind, PREMONOMORPHIC, state); | 438 Code::Flags flags = Code::ComputeFlags(kind, PREMONOMORPHIC, state); |
| 442 UnseededNumberDictionary* dictionary = | 439 UnseededNumberDictionary* dictionary = |
| 443 isolate()->heap()->non_monomorphic_cache(); | 440 isolate()->heap()->non_monomorphic_cache(); |
| 444 int entry = dictionary->FindEntry(isolate(), flags); | 441 int entry = dictionary->FindEntry(isolate(), flags); |
| 445 ASSERT(entry != -1); | 442 ASSERT(entry != -1); |
| 446 Object* code = dictionary->ValueAt(entry); | 443 Object* code = dictionary->ValueAt(entry); |
| 447 // This might be called during the marking phase of the collector | 444 // This might be called during the marking phase of the collector |
| 448 // hence the unchecked cast. | 445 // hence the unchecked cast. |
| 449 return reinterpret_cast<Code*>(code); | 446 return reinterpret_cast<Code*>(code); |
| 450 } | 447 } |
| 451 | 448 |
| 452 | 449 |
| 453 Handle<Code> StubCache::ComputeCallInitialize(int argc, | 450 Handle<Code> StubCache::ComputeCallInitialize(int argc, Code::Kind kind) { |
| 454 ContextualMode mode, | |
| 455 Code::Kind kind) { | |
| 456 ExtraICState extra_state = | 451 ExtraICState extra_state = |
| 457 CallICBase::ComputeExtraICState(mode, DEFAULT_STRING_STUB); | 452 CallICBase::ComputeExtraICState(DEFAULT_STRING_STUB); |
| 458 Code::Flags flags = | 453 Code::Flags flags = |
| 459 Code::ComputeFlags(kind, UNINITIALIZED, extra_state, Code::NORMAL, argc); | 454 Code::ComputeFlags(kind, UNINITIALIZED, extra_state, Code::NORMAL, argc); |
| 460 Handle<UnseededNumberDictionary> cache = | 455 Handle<UnseededNumberDictionary> cache = |
| 461 isolate_->factory()->non_monomorphic_cache(); | 456 isolate_->factory()->non_monomorphic_cache(); |
| 462 int entry = cache->FindEntry(isolate_, flags); | 457 int entry = cache->FindEntry(isolate_, flags); |
| 463 if (entry != -1) return Handle<Code>(Code::cast(cache->ValueAt(entry))); | 458 if (entry != -1) return Handle<Code>(Code::cast(cache->ValueAt(entry))); |
| 464 | 459 |
| 465 StubCompiler compiler(isolate_); | 460 StubCompiler compiler(isolate_); |
| 466 Handle<Code> code = compiler.CompileCallInitialize(flags); | 461 Handle<Code> code = compiler.CompileCallInitialize(flags); |
| 467 FillCache(isolate_, code); | 462 FillCache(isolate_, code); |
| 468 return code; | 463 return code; |
| 469 } | 464 } |
| 470 | 465 |
| 471 | 466 |
| 472 Handle<Code> StubCache::ComputeCallInitialize(int argc, ContextualMode mode) { | 467 Handle<Code> StubCache::ComputeCallInitialize(int argc) { |
| 473 return ComputeCallInitialize(argc, mode, Code::CALL_IC); | 468 return ComputeCallInitialize(argc, Code::CALL_IC); |
| 474 } | 469 } |
| 475 | 470 |
| 476 | 471 |
| 477 Handle<Code> StubCache::ComputeKeyedCallInitialize(int argc) { | 472 Handle<Code> StubCache::ComputeKeyedCallInitialize(int argc) { |
| 478 return ComputeCallInitialize(argc, NOT_CONTEXTUAL, Code::KEYED_CALL_IC); | 473 return ComputeCallInitialize(argc, Code::KEYED_CALL_IC); |
| 479 } | 474 } |
| 480 | 475 |
| 481 | 476 |
| 482 Handle<Code> StubCache::ComputeCallPreMonomorphic( | 477 Handle<Code> StubCache::ComputeCallPreMonomorphic( |
| 483 int argc, | 478 int argc, |
| 484 Code::Kind kind, | 479 Code::Kind kind, |
| 485 ExtraICState extra_state) { | 480 ExtraICState extra_state) { |
| 486 Code::Flags flags = | 481 Code::Flags flags = |
| 487 Code::ComputeFlags(kind, PREMONOMORPHIC, extra_state, Code::NORMAL, argc); | 482 Code::ComputeFlags(kind, PREMONOMORPHIC, extra_state, Code::NORMAL, argc); |
| 488 Handle<UnseededNumberDictionary> cache = | 483 Handle<UnseededNumberDictionary> cache = |
| (...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1261 holder->LocalLookupRealNamedProperty(*name, lookup); | 1256 holder->LocalLookupRealNamedProperty(*name, lookup); |
| 1262 if (lookup->IsFound()) return; | 1257 if (lookup->IsFound()) return; |
| 1263 if (holder->GetPrototype()->IsNull()) return; | 1258 if (holder->GetPrototype()->IsNull()) return; |
| 1264 holder->GetPrototype()->Lookup(*name, lookup); | 1259 holder->GetPrototype()->Lookup(*name, lookup); |
| 1265 } | 1260 } |
| 1266 | 1261 |
| 1267 | 1262 |
| 1268 #define __ ACCESS_MASM(masm()) | 1263 #define __ ACCESS_MASM(masm()) |
| 1269 | 1264 |
| 1270 | 1265 |
| 1271 CallKind CallStubCompiler::call_kind() { | |
| 1272 return CallICBase::Contextual::decode(extra_state()) | |
| 1273 ? CALL_AS_FUNCTION | |
| 1274 : CALL_AS_METHOD; | |
| 1275 } | |
| 1276 | |
| 1277 | |
| 1278 void CallStubCompiler::HandlerFrontendFooter(Label* miss) { | 1266 void CallStubCompiler::HandlerFrontendFooter(Label* miss) { |
| 1279 __ bind(miss); | 1267 __ bind(miss); |
| 1280 GenerateMissBranch(); | 1268 GenerateMissBranch(); |
| 1281 } | 1269 } |
| 1282 | 1270 |
| 1283 | 1271 |
| 1284 void CallStubCompiler::GenerateJumpFunctionIgnoreReceiver( | 1272 void CallStubCompiler::GenerateJumpFunctionIgnoreReceiver( |
| 1285 Handle<JSFunction> function) { | 1273 Handle<JSFunction> function) { |
| 1286 ParameterCount expected(function); | 1274 ParameterCount expected(function); |
| 1287 __ InvokeFunction(function, expected, arguments(), | 1275 __ InvokeFunction(function, expected, arguments(), |
| 1288 JUMP_FUNCTION, NullCallWrapper(), call_kind()); | 1276 JUMP_FUNCTION, NullCallWrapper()); |
| 1289 } | 1277 } |
| 1290 | 1278 |
| 1291 | 1279 |
| 1292 void CallStubCompiler::GenerateJumpFunction(Handle<Object> object, | 1280 void CallStubCompiler::GenerateJumpFunction(Handle<Object> object, |
| 1293 Handle<JSFunction> function) { | 1281 Handle<JSFunction> function) { |
| 1294 PatchImplicitReceiver(object); | 1282 PatchImplicitReceiver(object); |
| 1295 GenerateJumpFunctionIgnoreReceiver(function); | 1283 GenerateJumpFunctionIgnoreReceiver(function); |
| 1296 } | 1284 } |
| 1297 | 1285 |
| 1298 | 1286 |
| 1299 void CallStubCompiler::GenerateJumpFunction(Handle<Object> object, | 1287 void CallStubCompiler::GenerateJumpFunction(Handle<Object> object, |
| 1300 Register actual_closure, | 1288 Register actual_closure, |
| 1301 Handle<JSFunction> function) { | 1289 Handle<JSFunction> function) { |
| 1302 PatchImplicitReceiver(object); | 1290 PatchImplicitReceiver(object); |
| 1303 ParameterCount expected(function); | 1291 ParameterCount expected(function); |
| 1304 __ InvokeFunction(actual_closure, expected, arguments(), | 1292 __ InvokeFunction(actual_closure, expected, arguments(), |
| 1305 JUMP_FUNCTION, NullCallWrapper(), call_kind()); | 1293 JUMP_FUNCTION, NullCallWrapper()); |
| 1306 } | 1294 } |
| 1307 | 1295 |
| 1308 | 1296 |
| 1309 Handle<Code> CallStubCompiler::CompileCallConstant( | 1297 Handle<Code> CallStubCompiler::CompileCallConstant( |
| 1310 Handle<Object> object, | 1298 Handle<Object> object, |
| 1311 Handle<JSObject> holder, | 1299 Handle<JSObject> holder, |
| 1312 Handle<Name> name, | 1300 Handle<Name> name, |
| 1313 CheckType check, | 1301 CheckType check, |
| 1314 Handle<JSFunction> function) { | 1302 Handle<JSFunction> function) { |
| 1315 if (HasCustomCallGenerator(function)) { | 1303 if (HasCustomCallGenerator(function)) { |
| (...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2041 Handle<FunctionTemplateInfo>( | 2029 Handle<FunctionTemplateInfo>( |
| 2042 FunctionTemplateInfo::cast(signature->receiver())); | 2030 FunctionTemplateInfo::cast(signature->receiver())); |
| 2043 } | 2031 } |
| 2044 } | 2032 } |
| 2045 | 2033 |
| 2046 is_simple_api_call_ = true; | 2034 is_simple_api_call_ = true; |
| 2047 } | 2035 } |
| 2048 | 2036 |
| 2049 | 2037 |
| 2050 } } // namespace v8::internal | 2038 } } // namespace v8::internal |
| OLD | NEW |