| OLD | NEW |
| 1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 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 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 void VirtualFrame::SpillAll() { | 243 void VirtualFrame::SpillAll() { |
| 244 for (int i = 0; i < elements_.length(); i++) { | 244 for (int i = 0; i < elements_.length(); i++) { |
| 245 SpillElementAt(i); | 245 SpillElementAt(i); |
| 246 } | 246 } |
| 247 } | 247 } |
| 248 | 248 |
| 249 | 249 |
| 250 void VirtualFrame::PrepareForCall(int frame_arg_count) { | 250 void VirtualFrame::PrepareForCall(int frame_arg_count) { |
| 251 ASSERT(height() >= frame_arg_count); | 251 ASSERT(height() >= frame_arg_count); |
| 252 | 252 |
| 253 // Below the stack pointer, spill all registers and make sure that | 253 // Below the arguments to the function being called, spill all registers and |
| 254 // locals have the right values by sync'ing them. The sync'ing is | 254 // make sure that locals have the right values by synching them. The synching |
| 255 // necessary to give the debugger a consistent view of the values of | 255 // is necessary to give the debugger a consistent view of the values of |
| 256 // locals in the frame. | 256 // locals in the frame. Spill the arguments to the function being called. |
| 257 for (int i = 0; i <= stack_pointer_; i++) { | 257 int arg_base_index = elements_.length() - frame_arg_count; |
| 258 for (int i = 0; i < arg_base_index; i++) { |
| 258 FrameElement element = elements_[i]; | 259 FrameElement element = elements_[i]; |
| 259 if (element.is_register()) { | 260 if (element.is_register()) { |
| 260 SpillElementAt(i); | 261 SpillElementAt(i); |
| 261 } else if (element.is_valid() && i < expression_base_index()) { | 262 } else if (element.is_valid()) { |
| 262 SyncElementAt(i); | 263 SyncElementAt(i); |
| 263 } | 264 } |
| 264 } | 265 } |
| 265 | 266 // The arguments are spilled. |
| 266 // Above the stack pointer, spill registers and sync everything else (ie, | 267 for (int i = arg_base_index; i < elements_.length(); i++) { |
| 267 // constants). | 268 SpillElementAt(i); |
| 268 for (int i = stack_pointer_ + 1; i < elements_.length(); i++) { | |
| 269 if (elements_[i].is_register()) { | |
| 270 SpillElementAt(i); | |
| 271 } else { | |
| 272 SyncElementAt(i); | |
| 273 } | |
| 274 } | 269 } |
| 275 | 270 |
| 276 // Forget the frame elements that will be popped by the call. | 271 // Forget the frame elements that will be popped by the call. |
| 277 Forget(frame_arg_count); | 272 Forget(frame_arg_count); |
| 278 } | 273 } |
| 279 | 274 |
| 280 | 275 |
| 281 bool VirtualFrame::RequiresMergeCode() { | 276 bool VirtualFrame::RequiresMergeCode() { |
| 282 // A frame requires code to be generated to make the frame mergable if | 277 // A frame requires code to be generated to make the frame mergable if |
| 283 // there are duplicated non-synched registers or else valid elements not | 278 // there are duplicated non-synched registers or else valid elements not |
| (...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 891 int frame_arg_count) { | 886 int frame_arg_count) { |
| 892 ASSERT(cgen_->HasValidEntryRegisters()); | 887 ASSERT(cgen_->HasValidEntryRegisters()); |
| 893 PrepareForCall(frame_arg_count); | 888 PrepareForCall(frame_arg_count); |
| 894 __ CallRuntime(id, frame_arg_count); | 889 __ CallRuntime(id, frame_arg_count); |
| 895 Result result = cgen_->allocator()->Allocate(eax); | 890 Result result = cgen_->allocator()->Allocate(eax); |
| 896 ASSERT(result.is_valid()); | 891 ASSERT(result.is_valid()); |
| 897 return result; | 892 return result; |
| 898 } | 893 } |
| 899 | 894 |
| 900 | 895 |
| 901 void VirtualFrame::InvokeBuiltin(Builtins::JavaScript id, | 896 Result VirtualFrame::InvokeBuiltin(Builtins::JavaScript id, |
| 902 InvokeFlag flag, | 897 InvokeFlag flag, |
| 903 int frame_arg_count) { | 898 int frame_arg_count) { |
| 904 ASSERT(cgen_->HasValidEntryRegisters()); | 899 ASSERT(cgen_->HasValidEntryRegisters()); |
| 905 PrepareForCall(frame_arg_count); | 900 PrepareForCall(frame_arg_count); |
| 906 __ InvokeBuiltin(id, flag); | 901 __ InvokeBuiltin(id, flag); |
| 902 Result result = cgen_->allocator()->Allocate(eax); |
| 903 ASSERT(result.is_valid()); |
| 904 return result; |
| 907 } | 905 } |
| 908 | 906 |
| 909 | 907 |
| 910 Result VirtualFrame::CallCodeObject(Handle<Code> code, | 908 Result VirtualFrame::CallCodeObject(Handle<Code> code, |
| 911 RelocInfo::Mode rmode, | 909 RelocInfo::Mode rmode, |
| 912 int frame_arg_count) { | 910 int frame_arg_count) { |
| 913 ASSERT(cgen_->HasValidEntryRegisters()); | 911 ASSERT(cgen_->HasValidEntryRegisters()); |
| 914 PrepareForCall(frame_arg_count); | 912 PrepareForCall(frame_arg_count); |
| 915 __ call(code, rmode); | 913 __ call(code, rmode); |
| 916 Result result = cgen_->allocator()->Allocate(eax); | 914 Result result = cgen_->allocator()->Allocate(eax); |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1051 return false; | 1049 return false; |
| 1052 } | 1050 } |
| 1053 } | 1051 } |
| 1054 return true; | 1052 return true; |
| 1055 } | 1053 } |
| 1056 #endif | 1054 #endif |
| 1057 | 1055 |
| 1058 #undef __ | 1056 #undef __ |
| 1059 | 1057 |
| 1060 } } // namespace v8::internal | 1058 } } // namespace v8::internal |
| OLD | NEW |