| 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 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 if (cgen.HasStackOverflow()) { | 278 if (cgen.HasStackOverflow()) { |
| 279 ASSERT(!isolate->has_pending_exception()); | 279 ASSERT(!isolate->has_pending_exception()); |
| 280 return false; | 280 return false; |
| 281 } | 281 } |
| 282 unsigned table_offset = cgen.EmitStackCheckTable(); | 282 unsigned table_offset = cgen.EmitStackCheckTable(); |
| 283 | 283 |
| 284 Code::Flags flags = Code::ComputeFlags(Code::FUNCTION); | 284 Code::Flags flags = Code::ComputeFlags(Code::FUNCTION); |
| 285 Handle<Code> code = CodeGenerator::MakeCodeEpilogue(&masm, flags, info); | 285 Handle<Code> code = CodeGenerator::MakeCodeEpilogue(&masm, flags, info); |
| 286 code->set_optimizable(info->IsOptimizable()); | 286 code->set_optimizable(info->IsOptimizable()); |
| 287 cgen.PopulateDeoptimizationData(code); | 287 cgen.PopulateDeoptimizationData(code); |
| 288 cgen.PopulateTypeFeedbackCells(code); |
| 288 code->set_has_deoptimization_support(info->HasDeoptimizationSupport()); | 289 code->set_has_deoptimization_support(info->HasDeoptimizationSupport()); |
| 289 code->set_handler_table(*cgen.handler_table()); | 290 code->set_handler_table(*cgen.handler_table()); |
| 290 #ifdef ENABLE_DEBUGGER_SUPPORT | 291 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 291 code->set_has_debug_break_slots( | 292 code->set_has_debug_break_slots( |
| 292 info->isolate()->debugger()->IsDebuggerActive()); | 293 info->isolate()->debugger()->IsDebuggerActive()); |
| 293 code->set_compiled_optimizable(info->IsOptimizable()); | 294 code->set_compiled_optimizable(info->IsOptimizable()); |
| 294 #endif // ENABLE_DEBUGGER_SUPPORT | 295 #endif // ENABLE_DEBUGGER_SUPPORT |
| 295 code->set_allow_osr_at_loop_nesting_level(0); | 296 code->set_allow_osr_at_loop_nesting_level(0); |
| 296 code->set_stack_check_table_offset(table_offset); | 297 code->set_stack_check_table_offset(table_offset); |
| 297 CodeGenerator::PrintCode(code, info); | 298 CodeGenerator::PrintCode(code, info); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 322 } | 323 } |
| 323 return offset; | 324 return offset; |
| 324 } | 325 } |
| 325 | 326 |
| 326 | 327 |
| 327 void FullCodeGenerator::PopulateDeoptimizationData(Handle<Code> code) { | 328 void FullCodeGenerator::PopulateDeoptimizationData(Handle<Code> code) { |
| 328 // Fill in the deoptimization information. | 329 // Fill in the deoptimization information. |
| 329 ASSERT(info_->HasDeoptimizationSupport() || bailout_entries_.is_empty()); | 330 ASSERT(info_->HasDeoptimizationSupport() || bailout_entries_.is_empty()); |
| 330 if (!info_->HasDeoptimizationSupport()) return; | 331 if (!info_->HasDeoptimizationSupport()) return; |
| 331 int length = bailout_entries_.length(); | 332 int length = bailout_entries_.length(); |
| 332 Handle<DeoptimizationOutputData> data = | 333 Handle<DeoptimizationOutputData> data = isolate()->factory()-> |
| 333 isolate()->factory()-> | |
| 334 NewDeoptimizationOutputData(length, TENURED); | 334 NewDeoptimizationOutputData(length, TENURED); |
| 335 for (int i = 0; i < length; i++) { | 335 for (int i = 0; i < length; i++) { |
| 336 data->SetAstId(i, Smi::FromInt(bailout_entries_[i].id)); | 336 data->SetAstId(i, Smi::FromInt(bailout_entries_[i].id)); |
| 337 data->SetPcAndState(i, Smi::FromInt(bailout_entries_[i].pc_and_state)); | 337 data->SetPcAndState(i, Smi::FromInt(bailout_entries_[i].pc_and_state)); |
| 338 } | 338 } |
| 339 code->set_deoptimization_data(*data); | 339 code->set_deoptimization_data(*data); |
| 340 } | 340 } |
| 341 | 341 |
| 342 | 342 |
| 343 void FullCodeGenerator::PopulateTypeFeedbackCells(Handle<Code> code) { |
| 344 if (type_feedback_cells_.is_empty()) return; |
| 345 int length = type_feedback_cells_.length(); |
| 346 int array_size = TypeFeedbackCells::LengthOfFixedArray(length); |
| 347 Handle<TypeFeedbackCells> cache = Handle<TypeFeedbackCells>::cast( |
| 348 isolate()->factory()->NewFixedArray(array_size, TENURED)); |
| 349 for (int i = 0; i < length; i++) { |
| 350 cache->SetAstId(i, Smi::FromInt(type_feedback_cells_[i].ast_id)); |
| 351 cache->SetCell(i, *type_feedback_cells_[i].cell); |
| 352 } |
| 353 code->set_type_feedback_cells(*cache); |
| 354 } |
| 355 |
| 356 |
| 357 |
| 343 void FullCodeGenerator::PrepareForBailout(Expression* node, State state) { | 358 void FullCodeGenerator::PrepareForBailout(Expression* node, State state) { |
| 344 PrepareForBailoutForId(node->id(), state); | 359 PrepareForBailoutForId(node->id(), state); |
| 345 } | 360 } |
| 346 | 361 |
| 347 | 362 |
| 348 void FullCodeGenerator::RecordJSReturnSite(Call* call) { | 363 void FullCodeGenerator::RecordJSReturnSite(Call* call) { |
| 349 // We record the offset of the function return so we can rebuild the frame | 364 // We record the offset of the function return so we can rebuild the frame |
| 350 // if the function was inlined, i.e., this is the return address in the | 365 // if the function was inlined, i.e., this is the return address in the |
| 351 // inlined function's frame. | 366 // inlined function's frame. |
| 352 // | 367 // |
| (...skipping 23 matching lines...) Expand all Loading... |
| 376 AstPrinter printer; | 391 AstPrinter printer; |
| 377 PrintF("%s", printer.PrintProgram(info_->function())); | 392 PrintF("%s", printer.PrintProgram(info_->function())); |
| 378 UNREACHABLE(); | 393 UNREACHABLE(); |
| 379 } | 394 } |
| 380 } | 395 } |
| 381 #endif // DEBUG | 396 #endif // DEBUG |
| 382 bailout_entries_.Add(entry); | 397 bailout_entries_.Add(entry); |
| 383 } | 398 } |
| 384 | 399 |
| 385 | 400 |
| 401 void FullCodeGenerator::RecordTypeFeedbackCell( |
| 402 unsigned id, Handle<JSGlobalPropertyCell> cell) { |
| 403 TypeFeedbackCellEntry entry = { id, cell }; |
| 404 type_feedback_cells_.Add(entry); |
| 405 } |
| 406 |
| 407 |
| 386 void FullCodeGenerator::RecordStackCheck(unsigned ast_id) { | 408 void FullCodeGenerator::RecordStackCheck(unsigned ast_id) { |
| 387 // The pc offset does not need to be encoded and packed together with a | 409 // The pc offset does not need to be encoded and packed together with a |
| 388 // state. | 410 // state. |
| 389 ASSERT(masm_->pc_offset() > 0); | 411 ASSERT(masm_->pc_offset() > 0); |
| 390 BailoutEntry entry = { ast_id, static_cast<unsigned>(masm_->pc_offset()) }; | 412 BailoutEntry entry = { ast_id, static_cast<unsigned>(masm_->pc_offset()) }; |
| 391 stack_checks_.Add(entry); | 413 stack_checks_.Add(entry); |
| 392 } | 414 } |
| 393 | 415 |
| 394 | 416 |
| 395 bool FullCodeGenerator::ShouldInlineSmiCase(Token::Value op) { | 417 bool FullCodeGenerator::ShouldInlineSmiCase(Token::Value op) { |
| (...skipping 906 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1302 } | 1324 } |
| 1303 | 1325 |
| 1304 return false; | 1326 return false; |
| 1305 } | 1327 } |
| 1306 | 1328 |
| 1307 | 1329 |
| 1308 #undef __ | 1330 #undef __ |
| 1309 | 1331 |
| 1310 | 1332 |
| 1311 } } // namespace v8::internal | 1333 } } // namespace v8::internal |
| OLD | NEW |