| OLD | NEW |
| 1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 | 212 |
| 213 | 213 |
| 214 void VirtualFrame::PushTryHandler(HandlerType type) { | 214 void VirtualFrame::PushTryHandler(HandlerType type) { |
| 215 // Grow the expression stack by handler size less one (the return | 215 // Grow the expression stack by handler size less one (the return |
| 216 // address in lr is already counted by a call instruction). | 216 // address in lr is already counted by a call instruction). |
| 217 Adjust(kHandlerSize - 1); | 217 Adjust(kHandlerSize - 1); |
| 218 __ PushTryHandler(IN_JAVASCRIPT, type); | 218 __ PushTryHandler(IN_JAVASCRIPT, type); |
| 219 } | 219 } |
| 220 | 220 |
| 221 | 221 |
| 222 void VirtualFrame::RawCallStub(CodeStub* stub) { | |
| 223 ASSERT(cgen()->HasValidEntryRegisters()); | |
| 224 __ CallStub(stub); | |
| 225 } | |
| 226 | |
| 227 | |
| 228 void VirtualFrame::CallStub(CodeStub* stub, Result* arg) { | |
| 229 PrepareForCall(0, 0); | |
| 230 arg->Unuse(); | |
| 231 RawCallStub(stub); | |
| 232 } | |
| 233 | |
| 234 | |
| 235 void VirtualFrame::CallStub(CodeStub* stub, Result* arg0, Result* arg1) { | |
| 236 PrepareForCall(0, 0); | |
| 237 arg0->Unuse(); | |
| 238 arg1->Unuse(); | |
| 239 RawCallStub(stub); | |
| 240 } | |
| 241 | |
| 242 | |
| 243 void VirtualFrame::CallRuntime(Runtime::Function* f, int arg_count) { | 222 void VirtualFrame::CallRuntime(Runtime::Function* f, int arg_count) { |
| 244 PrepareForCall(arg_count, arg_count); | 223 Forget(arg_count); |
| 245 ASSERT(cgen()->HasValidEntryRegisters()); | 224 ASSERT(cgen()->HasValidEntryRegisters()); |
| 246 __ CallRuntime(f, arg_count); | 225 __ CallRuntime(f, arg_count); |
| 247 } | 226 } |
| 248 | 227 |
| 249 | 228 |
| 250 void VirtualFrame::CallRuntime(Runtime::FunctionId id, int arg_count) { | 229 void VirtualFrame::CallRuntime(Runtime::FunctionId id, int arg_count) { |
| 251 PrepareForCall(arg_count, arg_count); | 230 Forget(arg_count); |
| 252 ASSERT(cgen()->HasValidEntryRegisters()); | 231 ASSERT(cgen()->HasValidEntryRegisters()); |
| 253 __ CallRuntime(id, arg_count); | 232 __ CallRuntime(id, arg_count); |
| 254 } | 233 } |
| 255 | 234 |
| 256 | 235 |
| 257 void VirtualFrame::InvokeBuiltin(Builtins::JavaScript id, | 236 void VirtualFrame::InvokeBuiltin(Builtins::JavaScript id, |
| 258 InvokeJSFlags flags, | 237 InvokeJSFlags flags, |
| 259 int arg_count) { | 238 int arg_count) { |
| 260 PrepareForCall(arg_count, arg_count); | 239 Forget(arg_count); |
| 261 __ InvokeBuiltin(id, flags); | 240 __ InvokeBuiltin(id, flags); |
| 262 } | 241 } |
| 263 | 242 |
| 264 | 243 |
| 265 void VirtualFrame::RawCallCodeObject(Handle<Code> code, | |
| 266 RelocInfo::Mode rmode) { | |
| 267 ASSERT(cgen()->HasValidEntryRegisters()); | |
| 268 __ Call(code, rmode); | |
| 269 } | |
| 270 | |
| 271 | |
| 272 void VirtualFrame::CallCodeObject(Handle<Code> code, | 244 void VirtualFrame::CallCodeObject(Handle<Code> code, |
| 273 RelocInfo::Mode rmode, | 245 RelocInfo::Mode rmode, |
| 274 int dropped_args) { | 246 int dropped_args) { |
| 275 int spilled_args = 0; | |
| 276 switch (code->kind()) { | 247 switch (code->kind()) { |
| 277 case Code::CALL_IC: | 248 case Code::CALL_IC: |
| 278 spilled_args = dropped_args + 1; | |
| 279 break; | |
| 280 case Code::FUNCTION: | 249 case Code::FUNCTION: |
| 281 spilled_args = dropped_args + 1; | |
| 282 break; | 250 break; |
| 283 case Code::KEYED_LOAD_IC: | 251 case Code::KEYED_LOAD_IC: |
| 252 case Code::LOAD_IC: |
| 253 case Code::KEYED_STORE_IC: |
| 254 case Code::STORE_IC: |
| 284 ASSERT(dropped_args == 0); | 255 ASSERT(dropped_args == 0); |
| 285 spilled_args = 2; | 256 break; |
| 257 case Code::BUILTIN: |
| 258 ASSERT(*code == Builtins::builtin(Builtins::JSConstructCall)); |
| 286 break; | 259 break; |
| 287 default: | 260 default: |
| 288 // The other types of code objects are called with values | |
| 289 // in specific registers, and are handled in functions with | |
| 290 // a different signature. | |
| 291 UNREACHABLE(); | 261 UNREACHABLE(); |
| 292 break; | 262 break; |
| 293 } | 263 } |
| 294 PrepareForCall(spilled_args, dropped_args); | 264 Forget(dropped_args); |
| 295 RawCallCodeObject(code, rmode); | 265 ASSERT(cgen()->HasValidEntryRegisters()); |
| 266 __ Call(code, rmode); |
| 296 } | 267 } |
| 297 | 268 |
| 298 | 269 |
| 299 void VirtualFrame::CallCodeObject(Handle<Code> code, | |
| 300 RelocInfo::Mode rmode, | |
| 301 Result* arg, | |
| 302 int dropped_args) { | |
| 303 int spilled_args = 0; | |
| 304 switch (code->kind()) { | |
| 305 case Code::LOAD_IC: | |
| 306 ASSERT(arg->reg().is(r2)); | |
| 307 ASSERT(dropped_args == 0); | |
| 308 spilled_args = 1; | |
| 309 break; | |
| 310 case Code::KEYED_STORE_IC: | |
| 311 ASSERT(arg->reg().is(r0)); | |
| 312 ASSERT(dropped_args == 0); | |
| 313 spilled_args = 2; | |
| 314 break; | |
| 315 default: | |
| 316 // No other types of code objects are called with values | |
| 317 // in exactly one register. | |
| 318 UNREACHABLE(); | |
| 319 break; | |
| 320 } | |
| 321 PrepareForCall(spilled_args, dropped_args); | |
| 322 arg->Unuse(); | |
| 323 RawCallCodeObject(code, rmode); | |
| 324 } | |
| 325 | |
| 326 | |
| 327 void VirtualFrame::CallCodeObject(Handle<Code> code, | |
| 328 RelocInfo::Mode rmode, | |
| 329 Result* arg0, | |
| 330 Result* arg1, | |
| 331 int dropped_args) { | |
| 332 int spilled_args = 1; | |
| 333 switch (code->kind()) { | |
| 334 case Code::STORE_IC: | |
| 335 ASSERT(arg0->reg().is(r0)); | |
| 336 ASSERT(arg1->reg().is(r2)); | |
| 337 ASSERT(dropped_args == 0); | |
| 338 spilled_args = 1; | |
| 339 break; | |
| 340 case Code::BUILTIN: | |
| 341 ASSERT(*code == Builtins::builtin(Builtins::JSConstructCall)); | |
| 342 ASSERT(arg0->reg().is(r0)); | |
| 343 ASSERT(arg1->reg().is(r1)); | |
| 344 spilled_args = dropped_args + 1; | |
| 345 break; | |
| 346 default: | |
| 347 // No other types of code objects are called with values | |
| 348 // in exactly two registers. | |
| 349 UNREACHABLE(); | |
| 350 break; | |
| 351 } | |
| 352 PrepareForCall(spilled_args, dropped_args); | |
| 353 arg0->Unuse(); | |
| 354 arg1->Unuse(); | |
| 355 RawCallCodeObject(code, rmode); | |
| 356 } | |
| 357 | |
| 358 | |
| 359 void VirtualFrame::Drop(int count) { | 270 void VirtualFrame::Drop(int count) { |
| 360 ASSERT(count >= 0); | 271 ASSERT(count >= 0); |
| 361 ASSERT(height() >= count); | 272 ASSERT(height() >= count); |
| 362 int num_virtual_elements = (element_count() - 1) - stack_pointer_; | 273 int num_virtual_elements = (element_count() - 1) - stack_pointer_; |
| 363 | 274 |
| 364 // Emit code to lower the stack pointer if necessary. | 275 // Emit code to lower the stack pointer if necessary. |
| 365 if (num_virtual_elements < count) { | 276 if (num_virtual_elements < count) { |
| 366 int num_dropped = count - num_virtual_elements; | 277 int num_dropped = count - num_virtual_elements; |
| 367 stack_pointer_ -= num_dropped; | 278 stack_pointer_ -= num_dropped; |
| 368 __ add(sp, sp, Operand(num_dropped * kPointerSize)); | 279 __ add(sp, sp, Operand(num_dropped * kPointerSize)); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 void VirtualFrame::EmitPushMultiple(int count, int src_regs) { | 314 void VirtualFrame::EmitPushMultiple(int count, int src_regs) { |
| 404 ASSERT(stack_pointer_ == element_count() - 1); | 315 ASSERT(stack_pointer_ == element_count() - 1); |
| 405 Adjust(count); | 316 Adjust(count); |
| 406 __ stm(db_w, sp, src_regs); | 317 __ stm(db_w, sp, src_regs); |
| 407 } | 318 } |
| 408 | 319 |
| 409 | 320 |
| 410 #undef __ | 321 #undef __ |
| 411 | 322 |
| 412 } } // namespace v8::internal | 323 } } // namespace v8::internal |
| OLD | NEW |