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

Side by Side Diff: src/ia32/lithium-codegen-ia32.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, 10 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/ia32/lithium-codegen-ia32.h ('k') | src/ia32/lithium-ia32.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 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 Translation* translation) { 387 Translation* translation) {
388 if (environment == NULL) return; 388 if (environment == NULL) return;
389 389
390 // The translation includes one command per value in the environment. 390 // The translation includes one command per value in the environment.
391 int translation_size = environment->values()->length(); 391 int translation_size = environment->values()->length();
392 // The output frame height does not include the parameters. 392 // The output frame height does not include the parameters.
393 int height = translation_size - environment->parameter_count(); 393 int height = translation_size - environment->parameter_count();
394 394
395 WriteTranslation(environment->outer(), translation); 395 WriteTranslation(environment->outer(), translation);
396 int closure_id = DefineDeoptimizationLiteral(environment->closure()); 396 int closure_id = DefineDeoptimizationLiteral(environment->closure());
397 if (environment->is_arguments_adaptor()) { 397 switch (environment->frame_type()) {
398 translation->BeginArgumentsAdaptorFrame(closure_id, translation_size); 398 case JS_FUNCTION:
399 } else { 399 translation->BeginJSFrame(environment->ast_id(), closure_id, height);
400 translation->BeginJSFrame(environment->ast_id(), closure_id, height); 400 break;
401 case JS_CONSTRUCT:
402 translation->BeginConstructStubFrame(closure_id, translation_size);
403 break;
404 case ARGUMENTS_ADAPTOR:
405 translation->BeginArgumentsAdaptorFrame(closure_id, translation_size);
406 break;
407 default:
408 UNREACHABLE();
401 } 409 }
402 for (int i = 0; i < translation_size; ++i) { 410 for (int i = 0; i < translation_size; ++i) {
403 LOperand* value = environment->values()->at(i); 411 LOperand* value = environment->values()->at(i);
404 // spilled_registers_ and spilled_double_registers_ are either 412 // spilled_registers_ and spilled_double_registers_ are either
405 // both NULL or both set. 413 // both NULL or both set.
406 if (environment->spilled_registers() != NULL && value != NULL) { 414 if (environment->spilled_registers() != NULL && value != NULL) {
407 if (value->IsRegister() && 415 if (value->IsRegister() &&
408 environment->spilled_registers()[value->index()] != NULL) { 416 environment->spilled_registers()[value->index()] != NULL) {
409 translation->MarkDuplicate(); 417 translation->MarkDuplicate();
410 AddToTranslation(translation, 418 AddToTranslation(translation,
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 551
544 // Layout of the translation: 552 // Layout of the translation:
545 // 0 ........................................................ size - 1 + 4 553 // 0 ........................................................ size - 1 + 4
546 // [expression stack including arguments] [locals] [4 words] [parameters] 554 // [expression stack including arguments] [locals] [4 words] [parameters]
547 // |>------------ translation_size ------------<| 555 // |>------------ translation_size ------------<|
548 556
549 int frame_count = 0; 557 int frame_count = 0;
550 int jsframe_count = 0; 558 int jsframe_count = 0;
551 for (LEnvironment* e = environment; e != NULL; e = e->outer()) { 559 for (LEnvironment* e = environment; e != NULL; e = e->outer()) {
552 ++frame_count; 560 ++frame_count;
553 if (!e->is_arguments_adaptor()) { 561 if (e->frame_type() == JS_FUNCTION) {
554 ++jsframe_count; 562 ++jsframe_count;
555 } 563 }
556 } 564 }
557 Translation translation(&translations_, frame_count, jsframe_count); 565 Translation translation(&translations_, frame_count, jsframe_count);
558 WriteTranslation(environment, &translation); 566 WriteTranslation(environment, &translation);
559 int deoptimization_index = deoptimizations_.length(); 567 int deoptimization_index = deoptimizations_.length();
560 int pc_offset = masm()->pc_offset(); 568 int pc_offset = masm()->pc_offset();
561 environment->Register(deoptimization_index, 569 environment->Register(deoptimization_index,
562 translation.index(), 570 translation.index(),
563 (mode == Safepoint::kLazyDeopt) ? pc_offset : -1); 571 (mode == Safepoint::kLazyDeopt) ? pc_offset : -1);
(...skipping 3616 matching lines...) Expand 10 before | Expand all | Expand 10 after
4180 // Load next prototype object. 4188 // Load next prototype object.
4181 __ LoadHeapObject(reg, current_prototype); 4189 __ LoadHeapObject(reg, current_prototype);
4182 } 4190 }
4183 4191
4184 // Check the holder map. 4192 // Check the holder map.
4185 DoCheckMapCommon(reg, Handle<Map>(current_prototype->map()), 4193 DoCheckMapCommon(reg, Handle<Map>(current_prototype->map()),
4186 ALLOW_ELEMENT_TRANSITION_MAPS, instr->environment()); 4194 ALLOW_ELEMENT_TRANSITION_MAPS, instr->environment());
4187 } 4195 }
4188 4196
4189 4197
4198 void LCodeGen::DoAllocateObject(LAllocateObject* instr) {
4199 class DeferredAllocateObject: public LDeferredCode {
4200 public:
4201 DeferredAllocateObject(LCodeGen* codegen, LAllocateObject* instr)
4202 : LDeferredCode(codegen), instr_(instr) { }
4203 virtual void Generate() { codegen()->DoDeferredAllocateObject(instr_); }
4204 virtual LInstruction* instr() { return instr_; }
4205 private:
4206 LAllocateObject* instr_;
4207 };
4208
4209 DeferredAllocateObject* deferred = new DeferredAllocateObject(this, instr);
4210
4211 // TODO(mstarzinger): Implement inlined version instead of jumping to
4212 // deferred runtime call.
4213 __ jmp(deferred->entry());
4214
4215 __ bind(deferred->exit());
4216 }
4217
4218
4219 void LCodeGen::DoDeferredAllocateObject(LAllocateObject* instr) {
4220 Register result = ToRegister(instr->result());
4221 Handle<JSFunction> constructor = instr->hydrogen()->constructor();
4222
4223 // TODO(3095996): Get rid of this. For now, we need to make the
4224 // result register contain a valid pointer because it is already
4225 // contained in the register pointer map.
4226 __ Set(result, Immediate(0));
4227
4228 PushSafepointRegistersScope scope(this);
4229 __ PushHeapObject(constructor);
4230 CallRuntimeFromDeferred(Runtime::kNewObject, 1, instr, instr->context());
4231 __ StoreToSafepointRegisterSlot(result, eax);
4232 }
4233
4234
4190 void LCodeGen::DoArrayLiteral(LArrayLiteral* instr) { 4235 void LCodeGen::DoArrayLiteral(LArrayLiteral* instr) {
4191 ASSERT(ToRegister(instr->context()).is(esi)); 4236 ASSERT(ToRegister(instr->context()).is(esi));
4192 Heap* heap = isolate()->heap(); 4237 Heap* heap = isolate()->heap();
4193 ElementsKind boilerplate_elements_kind = 4238 ElementsKind boilerplate_elements_kind =
4194 instr->hydrogen()->boilerplate_elements_kind(); 4239 instr->hydrogen()->boilerplate_elements_kind();
4195 4240
4196 // Deopt if the array literal boilerplate ElementsKind is of a type different 4241 // Deopt if the array literal boilerplate ElementsKind is of a type different
4197 // than the expected one. The check isn't necessary if the boilerplate has 4242 // than the expected one. The check isn't necessary if the boilerplate has
4198 // already been converted to FAST_ELEMENTS. 4243 // already been converted to FAST_ELEMENTS.
4199 if (boilerplate_elements_kind != FAST_ELEMENTS) { 4244 if (boilerplate_elements_kind != FAST_ELEMENTS) {
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
4681 this, pointers, Safepoint::kLazyDeopt); 4726 this, pointers, Safepoint::kLazyDeopt);
4682 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION, safepoint_generator); 4727 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION, safepoint_generator);
4683 } 4728 }
4684 4729
4685 4730
4686 #undef __ 4731 #undef __
4687 4732
4688 } } // namespace v8::internal 4733 } } // namespace v8::internal
4689 4734
4690 #endif // V8_TARGET_ARCH_IA32 4735 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/lithium-codegen-ia32.h ('k') | src/ia32/lithium-ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698