| 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 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 | 310 |
| 311 | 311 |
| 312 void VirtualFrame::PushTryHandler(HandlerType type) { | 312 void VirtualFrame::PushTryHandler(HandlerType type) { |
| 313 // Grow the expression stack by handler size less one (the return address | 313 // Grow the expression stack by handler size less one (the return address |
| 314 // is already pushed by a call instruction). | 314 // is already pushed by a call instruction). |
| 315 Adjust(kHandlerSize - 1); | 315 Adjust(kHandlerSize - 1); |
| 316 __ PushTryHandler(IN_JAVASCRIPT, type); | 316 __ PushTryHandler(IN_JAVASCRIPT, type); |
| 317 } | 317 } |
| 318 | 318 |
| 319 | 319 |
| 320 Result VirtualFrame::RawCallStub(CodeStub* stub, int frame_arg_count) { | 320 Result VirtualFrame::RawCallStub(CodeStub* stub) { |
| 321 ASSERT(cgen_->HasValidEntryRegisters()); | 321 ASSERT(cgen_->HasValidEntryRegisters()); |
| 322 __ CallStub(stub); | 322 __ CallStub(stub); |
| 323 Result result = cgen_->allocator()->Allocate(r0); | 323 Result result = cgen_->allocator()->Allocate(r0); |
| 324 ASSERT(result.is_valid()); | 324 ASSERT(result.is_valid()); |
| 325 return result; | 325 return result; |
| 326 } | 326 } |
| 327 | 327 |
| 328 | 328 |
| 329 Result VirtualFrame::CallRuntime(Runtime::Function* f, | 329 Result VirtualFrame::CallRuntime(Runtime::Function* f, int arg_count) { |
| 330 int frame_arg_count) { | 330 PrepareForCall(arg_count, arg_count); |
| 331 PrepareForCall(frame_arg_count, frame_arg_count); | |
| 332 ASSERT(cgen_->HasValidEntryRegisters()); | 331 ASSERT(cgen_->HasValidEntryRegisters()); |
| 333 __ CallRuntime(f, frame_arg_count); | 332 __ CallRuntime(f, arg_count); |
| 334 Result result = cgen_->allocator()->Allocate(r0); | 333 Result result = cgen_->allocator()->Allocate(r0); |
| 335 ASSERT(result.is_valid()); | 334 ASSERT(result.is_valid()); |
| 336 return result; | 335 return result; |
| 337 } | 336 } |
| 338 | 337 |
| 339 | 338 |
| 340 Result VirtualFrame::CallRuntime(Runtime::FunctionId id, | 339 Result VirtualFrame::CallRuntime(Runtime::FunctionId id, int arg_count) { |
| 341 int frame_arg_count) { | 340 PrepareForCall(arg_count, arg_count); |
| 342 PrepareForCall(frame_arg_count, frame_arg_count); | |
| 343 ASSERT(cgen_->HasValidEntryRegisters()); | 341 ASSERT(cgen_->HasValidEntryRegisters()); |
| 344 __ CallRuntime(id, frame_arg_count); | 342 __ CallRuntime(id, arg_count); |
| 345 Result result = cgen_->allocator()->Allocate(r0); | 343 Result result = cgen_->allocator()->Allocate(r0); |
| 346 ASSERT(result.is_valid()); | 344 ASSERT(result.is_valid()); |
| 347 return result; | 345 return result; |
| 348 } | 346 } |
| 349 | 347 |
| 350 | 348 |
| 351 Result VirtualFrame::InvokeBuiltin(Builtins::JavaScript id, | 349 Result VirtualFrame::InvokeBuiltin(Builtins::JavaScript id, |
| 352 InvokeJSFlags flags, | 350 InvokeJSFlags flags, |
| 353 Result* arg_count_register, | 351 Result* arg_count_register, |
| 354 int frame_arg_count) { | 352 int arg_count) { |
| 355 ASSERT(arg_count_register->reg().is(r0)); | 353 ASSERT(arg_count_register->reg().is(r0)); |
| 356 PrepareForCall(frame_arg_count, frame_arg_count); | 354 PrepareForCall(arg_count, arg_count); |
| 357 arg_count_register->Unuse(); | 355 arg_count_register->Unuse(); |
| 358 __ InvokeBuiltin(id, flags); | 356 __ InvokeBuiltin(id, flags); |
| 359 Result result = cgen_->allocator()->Allocate(r0); | 357 Result result = cgen_->allocator()->Allocate(r0); |
| 360 return result; | 358 return result; |
| 361 } | 359 } |
| 362 | 360 |
| 363 | 361 |
| 364 Result VirtualFrame::RawCallCodeObject(Handle<Code> code, | 362 Result VirtualFrame::RawCallCodeObject(Handle<Code> code, |
| 365 RelocInfo::Mode rmode) { | 363 RelocInfo::Mode rmode) { |
| 366 ASSERT(cgen_->HasValidEntryRegisters()); | 364 ASSERT(cgen_->HasValidEntryRegisters()); |
| 367 __ Call(code, rmode); | 365 __ Call(code, rmode); |
| 368 Result result = cgen_->allocator()->Allocate(r0); | 366 Result result = cgen_->allocator()->Allocate(r0); |
| 369 ASSERT(result.is_valid()); | 367 ASSERT(result.is_valid()); |
| 370 return result; | 368 return result; |
| 371 } | 369 } |
| 372 | 370 |
| 373 | 371 |
| 374 Result VirtualFrame::CallCodeObject(Handle<Code> code, | 372 Result VirtualFrame::CallCodeObject(Handle<Code> code, |
| 375 RelocInfo::Mode rmode, | 373 RelocInfo::Mode rmode, |
| 374 int dropped_args) { |
| 375 int spilled_args = 0; |
| 376 switch (code->kind()) { |
| 377 case Code::CALL_IC: |
| 378 spilled_args = dropped_args + 1; |
| 379 break; |
| 380 case Code::FUNCTION: |
| 381 spilled_args = dropped_args + 1; |
| 382 break; |
| 383 case Code::KEYED_LOAD_IC: |
| 384 ASSERT(dropped_args == 0); |
| 385 spilled_args = 2; |
| 386 break; |
| 387 default: |
| 388 // The other types of code objects are called with values |
| 389 // in specific registers, and are handled in functions with |
| 390 // a different signature. |
| 391 UNREACHABLE(); |
| 392 break; |
| 393 } |
| 394 PrepareForCall(spilled_args, dropped_args); |
| 395 return RawCallCodeObject(code, rmode); |
| 396 } |
| 397 |
| 398 |
| 399 Result VirtualFrame::CallCodeObject(Handle<Code> code, |
| 400 RelocInfo::Mode rmode, |
| 376 Result* arg, | 401 Result* arg, |
| 377 int dropped_args) { | 402 int dropped_args) { |
| 378 int spilled_args = 0; | 403 int spilled_args = 0; |
| 379 switch (code->kind()) { | 404 switch (code->kind()) { |
| 380 case Code::LOAD_IC: | 405 case Code::LOAD_IC: |
| 381 ASSERT(arg->reg().is(r2)); | 406 ASSERT(arg->reg().is(r2)); |
| 382 ASSERT(dropped_args == 0); | 407 ASSERT(dropped_args == 0); |
| 383 spilled_args = 1; | 408 spilled_args = 1; |
| 384 break; | 409 break; |
| 385 case Code::KEYED_STORE_IC: | 410 case Code::KEYED_STORE_IC: |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 ASSERT(stack_pointer_ == elements_.length() - 1); | 496 ASSERT(stack_pointer_ == elements_.length() - 1); |
| 472 elements_.Add(FrameElement::MemoryElement()); | 497 elements_.Add(FrameElement::MemoryElement()); |
| 473 stack_pointer_++; | 498 stack_pointer_++; |
| 474 __ push(reg); | 499 __ push(reg); |
| 475 } | 500 } |
| 476 | 501 |
| 477 | 502 |
| 478 #undef __ | 503 #undef __ |
| 479 | 504 |
| 480 } } // namespace v8::internal | 505 } } // namespace v8::internal |
| OLD | NEW |