| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 StackFrameIterator it; | 93 StackFrameIterator it; |
| 94 for (int i = 0; i < depth + 1; i++) it.Advance(); | 94 for (int i = 0; i < depth + 1; i++) it.Advance(); |
| 95 StackFrame* frame = it.frame(); | 95 StackFrame* frame = it.frame(); |
| 96 ASSERT(fp == frame->fp() && pc_address == frame->pc_address()); | 96 ASSERT(fp == frame->fp() && pc_address == frame->pc_address()); |
| 97 #endif | 97 #endif |
| 98 fp_ = fp; | 98 fp_ = fp; |
| 99 pc_address_ = pc_address; | 99 pc_address_ = pc_address; |
| 100 } | 100 } |
| 101 | 101 |
| 102 | 102 |
| 103 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 103 Address IC::OriginalCodeAddress() { | 104 Address IC::OriginalCodeAddress() { |
| 104 HandleScope scope; | 105 HandleScope scope; |
| 105 // Compute the JavaScript frame for the frame pointer of this IC | 106 // Compute the JavaScript frame for the frame pointer of this IC |
| 106 // structure. We need this to be able to find the function | 107 // structure. We need this to be able to find the function |
| 107 // corresponding to the frame. | 108 // corresponding to the frame. |
| 108 StackFrameIterator it; | 109 StackFrameIterator it; |
| 109 while (it.frame()->fp() != this->fp()) it.Advance(); | 110 while (it.frame()->fp() != this->fp()) it.Advance(); |
| 110 JavaScriptFrame* frame = JavaScriptFrame::cast(it.frame()); | 111 JavaScriptFrame* frame = JavaScriptFrame::cast(it.frame()); |
| 111 // Find the function on the stack and both the active code for the | 112 // Find the function on the stack and both the active code for the |
| 112 // function and the original code. | 113 // function and the original code. |
| 113 JSFunction* function = JSFunction::cast(frame->function()); | 114 JSFunction* function = JSFunction::cast(frame->function()); |
| 114 Handle<SharedFunctionInfo> shared(function->shared()); | 115 Handle<SharedFunctionInfo> shared(function->shared()); |
| 115 Code* code = shared->code(); | 116 Code* code = shared->code(); |
| 116 ASSERT(Debug::HasDebugInfo(shared)); | 117 ASSERT(Debug::HasDebugInfo(shared)); |
| 117 Code* original_code = Debug::GetDebugInfo(shared)->original_code(); | 118 Code* original_code = Debug::GetDebugInfo(shared)->original_code(); |
| 118 ASSERT(original_code->IsCode()); | 119 ASSERT(original_code->IsCode()); |
| 119 // Get the address of the call site in the active code. This is the | 120 // Get the address of the call site in the active code. This is the |
| 120 // place where the call to DebugBreakXXX is and where the IC | 121 // place where the call to DebugBreakXXX is and where the IC |
| 121 // normally would be. | 122 // normally would be. |
| 122 Address addr = pc() - Assembler::kTargetAddrToReturnAddrDist; | 123 Address addr = pc() - Assembler::kTargetAddrToReturnAddrDist; |
| 123 // Return the address in the original code. This is the place where | 124 // Return the address in the original code. This is the place where |
| 124 // the call which has been overwritten by the DebugBreakXXX resides | 125 // the call which has been overwritten by the DebugBreakXXX resides |
| 125 // and the place where the inline cache system should look. | 126 // and the place where the inline cache system should look. |
| 126 int delta = original_code->instruction_start() - code->instruction_start(); | 127 int delta = original_code->instruction_start() - code->instruction_start(); |
| 127 return addr + delta; | 128 return addr + delta; |
| 128 } | 129 } |
| 129 | 130 #endif |
| 130 | 131 |
| 131 IC::State IC::StateFrom(Code* target, Object* receiver) { | 132 IC::State IC::StateFrom(Code* target, Object* receiver) { |
| 132 IC::State state = target->ic_state(); | 133 IC::State state = target->ic_state(); |
| 133 | 134 |
| 134 if (state != MONOMORPHIC) return state; | 135 if (state != MONOMORPHIC) return state; |
| 135 if (receiver->IsUndefined() || receiver->IsNull()) return state; | 136 if (receiver->IsUndefined() || receiver->IsNull()) return state; |
| 136 | 137 |
| 137 Map* map = GetCodeCacheMapForObject(receiver); | 138 Map* map = GetCodeCacheMapForObject(receiver); |
| 138 | 139 |
| 139 // Decide whether the inline cache failed because of changes to the | 140 // Decide whether the inline cache failed because of changes to the |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 // Ignored this will degrade performance for Array.prototype.{push,pop}. | 350 // Ignored this will degrade performance for Array.prototype.{push,pop}. |
| 350 // Please note we only return the optimized function iff | 351 // Please note we only return the optimized function iff |
| 351 // the JSObject has FastElements. | 352 // the JSObject has FastElements. |
| 352 if (object->IsJSObject() && JSObject::cast(*object)->HasFastElements()) { | 353 if (object->IsJSObject() && JSObject::cast(*object)->HasFastElements()) { |
| 353 Object* opt = Top::LookupSpecialFunction(JSObject::cast(*object), | 354 Object* opt = Top::LookupSpecialFunction(JSObject::cast(*object), |
| 354 lookup.holder(), | 355 lookup.holder(), |
| 355 JSFunction::cast(result)); | 356 JSFunction::cast(result)); |
| 356 if (opt->IsJSFunction()) return opt; | 357 if (opt->IsJSFunction()) return opt; |
| 357 } | 358 } |
| 358 | 359 |
| 360 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 359 // Handle stepping into a function if step into is active. | 361 // Handle stepping into a function if step into is active. |
| 360 if (Debug::StepInActive()) { | 362 if (Debug::StepInActive()) { |
| 361 // Protect the result in a handle as the debugger can allocate and might | 363 // Protect the result in a handle as the debugger can allocate and might |
| 362 // cause GC. | 364 // cause GC. |
| 363 HandleScope scope; | 365 HandleScope scope; |
| 364 Handle<JSFunction> function(JSFunction::cast(result)); | 366 Handle<JSFunction> function(JSFunction::cast(result)); |
| 365 Debug::HandleStepIn(function, fp(), false); | 367 Debug::HandleStepIn(function, fp(), false); |
| 366 return *function; | 368 return *function; |
| 367 } | 369 } |
| 370 #endif |
| 368 | 371 |
| 369 return result; | 372 return result; |
| 370 } | 373 } |
| 371 | 374 |
| 372 // Try to find a suitable function delegate for the object at hand. | 375 // Try to find a suitable function delegate for the object at hand. |
| 373 result = TryCallAsFunction(result); | 376 result = TryCallAsFunction(result); |
| 374 return result->IsJSFunction() ? | 377 return result->IsJSFunction() ? |
| 375 result : TypeError("property_not_function", object, name); | 378 result : TypeError("property_not_function", object, name); |
| 376 } | 379 } |
| 377 | 380 |
| (...skipping 831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1209 #undef ADDR | 1212 #undef ADDR |
| 1210 }; | 1213 }; |
| 1211 | 1214 |
| 1212 | 1215 |
| 1213 Address IC::AddressFromUtilityId(IC::UtilityId id) { | 1216 Address IC::AddressFromUtilityId(IC::UtilityId id) { |
| 1214 return IC_utilities[id]; | 1217 return IC_utilities[id]; |
| 1215 } | 1218 } |
| 1216 | 1219 |
| 1217 | 1220 |
| 1218 } } // namespace v8::internal | 1221 } } // namespace v8::internal |
| OLD | NEW |