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

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

Issue 112863002: Merge bleeding_edge 18021:18297 (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Created 7 years 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
« no previous file with comments | « src/arm/frames-arm.h ('k') | src/arm/ic-arm.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 void FullCodeGenerator::EmitProfilingCounterDecrement(int delta) { 327 void FullCodeGenerator::EmitProfilingCounterDecrement(int delta) {
328 __ mov(r2, Operand(profiling_counter_)); 328 __ mov(r2, Operand(profiling_counter_));
329 __ ldr(r3, FieldMemOperand(r2, Cell::kValueOffset)); 329 __ ldr(r3, FieldMemOperand(r2, Cell::kValueOffset));
330 __ sub(r3, r3, Operand(Smi::FromInt(delta)), SetCC); 330 __ sub(r3, r3, Operand(Smi::FromInt(delta)), SetCC);
331 __ str(r3, FieldMemOperand(r2, Cell::kValueOffset)); 331 __ str(r3, FieldMemOperand(r2, Cell::kValueOffset));
332 } 332 }
333 333
334 334
335 void FullCodeGenerator::EmitProfilingCounterReset() { 335 void FullCodeGenerator::EmitProfilingCounterReset() {
336 int reset_value = FLAG_interrupt_budget; 336 int reset_value = FLAG_interrupt_budget;
337 if (info_->ShouldSelfOptimize() && !FLAG_retry_self_opt) {
338 // Self-optimization is a one-off thing: if it fails, don't try again.
339 reset_value = Smi::kMaxValue;
340 }
341 if (isolate()->IsDebuggerActive()) { 337 if (isolate()->IsDebuggerActive()) {
342 // Detect debug break requests as soon as possible. 338 // Detect debug break requests as soon as possible.
343 reset_value = FLAG_interrupt_budget >> 4; 339 reset_value = FLAG_interrupt_budget >> 4;
344 } 340 }
345 __ mov(r2, Operand(profiling_counter_)); 341 __ mov(r2, Operand(profiling_counter_));
346 __ mov(r3, Operand(Smi::FromInt(reset_value))); 342 __ mov(r3, Operand(Smi::FromInt(reset_value)));
347 __ str(r3, FieldMemOperand(r2, Cell::kValueOffset)); 343 __ str(r3, FieldMemOperand(r2, Cell::kValueOffset));
348 } 344 }
349 345
350 346
351 void FullCodeGenerator::EmitBackEdgeBookkeeping(IterationStatement* stmt, 347 void FullCodeGenerator::EmitBackEdgeBookkeeping(IterationStatement* stmt,
352 Label* back_edge_target) { 348 Label* back_edge_target) {
353 Comment cmnt(masm_, "[ Back edge bookkeeping"); 349 Comment cmnt(masm_, "[ Back edge bookkeeping");
354 // Block literal pools whilst emitting back edge code. 350 // Block literal pools whilst emitting back edge code.
355 Assembler::BlockConstPoolScope block_const_pool(masm_); 351 Assembler::BlockConstPoolScope block_const_pool(masm_);
356 Label ok; 352 Label ok;
357 353
358 int weight = 1; 354 ASSERT(back_edge_target->is_bound());
359 if (FLAG_weighted_back_edges) { 355 int distance = masm_->SizeOfCodeGeneratedSince(back_edge_target);
360 ASSERT(back_edge_target->is_bound()); 356 int weight = Min(kMaxBackEdgeWeight,
361 int distance = masm_->SizeOfCodeGeneratedSince(back_edge_target); 357 Max(1, distance / kCodeSizeMultiplier));
362 weight = Min(kMaxBackEdgeWeight,
363 Max(1, distance / kCodeSizeMultiplier));
364 }
365 EmitProfilingCounterDecrement(weight); 358 EmitProfilingCounterDecrement(weight);
366 __ b(pl, &ok); 359 __ b(pl, &ok);
367 __ Call(isolate()->builtins()->InterruptCheck(), RelocInfo::CODE_TARGET); 360 __ Call(isolate()->builtins()->InterruptCheck(), RelocInfo::CODE_TARGET);
368 361
369 // Record a mapping of this PC offset to the OSR id. This is used to find 362 // Record a mapping of this PC offset to the OSR id. This is used to find
370 // the AST id from the unoptimized code in order to use it as a key into 363 // the AST id from the unoptimized code in order to use it as a key into
371 // the deoptimization input data found in the optimized code. 364 // the deoptimization input data found in the optimized code.
372 RecordBackEdge(stmt->OsrEntryId()); 365 RecordBackEdge(stmt->OsrEntryId());
373 366
374 EmitProfilingCounterReset(); 367 EmitProfilingCounterReset();
(...skipping 12 matching lines...) Expand all
387 if (return_label_.is_bound()) { 380 if (return_label_.is_bound()) {
388 __ b(&return_label_); 381 __ b(&return_label_);
389 } else { 382 } else {
390 __ bind(&return_label_); 383 __ bind(&return_label_);
391 if (FLAG_trace) { 384 if (FLAG_trace) {
392 // Push the return value on the stack as the parameter. 385 // Push the return value on the stack as the parameter.
393 // Runtime::TraceExit returns its parameter in r0. 386 // Runtime::TraceExit returns its parameter in r0.
394 __ push(r0); 387 __ push(r0);
395 __ CallRuntime(Runtime::kTraceExit, 1); 388 __ CallRuntime(Runtime::kTraceExit, 1);
396 } 389 }
397 if (FLAG_interrupt_at_exit || FLAG_self_optimization) { 390 // Pretend that the exit is a backwards jump to the entry.
398 // Pretend that the exit is a backwards jump to the entry. 391 int weight = 1;
399 int weight = 1; 392 if (info_->ShouldSelfOptimize()) {
400 if (info_->ShouldSelfOptimize()) { 393 weight = FLAG_interrupt_budget / FLAG_self_opt_count;
401 weight = FLAG_interrupt_budget / FLAG_self_opt_count; 394 } else {
402 } else if (FLAG_weighted_back_edges) { 395 int distance = masm_->pc_offset();
403 int distance = masm_->pc_offset(); 396 weight = Min(kMaxBackEdgeWeight,
404 weight = Min(kMaxBackEdgeWeight, 397 Max(1, distance / kCodeSizeMultiplier));
405 Max(1, distance / kCodeSizeMultiplier));
406 }
407 EmitProfilingCounterDecrement(weight);
408 Label ok;
409 __ b(pl, &ok);
410 __ push(r0);
411 if (info_->ShouldSelfOptimize() && FLAG_direct_self_opt) {
412 __ ldr(r2, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
413 __ push(r2);
414 __ CallRuntime(Runtime::kOptimizeFunctionOnNextCall, 1);
415 } else {
416 __ Call(isolate()->builtins()->InterruptCheck(),
417 RelocInfo::CODE_TARGET);
418 }
419 __ pop(r0);
420 EmitProfilingCounterReset();
421 __ bind(&ok);
422 } 398 }
399 EmitProfilingCounterDecrement(weight);
400 Label ok;
401 __ b(pl, &ok);
402 __ push(r0);
403 __ Call(isolate()->builtins()->InterruptCheck(),
404 RelocInfo::CODE_TARGET);
405 __ pop(r0);
406 EmitProfilingCounterReset();
407 __ bind(&ok);
423 408
424 #ifdef DEBUG 409 #ifdef DEBUG
425 // Add a label for checking the size of the code used for returning. 410 // Add a label for checking the size of the code used for returning.
426 Label check_exit_codesize; 411 Label check_exit_codesize;
427 masm_->bind(&check_exit_codesize); 412 masm_->bind(&check_exit_codesize);
428 #endif 413 #endif
429 // Make sure that the constant pool is not emitted inside of the return 414 // Make sure that the constant pool is not emitted inside of the return
430 // sequence. 415 // sequence.
431 { Assembler::BlockConstPoolScope block_const_pool(masm_); 416 { Assembler::BlockConstPoolScope block_const_pool(masm_);
432 // Here we use masm_-> instead of the __ macro to avoid the code coverage 417 // Here we use masm_-> instead of the __ macro to avoid the code coverage
(...skipping 1330 matching lines...) Expand 10 before | Expand all | Expand 10 after
1763 } else { 1748 } else {
1764 context()->Plug(r0); 1749 context()->Plug(r0);
1765 } 1750 }
1766 } 1751 }
1767 1752
1768 1753
1769 void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) { 1754 void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) {
1770 Comment cmnt(masm_, "[ ArrayLiteral"); 1755 Comment cmnt(masm_, "[ ArrayLiteral");
1771 1756
1772 expr->BuildConstantElements(isolate()); 1757 expr->BuildConstantElements(isolate());
1758 int flags = expr->depth() == 1
1759 ? ArrayLiteral::kShallowElements
1760 : ArrayLiteral::kNoFlags;
1761
1773 ZoneList<Expression*>* subexprs = expr->values(); 1762 ZoneList<Expression*>* subexprs = expr->values();
1774 int length = subexprs->length(); 1763 int length = subexprs->length();
1775 Handle<FixedArray> constant_elements = expr->constant_elements(); 1764 Handle<FixedArray> constant_elements = expr->constant_elements();
1776 ASSERT_EQ(2, constant_elements->length()); 1765 ASSERT_EQ(2, constant_elements->length());
1777 ElementsKind constant_elements_kind = 1766 ElementsKind constant_elements_kind =
1778 static_cast<ElementsKind>(Smi::cast(constant_elements->get(0))->value()); 1767 static_cast<ElementsKind>(Smi::cast(constant_elements->get(0))->value());
1779 bool has_fast_elements = IsFastObjectElementsKind(constant_elements_kind); 1768 bool has_fast_elements = IsFastObjectElementsKind(constant_elements_kind);
1780 Handle<FixedArrayBase> constant_elements_values( 1769 Handle<FixedArrayBase> constant_elements_values(
1781 FixedArrayBase::cast(constant_elements->get(1))); 1770 FixedArrayBase::cast(constant_elements->get(1)));
1782 1771
1772 AllocationSiteMode allocation_site_mode = FLAG_track_allocation_sites
1773 ? TRACK_ALLOCATION_SITE : DONT_TRACK_ALLOCATION_SITE;
1774 if (has_fast_elements && !FLAG_allocation_site_pretenuring) {
1775 // If the only customer of allocation sites is transitioning, then
1776 // we can turn it off if we don't have anywhere else to transition to.
1777 allocation_site_mode = DONT_TRACK_ALLOCATION_SITE;
1778 }
1779
1783 __ ldr(r3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); 1780 __ ldr(r3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
1784 __ ldr(r3, FieldMemOperand(r3, JSFunction::kLiteralsOffset)); 1781 __ ldr(r3, FieldMemOperand(r3, JSFunction::kLiteralsOffset));
1785 __ mov(r2, Operand(Smi::FromInt(expr->literal_index()))); 1782 __ mov(r2, Operand(Smi::FromInt(expr->literal_index())));
1786 __ mov(r1, Operand(constant_elements)); 1783 __ mov(r1, Operand(constant_elements));
1787 if (has_fast_elements && constant_elements_values->map() == 1784 if (has_fast_elements && constant_elements_values->map() ==
1788 isolate()->heap()->fixed_cow_array_map()) { 1785 isolate()->heap()->fixed_cow_array_map()) {
1789 FastCloneShallowArrayStub stub( 1786 FastCloneShallowArrayStub stub(
1790 FastCloneShallowArrayStub::COPY_ON_WRITE_ELEMENTS, 1787 FastCloneShallowArrayStub::COPY_ON_WRITE_ELEMENTS,
1791 DONT_TRACK_ALLOCATION_SITE, 1788 allocation_site_mode,
1792 length); 1789 length);
1793 __ CallStub(&stub); 1790 __ CallStub(&stub);
1794 __ IncrementCounter( 1791 __ IncrementCounter(
1795 isolate()->counters()->cow_arrays_created_stub(), 1, r1, r2); 1792 isolate()->counters()->cow_arrays_created_stub(), 1, r1, r2);
1796 } else if (expr->depth() > 1 || Serializer::enabled() || 1793 } else if (expr->depth() > 1 || Serializer::enabled() ||
1797 length > FastCloneShallowArrayStub::kMaximumClonedLength) { 1794 length > FastCloneShallowArrayStub::kMaximumClonedLength) {
1798 __ Push(r3, r2, r1); 1795 __ mov(r0, Operand(Smi::FromInt(flags)));
1799 __ CallRuntime(Runtime::kCreateArrayLiteral, 3); 1796 __ Push(r3, r2, r1, r0);
1797 __ CallRuntime(Runtime::kCreateArrayLiteral, 4);
1800 } else { 1798 } else {
1801 ASSERT(IsFastSmiOrObjectElementsKind(constant_elements_kind) || 1799 ASSERT(IsFastSmiOrObjectElementsKind(constant_elements_kind) ||
1802 FLAG_smi_only_arrays); 1800 FLAG_smi_only_arrays);
1803 FastCloneShallowArrayStub::Mode mode = 1801 FastCloneShallowArrayStub::Mode mode =
1804 FastCloneShallowArrayStub::CLONE_ANY_ELEMENTS; 1802 FastCloneShallowArrayStub::CLONE_ANY_ELEMENTS;
1805 AllocationSiteMode allocation_site_mode = FLAG_track_allocation_sites
1806 ? TRACK_ALLOCATION_SITE : DONT_TRACK_ALLOCATION_SITE;
1807 1803
1808 if (has_fast_elements) { 1804 if (has_fast_elements) {
1809 mode = FastCloneShallowArrayStub::CLONE_ELEMENTS; 1805 mode = FastCloneShallowArrayStub::CLONE_ELEMENTS;
1810 allocation_site_mode = DONT_TRACK_ALLOCATION_SITE;
1811 } 1806 }
1812 1807
1813 FastCloneShallowArrayStub stub(mode, allocation_site_mode, length); 1808 FastCloneShallowArrayStub stub(mode, allocation_site_mode, length);
1814 __ CallStub(&stub); 1809 __ CallStub(&stub);
1815 } 1810 }
1816 1811
1817 bool result_saved = false; // Is the result saved to the stack? 1812 bool result_saved = false; // Is the result saved to the stack?
1818 1813
1819 // Emit code to evaluate all the non-constant subexpressions and to store 1814 // Emit code to evaluate all the non-constant subexpressions and to store
1820 // them into the newly cloned array. 1815 // them into the newly cloned array.
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
2281 Register right = r0; 2276 Register right = r0;
2282 __ pop(left); 2277 __ pop(left);
2283 2278
2284 // Perform combined smi check on both operands. 2279 // Perform combined smi check on both operands.
2285 __ orr(scratch1, left, Operand(right)); 2280 __ orr(scratch1, left, Operand(right));
2286 STATIC_ASSERT(kSmiTag == 0); 2281 STATIC_ASSERT(kSmiTag == 0);
2287 JumpPatchSite patch_site(masm_); 2282 JumpPatchSite patch_site(masm_);
2288 patch_site.EmitJumpIfSmi(scratch1, &smi_case); 2283 patch_site.EmitJumpIfSmi(scratch1, &smi_case);
2289 2284
2290 __ bind(&stub_call); 2285 __ bind(&stub_call);
2291 BinaryOpStub stub(op, mode); 2286 BinaryOpICStub stub(op, mode);
2292 CallIC(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, 2287 CallIC(stub.GetCode(isolate()), RelocInfo::CODE_TARGET,
2293 expr->BinaryOperationFeedbackId()); 2288 expr->BinaryOperationFeedbackId());
2294 patch_site.EmitPatchInfo(); 2289 patch_site.EmitPatchInfo();
2295 __ jmp(&done); 2290 __ jmp(&done);
2296 2291
2297 __ bind(&smi_case); 2292 __ bind(&smi_case);
2298 // Smi case. This code works the same way as the smi-smi case in the type 2293 // Smi case. This code works the same way as the smi-smi case in the type
2299 // recording binary operation stub, see 2294 // recording binary operation stub, see
2300 // BinaryOpStub::GenerateSmiSmiOperation for comments.
2301 switch (op) { 2295 switch (op) {
2302 case Token::SAR: 2296 case Token::SAR:
2303 __ GetLeastBitsFromSmi(scratch1, right, 5); 2297 __ GetLeastBitsFromSmi(scratch1, right, 5);
2304 __ mov(right, Operand(left, ASR, scratch1)); 2298 __ mov(right, Operand(left, ASR, scratch1));
2305 __ bic(right, right, Operand(kSmiTagMask)); 2299 __ bic(right, right, Operand(kSmiTagMask));
2306 break; 2300 break;
2307 case Token::SHL: { 2301 case Token::SHL: {
2308 __ SmiUntag(scratch1, left); 2302 __ SmiUntag(scratch1, left);
2309 __ GetLeastBitsFromSmi(scratch2, right, 5); 2303 __ GetLeastBitsFromSmi(scratch2, right, 5);
2310 __ mov(scratch1, Operand(scratch1, LSL, scratch2)); 2304 __ mov(scratch1, Operand(scratch1, LSL, scratch2));
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
2359 2353
2360 __ bind(&done); 2354 __ bind(&done);
2361 context()->Plug(r0); 2355 context()->Plug(r0);
2362 } 2356 }
2363 2357
2364 2358
2365 void FullCodeGenerator::EmitBinaryOp(BinaryOperation* expr, 2359 void FullCodeGenerator::EmitBinaryOp(BinaryOperation* expr,
2366 Token::Value op, 2360 Token::Value op,
2367 OverwriteMode mode) { 2361 OverwriteMode mode) {
2368 __ pop(r1); 2362 __ pop(r1);
2369 BinaryOpStub stub(op, mode); 2363 BinaryOpICStub stub(op, mode);
2370 JumpPatchSite patch_site(masm_); // unbound, signals no inlined smi code. 2364 JumpPatchSite patch_site(masm_); // unbound, signals no inlined smi code.
2371 CallIC(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, 2365 CallIC(stub.GetCode(isolate()), RelocInfo::CODE_TARGET,
2372 expr->BinaryOperationFeedbackId()); 2366 expr->BinaryOperationFeedbackId());
2373 patch_site.EmitPatchInfo(); 2367 patch_site.EmitPatchInfo();
2374 context()->Plug(r0); 2368 context()->Plug(r0);
2375 } 2369 }
2376 2370
2377 2371
2378 void FullCodeGenerator::EmitAssignment(Expression* expr) { 2372 void FullCodeGenerator::EmitAssignment(Expression* expr) {
2379 // Invalid left-hand sides are rewritten by the parser to have a 'throw 2373 // Invalid left-hand sides are rewritten by the parser to have a 'throw
(...skipping 2019 matching lines...) Expand 10 before | Expand all | Expand 10 after
4399 } 4393 }
4400 4394
4401 4395
4402 __ bind(&stub_call); 4396 __ bind(&stub_call);
4403 __ mov(r1, r0); 4397 __ mov(r1, r0);
4404 __ mov(r0, Operand(Smi::FromInt(count_value))); 4398 __ mov(r0, Operand(Smi::FromInt(count_value)));
4405 4399
4406 // Record position before stub call. 4400 // Record position before stub call.
4407 SetSourcePosition(expr->position()); 4401 SetSourcePosition(expr->position());
4408 4402
4409 BinaryOpStub stub(Token::ADD, NO_OVERWRITE); 4403 BinaryOpICStub stub(Token::ADD, NO_OVERWRITE);
4410 CallIC(stub.GetCode(isolate()), 4404 CallIC(stub.GetCode(isolate()),
4411 RelocInfo::CODE_TARGET, 4405 RelocInfo::CODE_TARGET,
4412 expr->CountBinOpFeedbackId()); 4406 expr->CountBinOpFeedbackId());
4413 patch_site.EmitPatchInfo(); 4407 patch_site.EmitPatchInfo();
4414 __ bind(&done); 4408 __ bind(&done);
4415 4409
4416 // Store the value returned in r0. 4410 // Store the value returned in r0.
4417 switch (assign_type) { 4411 switch (assign_type) {
4418 case VARIABLE: 4412 case VARIABLE:
4419 if (expr->is_postfix()) { 4413 if (expr->is_postfix()) {
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
4919 ASSERT(Memory::uint32_at(interrupt_address_pointer) == 4913 ASSERT(Memory::uint32_at(interrupt_address_pointer) ==
4920 reinterpret_cast<uint32_t>( 4914 reinterpret_cast<uint32_t>(
4921 isolate->builtins()->OsrAfterStackCheck()->entry())); 4915 isolate->builtins()->OsrAfterStackCheck()->entry()));
4922 return OSR_AFTER_STACK_CHECK; 4916 return OSR_AFTER_STACK_CHECK;
4923 } 4917 }
4924 4918
4925 4919
4926 } } // namespace v8::internal 4920 } } // namespace v8::internal
4927 4921
4928 #endif // V8_TARGET_ARCH_ARM 4922 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « src/arm/frames-arm.h ('k') | src/arm/ic-arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698