OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 1273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1284 | 1284 |
1285 | 1285 |
1286 Handle<Code> StubCompiler::GetCodeWithFlags(Code::Flags flags, | 1286 Handle<Code> StubCompiler::GetCodeWithFlags(Code::Flags flags, |
1287 Handle<String> name) { | 1287 Handle<String> name) { |
1288 return (FLAG_print_code_stubs && !name.is_null()) | 1288 return (FLAG_print_code_stubs && !name.is_null()) |
1289 ? GetCodeWithFlags(flags, *name->ToCString()) | 1289 ? GetCodeWithFlags(flags, *name->ToCString()) |
1290 : GetCodeWithFlags(flags, reinterpret_cast<char*>(NULL)); | 1290 : GetCodeWithFlags(flags, reinterpret_cast<char*>(NULL)); |
1291 } | 1291 } |
1292 | 1292 |
1293 | 1293 |
1294 MaybeObject* StubCompiler::TryGetCodeWithFlags(Code::Flags flags, | |
1295 const char* name) { | |
1296 // Check for allocation failures during stub compilation. | |
1297 if (failure_->IsFailure()) return failure_; | |
1298 | |
1299 // Create code object in the heap. | |
1300 CodeDesc desc; | |
1301 masm_.GetCode(&desc); | |
1302 MaybeObject* result = heap()->CreateCode(desc, flags, masm_.CodeObject()); | |
1303 #ifdef ENABLE_DISASSEMBLER | |
1304 if (FLAG_print_code_stubs && !result->IsFailure()) { | |
1305 Code::cast(result->ToObjectUnchecked())->Disassemble(name); | |
1306 } | |
1307 #endif | |
1308 return result; | |
1309 } | |
1310 | |
1311 | |
1312 MaybeObject* StubCompiler::TryGetCodeWithFlags(Code::Flags flags, | |
1313 String* name) { | |
1314 if (FLAG_print_code_stubs && name != NULL) { | |
1315 return TryGetCodeWithFlags(flags, *name->ToCString()); | |
1316 } | |
1317 return TryGetCodeWithFlags(flags, reinterpret_cast<char*>(NULL)); | |
1318 } | |
1319 | |
1320 | |
1321 void StubCompiler::LookupPostInterceptor(Handle<JSObject> holder, | 1294 void StubCompiler::LookupPostInterceptor(Handle<JSObject> holder, |
1322 Handle<String> name, | 1295 Handle<String> name, |
1323 LookupResult* lookup) { | 1296 LookupResult* lookup) { |
1324 holder->LocalLookupRealNamedProperty(*name, lookup); | 1297 holder->LocalLookupRealNamedProperty(*name, lookup); |
1325 if (lookup->IsProperty()) return; | 1298 if (lookup->IsProperty()) return; |
1326 | 1299 |
1327 lookup->NotFound(); | 1300 lookup->NotFound(); |
1328 if (holder->GetPrototype()->IsNull()) return; | 1301 if (holder->GetPrototype()->IsNull()) return; |
1329 | 1302 |
1330 holder->GetPrototype()->Lookup(*name, lookup); | 1303 holder->GetPrototype()->Lookup(*name, lookup); |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1452 | 1425 |
1453 Handle<Code> CallStubCompiler::GetCode(Handle<JSFunction> function) { | 1426 Handle<Code> CallStubCompiler::GetCode(Handle<JSFunction> function) { |
1454 Handle<String> function_name; | 1427 Handle<String> function_name; |
1455 if (function->shared()->name()->IsString()) { | 1428 if (function->shared()->name()->IsString()) { |
1456 function_name = Handle<String>(String::cast(function->shared()->name())); | 1429 function_name = Handle<String>(String::cast(function->shared()->name())); |
1457 } | 1430 } |
1458 return GetCode(CONSTANT_FUNCTION, function_name); | 1431 return GetCode(CONSTANT_FUNCTION, function_name); |
1459 } | 1432 } |
1460 | 1433 |
1461 | 1434 |
1462 MaybeObject* ConstructStubCompiler::GetCode() { | 1435 Handle<Code> ConstructStubCompiler::GetCode() { |
1463 Code::Flags flags = Code::ComputeFlags(Code::STUB); | 1436 Code::Flags flags = Code::ComputeFlags(Code::STUB); |
1464 Object* result; | 1437 Handle<Code> code = GetCodeWithFlags(flags, "ConstructStub"); |
1465 { MaybeObject* maybe_result = TryGetCodeWithFlags(flags, "ConstructStub"); | 1438 PROFILE(isolate(), CodeCreateEvent(Logger::STUB_TAG, *code, "ConstructStub")); |
1466 if (!maybe_result->ToObject(&result)) return maybe_result; | 1439 GDBJIT(AddCode(GDBJITInterface::STUB, "ConstructStub", *code)); |
1467 } | 1440 return code; |
1468 Code* code = Code::cast(result); | |
1469 USE(code); | |
1470 PROFILE(isolate(), CodeCreateEvent(Logger::STUB_TAG, code, "ConstructStub")); | |
1471 GDBJIT(AddCode(GDBJITInterface::STUB, "ConstructStub", Code::cast(code))); | |
1472 return result; | |
1473 } | 1441 } |
1474 | 1442 |
1475 | 1443 |
1476 CallOptimization::CallOptimization(LookupResult* lookup) { | 1444 CallOptimization::CallOptimization(LookupResult* lookup) { |
1477 if (!lookup->IsProperty() || | 1445 if (!lookup->IsProperty() || |
1478 !lookup->IsCacheable() || | 1446 !lookup->IsCacheable() || |
1479 lookup->type() != CONSTANT_FUNCTION) { | 1447 lookup->type() != CONSTANT_FUNCTION) { |
1480 Initialize(Handle<JSFunction>::null()); | 1448 Initialize(Handle<JSFunction>::null()); |
1481 } else { | 1449 } else { |
1482 // We only optimize constant function calls. | 1450 // We only optimize constant function calls. |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1538 Handle<FunctionTemplateInfo>( | 1506 Handle<FunctionTemplateInfo>( |
1539 FunctionTemplateInfo::cast(signature->receiver())); | 1507 FunctionTemplateInfo::cast(signature->receiver())); |
1540 } | 1508 } |
1541 } | 1509 } |
1542 | 1510 |
1543 is_simple_api_call_ = true; | 1511 is_simple_api_call_ = true; |
1544 } | 1512 } |
1545 | 1513 |
1546 | 1514 |
1547 } } // namespace v8::internal | 1515 } } // namespace v8::internal |
OLD | NEW |