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

Side by Side Diff: src/debug.cc

Issue 224903005: Reland "create a function call IC" (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Comments. Created 6 years, 8 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
« no previous file with comments | « src/debug.h ('k') | src/full-codegen.h » ('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 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 bool BreakLocationIterator::IsStepInLocation(Isolate* isolate) { 399 bool BreakLocationIterator::IsStepInLocation(Isolate* isolate) {
400 if (RelocInfo::IsConstructCall(original_rmode())) { 400 if (RelocInfo::IsConstructCall(original_rmode())) {
401 return true; 401 return true;
402 } else if (RelocInfo::IsCodeTarget(rmode())) { 402 } else if (RelocInfo::IsCodeTarget(rmode())) {
403 HandleScope scope(debug_info_->GetIsolate()); 403 HandleScope scope(debug_info_->GetIsolate());
404 Address target = original_rinfo()->target_address(); 404 Address target = original_rinfo()->target_address();
405 Handle<Code> target_code(Code::GetCodeFromTargetAddress(target)); 405 Handle<Code> target_code(Code::GetCodeFromTargetAddress(target));
406 if (target_code->kind() == Code::STUB) { 406 if (target_code->kind() == Code::STUB) {
407 return target_code->major_key() == CodeStub::CallFunction; 407 return target_code->major_key() == CodeStub::CallFunction;
408 } 408 }
409 return target_code->is_call_stub();
409 } 410 }
410 return false; 411 return false;
411 } 412 }
412 413
413 414
414 void BreakLocationIterator::PrepareStepIn(Isolate* isolate) { 415 void BreakLocationIterator::PrepareStepIn(Isolate* isolate) {
415 #ifdef DEBUG 416 #ifdef DEBUG
416 HandleScope scope(isolate); 417 HandleScope scope(isolate);
417 // Step in can only be prepared if currently positioned on an IC call, 418 // Step in can only be prepared if currently positioned on an IC call,
418 // construct call or CallFunction stub call. 419 // construct call or CallFunction stub call.
(...skipping 999 matching lines...) Expand 10 before | Expand all | Expand 10 after
1418 bool is_load_or_store = false; 1419 bool is_load_or_store = false;
1419 bool is_inline_cache_stub = false; 1420 bool is_inline_cache_stub = false;
1420 bool is_at_restarted_function = false; 1421 bool is_at_restarted_function = false;
1421 Handle<Code> call_function_stub; 1422 Handle<Code> call_function_stub;
1422 1423
1423 if (thread_local_.restarter_frame_function_pointer_ == NULL) { 1424 if (thread_local_.restarter_frame_function_pointer_ == NULL) {
1424 if (RelocInfo::IsCodeTarget(it.rinfo()->rmode())) { 1425 if (RelocInfo::IsCodeTarget(it.rinfo()->rmode())) {
1425 bool is_call_target = false; 1426 bool is_call_target = false;
1426 Address target = it.rinfo()->target_address(); 1427 Address target = it.rinfo()->target_address();
1427 Code* code = Code::GetCodeFromTargetAddress(target); 1428 Code* code = Code::GetCodeFromTargetAddress(target);
1429 if (code->is_call_stub()) {
1430 is_call_target = true;
1431 }
1428 if (code->is_inline_cache_stub()) { 1432 if (code->is_inline_cache_stub()) {
1429 is_inline_cache_stub = true; 1433 is_inline_cache_stub = true;
1430 is_load_or_store = !is_call_target; 1434 is_load_or_store = !is_call_target;
1431 } 1435 }
1432 1436
1433 // Check if target code is CallFunction stub. 1437 // Check if target code is CallFunction stub.
1434 Code* maybe_call_function_stub = code; 1438 Code* maybe_call_function_stub = code;
1435 // If there is a breakpoint at this line look at the original code to 1439 // If there is a breakpoint at this line look at the original code to
1436 // check if it is a CallFunction stub. 1440 // check if it is a CallFunction stub.
1437 if (it.IsDebugBreak()) { 1441 if (it.IsDebugBreak()) {
1438 Address original_target = it.original_rinfo()->target_address(); 1442 Address original_target = it.original_rinfo()->target_address();
1439 maybe_call_function_stub = 1443 maybe_call_function_stub =
1440 Code::GetCodeFromTargetAddress(original_target); 1444 Code::GetCodeFromTargetAddress(original_target);
1441 } 1445 }
1442 if (maybe_call_function_stub->kind() == Code::STUB && 1446 if ((maybe_call_function_stub->kind() == Code::STUB &&
1443 maybe_call_function_stub->major_key() == CodeStub::CallFunction) { 1447 maybe_call_function_stub->major_key() == CodeStub::CallFunction) ||
1448 maybe_call_function_stub->kind() == Code::CALL_IC) {
1444 // Save reference to the code as we may need it to find out arguments 1449 // Save reference to the code as we may need it to find out arguments
1445 // count for 'step in' later. 1450 // count for 'step in' later.
1446 call_function_stub = Handle<Code>(maybe_call_function_stub); 1451 call_function_stub = Handle<Code>(maybe_call_function_stub);
1447 } 1452 }
1448 } 1453 }
1449 } else { 1454 } else {
1450 is_at_restarted_function = true; 1455 is_at_restarted_function = true;
1451 } 1456 }
1452 1457
1453 // If this is the last break code target step out is the only possibility. 1458 // If this is the last break code target step out is the only possibility.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1489 } else { 1494 } else {
1490 // If there's restarter frame on top of the stack, just get the pointer 1495 // If there's restarter frame on top of the stack, just get the pointer
1491 // to function which is going to be restarted. 1496 // to function which is going to be restarted.
1492 if (is_at_restarted_function) { 1497 if (is_at_restarted_function) {
1493 Handle<JSFunction> restarted_function( 1498 Handle<JSFunction> restarted_function(
1494 JSFunction::cast(*thread_local_.restarter_frame_function_pointer_)); 1499 JSFunction::cast(*thread_local_.restarter_frame_function_pointer_));
1495 FloodWithOneShot(restarted_function); 1500 FloodWithOneShot(restarted_function);
1496 } else if (!call_function_stub.is_null()) { 1501 } else if (!call_function_stub.is_null()) {
1497 // If it's CallFunction stub ensure target function is compiled and flood 1502 // If it's CallFunction stub ensure target function is compiled and flood
1498 // it with one shot breakpoints. 1503 // it with one shot breakpoints.
1504 bool is_call_ic = call_function_stub->kind() == Code::CALL_IC;
1499 1505
1500 // Find out number of arguments from the stub minor key. 1506 // Find out number of arguments from the stub minor key.
1501 // Reverse lookup required as the minor key cannot be retrieved 1507 // Reverse lookup required as the minor key cannot be retrieved
1502 // from the code object. 1508 // from the code object.
1503 Handle<Object> obj( 1509 Handle<Object> obj(
1504 isolate_->heap()->code_stubs()->SlowReverseLookup( 1510 isolate_->heap()->code_stubs()->SlowReverseLookup(
1505 *call_function_stub), 1511 *call_function_stub),
1506 isolate_); 1512 isolate_);
1507 ASSERT(!obj.is_null()); 1513 ASSERT(!obj.is_null());
1508 ASSERT(!(*obj)->IsUndefined()); 1514 ASSERT(!(*obj)->IsUndefined());
1509 ASSERT(obj->IsSmi()); 1515 ASSERT(obj->IsSmi());
1510 // Get the STUB key and extract major and minor key. 1516 // Get the STUB key and extract major and minor key.
1511 uint32_t key = Smi::cast(*obj)->value(); 1517 uint32_t key = Smi::cast(*obj)->value();
1512 // Argc in the stub is the number of arguments passed - not the 1518 // Argc in the stub is the number of arguments passed - not the
1513 // expected arguments of the called function. 1519 // expected arguments of the called function.
1514 int call_function_arg_count = 1520 int call_function_arg_count = is_call_ic
1515 CallFunctionStub::ExtractArgcFromMinorKey( 1521 ? CallICStub::ExtractArgcFromMinorKey(CodeStub::MinorKeyFromKey(key))
1522 : CallFunctionStub::ExtractArgcFromMinorKey(
1516 CodeStub::MinorKeyFromKey(key)); 1523 CodeStub::MinorKeyFromKey(key));
1517 ASSERT(call_function_stub->major_key() == 1524
1518 CodeStub::MajorKeyFromKey(key)); 1525 ASSERT(is_call_ic ||
1526 call_function_stub->major_key() == CodeStub::MajorKeyFromKey(key));
1519 1527
1520 // Find target function on the expression stack. 1528 // Find target function on the expression stack.
1521 // Expression stack looks like this (top to bottom): 1529 // Expression stack looks like this (top to bottom):
1522 // argN 1530 // argN
1523 // ... 1531 // ...
1524 // arg0 1532 // arg0
1525 // Receiver 1533 // Receiver
1526 // Function to call 1534 // Function to call
1527 int expressions_count = frame->ComputeExpressionsCount(); 1535 int expressions_count = frame->ComputeExpressionsCount();
1528 ASSERT(expressions_count - 2 - call_function_arg_count >= 0); 1536 ASSERT(expressions_count - 2 - call_function_arg_count >= 0);
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
1636 1644
1637 1645
1638 // Find the builtin to use for invoking the debug break 1646 // Find the builtin to use for invoking the debug break
1639 Handle<Code> Debug::FindDebugBreak(Handle<Code> code, RelocInfo::Mode mode) { 1647 Handle<Code> Debug::FindDebugBreak(Handle<Code> code, RelocInfo::Mode mode) {
1640 Isolate* isolate = code->GetIsolate(); 1648 Isolate* isolate = code->GetIsolate();
1641 1649
1642 // Find the builtin debug break function matching the calling convention 1650 // Find the builtin debug break function matching the calling convention
1643 // used by the call site. 1651 // used by the call site.
1644 if (code->is_inline_cache_stub()) { 1652 if (code->is_inline_cache_stub()) {
1645 switch (code->kind()) { 1653 switch (code->kind()) {
1654 case Code::CALL_IC:
1655 return isolate->builtins()->CallICStub_DebugBreak();
1656
1646 case Code::LOAD_IC: 1657 case Code::LOAD_IC:
1647 return isolate->builtins()->LoadIC_DebugBreak(); 1658 return isolate->builtins()->LoadIC_DebugBreak();
1648 1659
1649 case Code::STORE_IC: 1660 case Code::STORE_IC:
1650 return isolate->builtins()->StoreIC_DebugBreak(); 1661 return isolate->builtins()->StoreIC_DebugBreak();
1651 1662
1652 case Code::KEYED_LOAD_IC: 1663 case Code::KEYED_LOAD_IC:
1653 return isolate->builtins()->KeyedLoadIC_DebugBreak(); 1664 return isolate->builtins()->KeyedLoadIC_DebugBreak();
1654 1665
1655 case Code::KEYED_STORE_IC: 1666 case Code::KEYED_STORE_IC:
1656 return isolate->builtins()->KeyedStoreIC_DebugBreak(); 1667 return isolate->builtins()->KeyedStoreIC_DebugBreak();
1657 1668
1658 case Code::COMPARE_NIL_IC: 1669 case Code::COMPARE_NIL_IC:
1659 return isolate->builtins()->CompareNilIC_DebugBreak(); 1670 return isolate->builtins()->CompareNilIC_DebugBreak();
1660 1671
1661 default: 1672 default:
1662 UNREACHABLE(); 1673 UNREACHABLE();
1663 } 1674 }
1664 } 1675 }
1665 if (RelocInfo::IsConstructCall(mode)) { 1676 if (RelocInfo::IsConstructCall(mode)) {
1666 if (code->has_function_cache()) { 1677 if (code->has_function_cache()) {
1667 return isolate->builtins()->CallConstructStub_Recording_DebugBreak(); 1678 return isolate->builtins()->CallConstructStub_Recording_DebugBreak();
1668 } else { 1679 } else {
1669 return isolate->builtins()->CallConstructStub_DebugBreak(); 1680 return isolate->builtins()->CallConstructStub_DebugBreak();
1670 } 1681 }
1671 } 1682 }
1672 if (code->kind() == Code::STUB) { 1683 if (code->kind() == Code::STUB) {
1673 ASSERT(code->major_key() == CodeStub::CallFunction); 1684 ASSERT(code->major_key() == CodeStub::CallFunction);
1674 if (code->has_function_cache()) { 1685 return isolate->builtins()->CallFunctionStub_DebugBreak();
1675 return isolate->builtins()->CallFunctionStub_Recording_DebugBreak();
1676 } else {
1677 return isolate->builtins()->CallFunctionStub_DebugBreak();
1678 }
1679 } 1686 }
1680 1687
1681 UNREACHABLE(); 1688 UNREACHABLE();
1682 return Handle<Code>::null(); 1689 return Handle<Code>::null();
1683 } 1690 }
1684 1691
1685 1692
1686 // Simple function for returning the source positions for active break points. 1693 // Simple function for returning the source positions for active break points.
1687 Handle<Object> Debug::GetSourceBreakLocations( 1694 Handle<Object> Debug::GetSourceBreakLocations(
1688 Handle<SharedFunctionInfo> shared, 1695 Handle<SharedFunctionInfo> shared,
(...skipping 2122 matching lines...) Expand 10 before | Expand all | Expand 10 after
3811 { 3818 {
3812 Locker locker(reinterpret_cast<v8::Isolate*>(isolate_)); 3819 Locker locker(reinterpret_cast<v8::Isolate*>(isolate_));
3813 isolate_->debugger()->CallMessageDispatchHandler(); 3820 isolate_->debugger()->CallMessageDispatchHandler();
3814 } 3821 }
3815 } 3822 }
3816 } 3823 }
3817 3824
3818 #endif // ENABLE_DEBUGGER_SUPPORT 3825 #endif // ENABLE_DEBUGGER_SUPPORT
3819 3826
3820 } } // namespace v8::internal 3827 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/debug.h ('k') | src/full-codegen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698