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/ia32/fast-codegen-ia32.cc

Issue 565034: Fast compiler: Load globals variables directly from property cells.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Merge 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/fast-codegen.cc ('k') | src/ia32/macro-assembler-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 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 30 matching lines...) Expand all
41 __ mov(reg, Operand(ebp, index * kPointerSize)); 41 __ mov(reg, Operand(ebp, 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(edx); 55 EmitLoadReceiver(edx);
52 __ test(edx, Immediate(kSmiTagMask)); 56 __ CheckMap(edx, map, bailout(), false);
53 __ j(zero, bailout());
54
55 ASSERT(has_receiver() && receiver()->IsHeapObject());
56 Handle<HeapObject> object = Handle<HeapObject>::cast(receiver());
57 Handle<Map> map(object->map());
58 __ cmp(FieldOperand(edx, HeapObject::kMapOffset), Immediate(map));
59 __ j(not_equal, bailout());
60 } 57 }
61 58
62 59
63 void FastCodeGenerator::EmitGlobalVariableLoad(Handle<String> name) { 60 void FastCodeGenerator::EmitGlobalMapCheck() {
64 // Compile global variable accesses as load IC calls. The only live 61 Comment cmnt(masm(), ";; GlobalMapCheck");
65 // registers are esi (context) and possibly edx (this). Both are also 62 if (FLAG_print_ir) {
66 // saved in the stack and esi is preserved by the call. 63 PrintF(";; GlobalMapCheck()");
67 __ push(CodeGenerator::GlobalObject()); 64 }
68 __ mov(ecx, name); 65
69 Handle<Code> ic(Builtins::builtin(Builtins::LoadIC_Initialize)); 66 ASSERT(info()->has_global_object());
70 __ call(ic, RelocInfo::CODE_TARGET_CONTEXT); 67 Handle<Map> map(info()->global_object()->map());
71 if (has_this_properties()) { 68
72 // Restore this. 69 __ mov(ebx, CodeGenerator::GlobalObject());
73 EmitLoadReceiver(edx); 70 __ CheckMap(ebx, map, bailout(), true);
74 } else { 71 }
75 __ nop(); // Not test eax, indicates IC has no inlined code at call site. 72
73
74 void FastCodeGenerator::EmitGlobalVariableLoad(Handle<Object> cell) {
75 ASSERT(cell->IsJSGlobalPropertyCell());
76 __ mov(eax, Immediate(cell));
77 __ mov(eax, FieldOperand(eax, JSGlobalPropertyCell::kValueOffset));
78 if (FLAG_debug_code) {
79 __ cmp(eax, Factory::the_hole_value());
80 __ Check(not_equal, "DontDelete cells can't contain the hole");
76 } 81 }
77 } 82 }
78 83
79 84
80 void FastCodeGenerator::EmitThisPropertyStore(Handle<String> name) { 85 void FastCodeGenerator::EmitThisPropertyStore(Handle<String> name) {
81 LookupResult lookup; 86 LookupResult lookup;
82 receiver()->Lookup(*name, &lookup); 87 info()->receiver()->Lookup(*name, &lookup);
83 88
84 ASSERT(lookup.holder() == *receiver()); 89 ASSERT(lookup.holder() == *info()->receiver());
85 ASSERT(lookup.type() == FIELD); 90 ASSERT(lookup.type() == FIELD);
86 Handle<Map> map(Handle<HeapObject>::cast(receiver())->map()); 91 Handle<Map> map(Handle<HeapObject>::cast(info()->receiver())->map());
87 int index = lookup.GetFieldIndex() - map->inobject_properties(); 92 int index = lookup.GetFieldIndex() - map->inobject_properties();
88 int offset = index * kPointerSize; 93 int offset = index * kPointerSize;
89 94
90 // Negative offsets are inobject properties. 95 // Negative offsets are inobject properties.
91 if (offset < 0) { 96 if (offset < 0) {
92 offset += map->instance_size(); 97 offset += map->instance_size();
93 __ mov(ecx, edx); // Copy receiver for write barrier. 98 __ mov(ecx, edx); // Copy receiver for write barrier.
94 } else { 99 } else {
95 offset += FixedArray::kHeaderSize; 100 offset += FixedArray::kHeaderSize;
96 __ mov(ecx, FieldOperand(edx, JSObject::kPropertiesOffset)); 101 __ mov(ecx, FieldOperand(edx, JSObject::kPropertiesOffset));
97 } 102 }
98 // Perform the store. 103 // Perform the store.
99 __ mov(FieldOperand(ecx, offset), eax); 104 __ mov(FieldOperand(ecx, offset), eax);
100 // Preserve value from write barrier in case it's needed. 105 // Preserve value from write barrier in case it's needed.
101 __ mov(ebx, eax); 106 __ mov(ebx, eax);
102 __ RecordWrite(ecx, offset, ebx, edi); 107 __ RecordWrite(ecx, offset, ebx, edi);
103 } 108 }
104 109
105 110
106 void FastCodeGenerator::Generate(CompilationInfo* info) { 111 void FastCodeGenerator::Generate(CompilationInfo* compilation_info) {
107 ASSERT(info_ == NULL); 112 ASSERT(info_ == NULL);
108 info_ = info; 113 info_ = compilation_info;
109 114
110 // Save the caller's frame pointer and set up our own. 115 // Save the caller's frame pointer and set up our own.
111 Comment prologue_cmnt(masm(), ";; Prologue"); 116 Comment prologue_cmnt(masm(), ";; Prologue");
112 __ push(ebp); 117 __ push(ebp);
113 __ mov(ebp, esp); 118 __ mov(ebp, esp);
114 __ push(esi); // Context. 119 __ push(esi); // Context.
115 __ push(edi); // Closure. 120 __ push(edi); // Closure.
116 // 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
117 // point. 122 // point.
118 123
119 // Receiver (this) is allocated to edx if there are this properties. 124 // Receiver (this) is allocated to edx if there are this properties.
120 if (has_this_properties()) EmitReceiverMapCheck(); 125 if (info()->has_this_properties()) EmitReceiverMapCheck();
126
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();
121 130
122 VisitStatements(function()->body()); 131 VisitStatements(function()->body());
123 132
124 Comment return_cmnt(masm(), ";; Return(<undefined>)"); 133 Comment return_cmnt(masm(), ";; Return(<undefined>)");
125 __ mov(eax, Factory::undefined_value()); 134 __ mov(eax, Factory::undefined_value());
126 135
127 Comment epilogue_cmnt(masm(), ";; Epilogue"); 136 Comment epilogue_cmnt(masm(), ";; Epilogue");
128 __ mov(esp, ebp); 137 __ mov(esp, ebp);
129 __ pop(ebp); 138 __ pop(ebp);
130 __ ret((scope()->num_parameters() + 1) * kPointerSize); 139 __ ret((scope()->num_parameters() + 1) * kPointerSize);
131 140
132 __ bind(&bailout_); 141 __ bind(&bailout_);
133 } 142 }
134 143
135 144
136 #undef __ 145 #undef __
137 146
138 147
139 } } // namespace v8::internal 148 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/fast-codegen.cc ('k') | src/ia32/macro-assembler-ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698