Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(449)

Side by Side Diff: src/full-codegen.cc

Issue 8932004: Implement target cache for constructor calls. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments by Vyacheslav Egorov and ported to x64 & ARM. Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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.PopulateCacheCells(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
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::PopulateCacheCells(Handle<Code> code) {
344 if (cache_cells_.is_empty()) return;
345 int length = cache_cells_.length();
346 Handle<CacheCells> cache = Handle<CacheCells>::cast(isolate()->factory()->
347 NewFixedArray(CacheCells::LengthOfFixedArray(length), TENURED));
348 for (int i = 0; i < length; i++) {
349 cache->SetAstId(i, Smi::FromInt(cache_cells_[i].id));
350 cache->SetCell(i, *cache_cells_[i].cell);
351 }
352 code->set_cache_cells(*cache);
353 }
354
355
356
343 void FullCodeGenerator::PrepareForBailout(Expression* node, State state) { 357 void FullCodeGenerator::PrepareForBailout(Expression* node, State state) {
344 PrepareForBailoutForId(node->id(), state); 358 PrepareForBailoutForId(node->id(), state);
345 } 359 }
346 360
347 361
348 void FullCodeGenerator::RecordJSReturnSite(Call* call) { 362 void FullCodeGenerator::RecordJSReturnSite(Call* call) {
349 // We record the offset of the function return so we can rebuild the frame 363 // 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 364 // if the function was inlined, i.e., this is the return address in the
351 // inlined function's frame. 365 // inlined function's frame.
352 // 366 //
(...skipping 23 matching lines...) Expand all
376 AstPrinter printer; 390 AstPrinter printer;
377 PrintF("%s", printer.PrintProgram(info_->function())); 391 PrintF("%s", printer.PrintProgram(info_->function()));
378 UNREACHABLE(); 392 UNREACHABLE();
379 } 393 }
380 } 394 }
381 #endif // DEBUG 395 #endif // DEBUG
382 bailout_entries_.Add(entry); 396 bailout_entries_.Add(entry);
383 } 397 }
384 398
385 399
400 void FullCodeGenerator::RecordCacheCell(unsigned id,
401 Handle<JSGlobalPropertyCell> cell) {
402 CacheCellEntry entry = { id, cell };
403 cache_cells_.Add(entry);
404 }
405
406
386 void FullCodeGenerator::RecordStackCheck(unsigned ast_id) { 407 void FullCodeGenerator::RecordStackCheck(unsigned ast_id) {
387 // The pc offset does not need to be encoded and packed together with a 408 // The pc offset does not need to be encoded and packed together with a
388 // state. 409 // state.
389 ASSERT(masm_->pc_offset() > 0); 410 ASSERT(masm_->pc_offset() > 0);
390 BailoutEntry entry = { ast_id, static_cast<unsigned>(masm_->pc_offset()) }; 411 BailoutEntry entry = { ast_id, static_cast<unsigned>(masm_->pc_offset()) };
391 stack_checks_.Add(entry); 412 stack_checks_.Add(entry);
392 } 413 }
393 414
394 415
395 bool FullCodeGenerator::ShouldInlineSmiCase(Token::Value op) { 416 bool FullCodeGenerator::ShouldInlineSmiCase(Token::Value op) {
(...skipping 906 matching lines...) Expand 10 before | Expand all | Expand 10 after
1302 } 1323 }
1303 1324
1304 return false; 1325 return false;
1305 } 1326 }
1306 1327
1307 1328
1308 #undef __ 1329 #undef __
1309 1330
1310 1331
1311 } } // namespace v8::internal 1332 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698