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

Side by Side Diff: src/x64/lithium-codegen-x64.cc

Issue 9304001: Implement inlining of constructor calls. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed moar comments by Vyacheslav Egorov. Created 8 years, 9 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/x64/lithium-codegen-x64.h ('k') | src/x64/lithium-x64.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 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 Translation* translation) { 361 Translation* translation) {
362 if (environment == NULL) return; 362 if (environment == NULL) return;
363 363
364 // The translation includes one command per value in the environment. 364 // The translation includes one command per value in the environment.
365 int translation_size = environment->values()->length(); 365 int translation_size = environment->values()->length();
366 // The output frame height does not include the parameters. 366 // The output frame height does not include the parameters.
367 int height = translation_size - environment->parameter_count(); 367 int height = translation_size - environment->parameter_count();
368 368
369 WriteTranslation(environment->outer(), translation); 369 WriteTranslation(environment->outer(), translation);
370 int closure_id = DefineDeoptimizationLiteral(environment->closure()); 370 int closure_id = DefineDeoptimizationLiteral(environment->closure());
371 if (environment->is_arguments_adaptor()) { 371 switch (environment->frame_type()) {
372 translation->BeginArgumentsAdaptorFrame(closure_id, translation_size); 372 case JS_FUNCTION:
373 } else { 373 translation->BeginJSFrame(environment->ast_id(), closure_id, height);
374 translation->BeginJSFrame(environment->ast_id(), closure_id, height); 374 break;
375 case JS_CONSTRUCT:
376 translation->BeginConstructStubFrame(closure_id, translation_size);
377 break;
378 case ARGUMENTS_ADAPTOR:
379 translation->BeginArgumentsAdaptorFrame(closure_id, translation_size);
380 break;
381 default:
382 UNREACHABLE();
375 } 383 }
376 for (int i = 0; i < translation_size; ++i) { 384 for (int i = 0; i < translation_size; ++i) {
377 LOperand* value = environment->values()->at(i); 385 LOperand* value = environment->values()->at(i);
378 // spilled_registers_ and spilled_double_registers_ are either 386 // spilled_registers_ and spilled_double_registers_ are either
379 // both NULL or both set. 387 // both NULL or both set.
380 if (environment->spilled_registers() != NULL && value != NULL) { 388 if (environment->spilled_registers() != NULL && value != NULL) {
381 if (value->IsRegister() && 389 if (value->IsRegister() &&
382 environment->spilled_registers()[value->index()] != NULL) { 390 environment->spilled_registers()[value->index()] != NULL) {
383 translation->MarkDuplicate(); 391 translation->MarkDuplicate();
384 AddToTranslation(translation, 392 AddToTranslation(translation,
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 512
505 // Layout of the translation: 513 // Layout of the translation:
506 // 0 ........................................................ size - 1 + 4 514 // 0 ........................................................ size - 1 + 4
507 // [expression stack including arguments] [locals] [4 words] [parameters] 515 // [expression stack including arguments] [locals] [4 words] [parameters]
508 // |>------------ translation_size ------------<| 516 // |>------------ translation_size ------------<|
509 517
510 int frame_count = 0; 518 int frame_count = 0;
511 int jsframe_count = 0; 519 int jsframe_count = 0;
512 for (LEnvironment* e = environment; e != NULL; e = e->outer()) { 520 for (LEnvironment* e = environment; e != NULL; e = e->outer()) {
513 ++frame_count; 521 ++frame_count;
514 if (!e->is_arguments_adaptor()) { 522 if (e->frame_type() == JS_FUNCTION) {
515 ++jsframe_count; 523 ++jsframe_count;
516 } 524 }
517 } 525 }
518 Translation translation(&translations_, frame_count, jsframe_count); 526 Translation translation(&translations_, frame_count, jsframe_count);
519 WriteTranslation(environment, &translation); 527 WriteTranslation(environment, &translation);
520 int deoptimization_index = deoptimizations_.length(); 528 int deoptimization_index = deoptimizations_.length();
521 int pc_offset = masm()->pc_offset(); 529 int pc_offset = masm()->pc_offset();
522 environment->Register(deoptimization_index, 530 environment->Register(deoptimization_index,
523 translation.index(), 531 translation.index(),
524 (mode == Safepoint::kLazyDeopt) ? pc_offset : -1); 532 (mode == Safepoint::kLazyDeopt) ? pc_offset : -1);
(...skipping 3379 matching lines...) Expand 10 before | Expand all | Expand 10 after
3904 // Load next prototype object. 3912 // Load next prototype object.
3905 __ LoadHeapObject(reg, current_prototype); 3913 __ LoadHeapObject(reg, current_prototype);
3906 } 3914 }
3907 3915
3908 // Check the holder map. 3916 // Check the holder map.
3909 DoCheckMapCommon(reg, Handle<Map>(current_prototype->map()), 3917 DoCheckMapCommon(reg, Handle<Map>(current_prototype->map()),
3910 ALLOW_ELEMENT_TRANSITION_MAPS, instr->environment()); 3918 ALLOW_ELEMENT_TRANSITION_MAPS, instr->environment());
3911 } 3919 }
3912 3920
3913 3921
3922 void LCodeGen::DoAllocateObject(LAllocateObject* instr) {
3923 class DeferredAllocateObject: public LDeferredCode {
3924 public:
3925 DeferredAllocateObject(LCodeGen* codegen, LAllocateObject* instr)
3926 : LDeferredCode(codegen), instr_(instr) { }
3927 virtual void Generate() { codegen()->DoDeferredAllocateObject(instr_); }
3928 virtual LInstruction* instr() { return instr_; }
3929 private:
3930 LAllocateObject* instr_;
3931 };
3932
3933 DeferredAllocateObject* deferred = new DeferredAllocateObject(this, instr);
3934
3935 // TODO(mstarzinger): Implement inlined version instead of jumping to
3936 // deferred runtime call.
3937 __ jmp(deferred->entry());
3938
3939 __ bind(deferred->exit());
3940 }
3941
3942
3943 void LCodeGen::DoDeferredAllocateObject(LAllocateObject* instr) {
3944 Register result = ToRegister(instr->result());
3945 Handle<JSFunction> constructor = instr->hydrogen()->constructor();
3946
3947 // TODO(3095996): Get rid of this. For now, we need to make the
3948 // result register contain a valid pointer because it is already
3949 // contained in the register pointer map.
3950 __ Set(result, 0);
3951
3952 PushSafepointRegistersScope scope(this);
3953 __ PushHeapObject(constructor);
3954 CallRuntimeFromDeferred(Runtime::kNewObject, 1, instr);
3955 __ StoreToSafepointRegisterSlot(result, rax);
3956 }
3957
3958
3914 void LCodeGen::DoArrayLiteral(LArrayLiteral* instr) { 3959 void LCodeGen::DoArrayLiteral(LArrayLiteral* instr) {
3915 Heap* heap = isolate()->heap(); 3960 Heap* heap = isolate()->heap();
3916 ElementsKind boilerplate_elements_kind = 3961 ElementsKind boilerplate_elements_kind =
3917 instr->hydrogen()->boilerplate_elements_kind(); 3962 instr->hydrogen()->boilerplate_elements_kind();
3918 3963
3919 // Deopt if the array literal boilerplate ElementsKind is of a type different 3964 // Deopt if the array literal boilerplate ElementsKind is of a type different
3920 // than the expected one. The check isn't necessary if the boilerplate has 3965 // than the expected one. The check isn't necessary if the boilerplate has
3921 // already been converted to FAST_ELEMENTS. 3966 // already been converted to FAST_ELEMENTS.
3922 if (boilerplate_elements_kind != FAST_ELEMENTS) { 3967 if (boilerplate_elements_kind != FAST_ELEMENTS) {
3923 __ LoadHeapObject(rax, instr->hydrogen()->boilerplate_object()); 3968 __ LoadHeapObject(rax, instr->hydrogen()->boilerplate_object());
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
4405 RegisterEnvironmentForDeoptimization(environment, Safepoint::kNoLazyDeopt); 4450 RegisterEnvironmentForDeoptimization(environment, Safepoint::kNoLazyDeopt);
4406 ASSERT(osr_pc_offset_ == -1); 4451 ASSERT(osr_pc_offset_ == -1);
4407 osr_pc_offset_ = masm()->pc_offset(); 4452 osr_pc_offset_ = masm()->pc_offset();
4408 } 4453 }
4409 4454
4410 #undef __ 4455 #undef __
4411 4456
4412 } } // namespace v8::internal 4457 } } // namespace v8::internal
4413 4458
4414 #endif // V8_TARGET_ARCH_X64 4459 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/lithium-codegen-x64.h ('k') | src/x64/lithium-x64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698