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

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

Issue 655002: Merge revisions 3777-3813 from bleding_edge to partial snapshots ... (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/partial_snapshots/
Patch Set: Created 10 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/x64/codegen-x64.cc ('k') | src/x64/full-codegen-x64.cc » ('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 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 19 matching lines...) Expand all
30 #include "codegen-inl.h" 30 #include "codegen-inl.h"
31 #include "fast-codegen.h" 31 #include "fast-codegen.h"
32 32
33 namespace v8 { 33 namespace v8 {
34 namespace internal { 34 namespace internal {
35 35
36 #define __ ACCESS_MASM(masm()) 36 #define __ ACCESS_MASM(masm())
37 37
38 void FastCodeGenerator::EmitLoadReceiver(Register reg) { 38 void FastCodeGenerator::EmitLoadReceiver(Register reg) {
39 // Offset 2 is due to return address and saved frame pointer. 39 // Offset 2 is due to return address and saved frame pointer.
40 int index = 2 + function()->scope()->num_parameters(); 40 int index = 2 + scope()->num_parameters();
41 __ movq(reg, Operand(rbp, index * kPointerSize)); 41 __ movq(reg, Operand(rbp, index * kPointerSize));
42 } 42 }
43 43
44 44
45 void FastCodeGenerator::EmitReceiverMapCheck() { 45 void FastCodeGenerator::EmitReceiverMapCheck() {
46 Comment cmnt(masm(), ";; MapCheck(this)"); 46 Comment cmnt(masm(), ";; MapCheck(this)");
47 if (FLAG_print_ir) { 47 if (FLAG_print_ir) {
48 PrintF("MapCheck(this)\n"); 48 PrintF("MapCheck(this)\n");
49 } 49 }
50 50
51 ASSERT(info()->has_receiver() && info()->receiver()->IsHeapObject());
52 Handle<HeapObject> object = Handle<HeapObject>::cast(info()->receiver());
53 Handle<Map> map(object->map());
54
51 EmitLoadReceiver(rdx); 55 EmitLoadReceiver(rdx);
52 __ JumpIfSmi(rdx, bailout()); 56 __ CheckMap(rdx, map, bailout(), false);
53
54 ASSERT(has_receiver() && receiver()->IsHeapObject());
55 Handle<HeapObject> object = Handle<HeapObject>::cast(receiver());
56 Handle<Map> map(object->map());
57 __ Cmp(FieldOperand(rdx, HeapObject::kMapOffset), map);
58 __ j(not_equal, bailout());
59 } 57 }
60 58
61 59
62 void FastCodeGenerator::EmitGlobalVariableLoad(Handle<String> name) { 60 void FastCodeGenerator::EmitGlobalMapCheck() {
63 // Compile global variable accesses as load IC calls. The only live 61 Comment cmnt(masm(), ";; GlobalMapCheck");
64 // registers are rsi (context) and possibly rdx (this). Both are also 62 if (FLAG_print_ir) {
65 // saved in the stack and rsi is preserved by the call. 63 PrintF(";; GlobalMapCheck()");
66 __ push(CodeGenerator::GlobalObject()); 64 }
67 __ Move(rcx, name); 65
68 Handle<Code> ic(Builtins::builtin(Builtins::LoadIC_Initialize)); 66 ASSERT(info()->has_global_object());
69 __ Call(ic, RelocInfo::CODE_TARGET_CONTEXT); 67 Handle<Map> map(info()->global_object()->map());
70 if (has_this_properties()) { 68
71 // Restore this. 69 __ movq(rbx, CodeGenerator::GlobalObject());
72 EmitLoadReceiver(rdx); 70 __ CheckMap(rbx, map, bailout(), true);
73 } else { 71 }
74 __ nop(); // Not test rax, indicates IC has no inlined code at call site. 72
73
74 void FastCodeGenerator::EmitGlobalVariableLoad(Handle<Object> cell) {
75 ASSERT(cell->IsJSGlobalPropertyCell());
76 __ Move(rax, cell);
77 __ movq(rax, FieldOperand(rax, JSGlobalPropertyCell::kValueOffset));
78 if (FLAG_debug_code) {
79 __ Cmp(rax, Factory::the_hole_value());
80 __ Check(not_equal, "DontDelete cells can't contain the hole");
75 } 81 }
76 } 82 }
77 83
78 84
79 void FastCodeGenerator::EmitThisPropertyStore(Handle<String> name) { 85 void FastCodeGenerator::EmitThisPropertyStore(Handle<String> name) {
80 LookupResult lookup; 86 LookupResult lookup;
81 receiver()->Lookup(*name, &lookup); 87 info()->receiver()->Lookup(*name, &lookup);
82 88
83 ASSERT(lookup.holder() == *receiver()); 89 ASSERT(lookup.holder() == *info()->receiver());
84 ASSERT(lookup.type() == FIELD); 90 ASSERT(lookup.type() == FIELD);
85 Handle<Map> map(Handle<HeapObject>::cast(receiver())->map()); 91 Handle<Map> map(Handle<HeapObject>::cast(info()->receiver())->map());
86 int index = lookup.GetFieldIndex() - map->inobject_properties(); 92 int index = lookup.GetFieldIndex() - map->inobject_properties();
87 int offset = index * kPointerSize; 93 int offset = index * kPointerSize;
88 94
89 // Negative offsets are inobject properties. 95 // Negative offsets are inobject properties.
90 if (offset < 0) { 96 if (offset < 0) {
91 offset += map->instance_size(); 97 offset += map->instance_size();
92 __ movq(rcx, rdx); // Copy receiver for write barrier. 98 __ movq(rcx, rdx); // Copy receiver for write barrier.
93 } else { 99 } else {
94 offset += FixedArray::kHeaderSize; 100 offset += FixedArray::kHeaderSize;
95 __ movq(rcx, FieldOperand(rdx, JSObject::kPropertiesOffset)); 101 __ movq(rcx, FieldOperand(rdx, JSObject::kPropertiesOffset));
96 } 102 }
97 // Perform the store. 103 // Perform the store.
98 __ movq(FieldOperand(rcx, offset), rax); 104 __ movq(FieldOperand(rcx, offset), rax);
99 // Preserve value from write barrier in case it's needed. 105 // Preserve value from write barrier in case it's needed.
100 __ movq(rbx, rax); 106 __ movq(rbx, rax);
101 __ RecordWrite(rcx, offset, rbx, rdi); 107 __ RecordWrite(rcx, offset, rbx, rdi);
102 } 108 }
103 109
104 110
105 void FastCodeGenerator::Generate(FunctionLiteral* fun, CompilationInfo* info) { 111 void FastCodeGenerator::Generate(CompilationInfo* compilation_info) {
106 ASSERT(function_ == NULL);
107 ASSERT(info_ == NULL); 112 ASSERT(info_ == NULL);
108 function_ = fun; 113 info_ = compilation_info;
109 info_ = info;
110 114
111 // Save the caller's frame pointer and set up our own. 115 // Save the caller's frame pointer and set up our own.
112 Comment prologue_cmnt(masm(), ";; Prologue"); 116 Comment prologue_cmnt(masm(), ";; Prologue");
113 __ push(rbp); 117 __ push(rbp);
114 __ movq(rbp, rsp); 118 __ movq(rbp, rsp);
115 __ push(rsi); // Context. 119 __ push(rsi); // Context.
116 __ push(rdi); // Closure. 120 __ push(rdi); // Closure.
117 // Note that we keep a live register reference to esi (context) at this 121 // Note that we keep a live register reference to esi (context) at this
118 // point. 122 // point.
119 123
120 // Receiver (this) is allocated to rdx if there are this properties. 124 // Receiver (this) is allocated to rdx if there are this properties.
121 if (has_this_properties()) EmitReceiverMapCheck(); 125 if (info()->has_this_properties()) EmitReceiverMapCheck();
122 126
123 VisitStatements(fun->body()); 127 // If there is a global variable access check if the global object
128 // is the same as at lazy-compilation time.
129 if (info()->has_globals()) EmitGlobalMapCheck();
130
131 VisitStatements(info()->function()->body());
124 132
125 Comment return_cmnt(masm(), ";; Return(<undefined>)"); 133 Comment return_cmnt(masm(), ";; Return(<undefined>)");
126 __ LoadRoot(rax, Heap::kUndefinedValueRootIndex); 134 __ LoadRoot(rax, Heap::kUndefinedValueRootIndex);
127 135
128 Comment epilogue_cmnt(masm(), ";; Epilogue"); 136 Comment epilogue_cmnt(masm(), ";; Epilogue");
129 __ movq(rsp, rbp); 137 __ movq(rsp, rbp);
130 __ pop(rbp); 138 __ pop(rbp);
131 __ ret((fun->scope()->num_parameters() + 1) * kPointerSize); 139 __ ret((scope()->num_parameters() + 1) * kPointerSize);
132 140
133 __ bind(&bailout_); 141 __ bind(&bailout_);
134 } 142 }
135 143
136 144
137 #undef __ 145 #undef __
138 146
139 147
140 } } // namespace v8::internal 148 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/x64/codegen-x64.cc ('k') | src/x64/full-codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698