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

Side by Side Diff: src/ia32/full-codegen-ia32.cc

Issue 527963002: Implement loads and calls from 'super' (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 3 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
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #if V8_TARGET_ARCH_IA32 7 #if V8_TARGET_ARCH_IA32
8 8
9 #include "src/code-stubs.h" 9 #include "src/code-stubs.h"
10 #include "src/codegen.h" 10 #include "src/codegen.h"
(...skipping 1259 matching lines...) Expand 10 before | Expand all | Expand 10 after
1270 context()->Plug(eax); 1270 context()->Plug(eax);
1271 } 1271 }
1272 1272
1273 1273
1274 void FullCodeGenerator::VisitVariableProxy(VariableProxy* expr) { 1274 void FullCodeGenerator::VisitVariableProxy(VariableProxy* expr) {
1275 Comment cmnt(masm_, "[ VariableProxy"); 1275 Comment cmnt(masm_, "[ VariableProxy");
1276 EmitVariableLoad(expr); 1276 EmitVariableLoad(expr);
1277 } 1277 }
1278 1278
1279 1279
1280 void FullCodeGenerator::VisitSuperReference(SuperReference* expr) {
1281 Comment cnmt(masm_, "[ SuperReference ");
1282
1283 Label super_lookup_failure;
1284 __ mov(LoadConvention::ReceiverRegister(),
1285 Operand(ebp, JavaScriptFrameConstants::kFunctionOffset));
1286
1287 Handle<Symbol> home_object_symbol(isolate()->heap()->home_object_symbol());
1288 __ mov(LoadConvention::NameRegister(), home_object_symbol);
1289
1290 CallLoadIC(NOT_CONTEXTUAL, expr->HomeObjectFeedbackId());
1291
1292 __ cmp(eax, isolate()->factory()->undefined_value());
1293 __ j(equal, &super_lookup_failure);
Toon Verwaest 2014/09/15 11:57:20 What about j(not_equal, &done) push(Immediate(...
Dmitry Lomov (no reviews) 2014/09/15 12:31:12 Done.
1294 __ mov(eax, FieldOperand(eax, HeapObject::kMapOffset));
1295 __ mov(eax, FieldOperand(eax, Map::kPrototypeOffset));
1296 Label done;
1297 __ jmp(&done);
1298 __ bind(&super_lookup_failure);
1299 __ push(Immediate(isolate()->factory()->empty_string()));
arv (Not doing code reviews) 2014/09/15 15:22:57 Can we do a better error message than an empty str
1300 __ CallRuntime(Runtime::kThrowReferenceError, 1);
1301 __ bind(&done);
1302 context()->Plug(eax);
1303 }
1304
1305
1280 void FullCodeGenerator::EmitLoadGlobalCheckExtensions(VariableProxy* proxy, 1306 void FullCodeGenerator::EmitLoadGlobalCheckExtensions(VariableProxy* proxy,
1281 TypeofState typeof_state, 1307 TypeofState typeof_state,
1282 Label* slow) { 1308 Label* slow) {
1283 Register context = esi; 1309 Register context = esi;
1284 Register temp = edx; 1310 Register temp = edx;
1285 1311
1286 Scope* s = scope(); 1312 Scope* s = scope();
1287 while (s != NULL) { 1313 while (s != NULL) {
1288 if (s->num_heap_slots() > 0) { 1314 if (s->num_heap_slots() > 0) {
1289 if (s->calls_sloppy_eval()) { 1315 if (s->calls_sloppy_eval()) {
(...skipping 898 matching lines...) Expand 10 before | Expand all | Expand 10 after
2188 2214
2189 __ Allocate(map->instance_size(), eax, ecx, edx, &gc_required, TAG_OBJECT); 2215 __ Allocate(map->instance_size(), eax, ecx, edx, &gc_required, TAG_OBJECT);
2190 __ jmp(&allocated); 2216 __ jmp(&allocated);
2191 2217
2192 __ bind(&gc_required); 2218 __ bind(&gc_required);
2193 __ Push(Smi::FromInt(map->instance_size())); 2219 __ Push(Smi::FromInt(map->instance_size()));
2194 __ CallRuntime(Runtime::kAllocateInNewSpace, 1); 2220 __ CallRuntime(Runtime::kAllocateInNewSpace, 1);
2195 __ mov(context_register(), 2221 __ mov(context_register(),
2196 Operand(ebp, StandardFrameConstants::kContextOffset)); 2222 Operand(ebp, StandardFrameConstants::kContextOffset));
2197 2223
2224
2198 __ bind(&allocated); 2225 __ bind(&allocated);
2199 __ mov(ebx, map); 2226 __ mov(ebx, map);
2200 __ pop(ecx); 2227 __ pop(ecx);
2201 __ mov(edx, isolate()->factory()->ToBoolean(done)); 2228 __ mov(edx, isolate()->factory()->ToBoolean(done));
2202 DCHECK_EQ(map->instance_size(), 5 * kPointerSize); 2229 DCHECK_EQ(map->instance_size(), 5 * kPointerSize);
2203 __ mov(FieldOperand(eax, HeapObject::kMapOffset), ebx); 2230 __ mov(FieldOperand(eax, HeapObject::kMapOffset), ebx);
2204 __ mov(FieldOperand(eax, JSObject::kPropertiesOffset), 2231 __ mov(FieldOperand(eax, JSObject::kPropertiesOffset),
2205 isolate()->factory()->empty_fixed_array()); 2232 isolate()->factory()->empty_fixed_array());
2206 __ mov(FieldOperand(eax, JSObject::kElementsOffset), 2233 __ mov(FieldOperand(eax, JSObject::kElementsOffset),
2207 isolate()->factory()->empty_fixed_array()); 2234 isolate()->factory()->empty_fixed_array());
2208 __ mov(FieldOperand(eax, JSGeneratorObject::kResultValuePropertyOffset), ecx); 2235 __ mov(FieldOperand(eax, JSGeneratorObject::kResultValuePropertyOffset), ecx);
2209 __ mov(FieldOperand(eax, JSGeneratorObject::kResultDonePropertyOffset), edx); 2236 __ mov(FieldOperand(eax, JSGeneratorObject::kResultDonePropertyOffset), edx);
2210 2237
2211 // Only the value field needs a write barrier, as the other values are in the 2238 // Only the value field needs a write barrier, as the other values are in the
2212 // root set. 2239 // root set.
2213 __ RecordWriteField(eax, JSGeneratorObject::kResultValuePropertyOffset, 2240 __ RecordWriteField(eax, JSGeneratorObject::kResultValuePropertyOffset,
2214 ecx, edx, kDontSaveFPRegs); 2241 ecx, edx, kDontSaveFPRegs);
2215 } 2242 }
2216 2243
2217 2244
2218 void FullCodeGenerator::EmitNamedPropertyLoad(Property* prop) { 2245 void FullCodeGenerator::EmitNamedPropertyLoad(Property* prop) {
2219 SetSourcePosition(prop->position()); 2246 SetSourcePosition(prop->position());
2220 Literal* key = prop->key()->AsLiteral(); 2247 Literal* key = prop->key()->AsLiteral();
2221 DCHECK(!key->value()->IsSmi()); 2248 DCHECK(!key->value()->IsSmi());
2249
2250 if (prop->IsSuperAccess()) {
2251 __ push(LoadConvention::ReceiverRegister());
2252
2253 SuperReference* super_ref = prop->obj()->AsSuperReference();
2254 VisitForStackValue(super_ref->this_var());
2255 __ push(Immediate(key->value()));
2256 __ CallRuntime(Runtime::kLoadFromSuper, 3);
2257 return;
2258 }
2259
2222 __ mov(LoadConvention::NameRegister(), Immediate(key->value())); 2260 __ mov(LoadConvention::NameRegister(), Immediate(key->value()));
2223 if (FLAG_vector_ics) { 2261 if (FLAG_vector_ics) {
2224 __ mov(VectorLoadConvention::SlotRegister(), 2262 __ mov(VectorLoadConvention::SlotRegister(),
2225 Immediate(Smi::FromInt(prop->PropertyFeedbackSlot()))); 2263 Immediate(Smi::FromInt(prop->PropertyFeedbackSlot())));
2226 CallLoadIC(NOT_CONTEXTUAL); 2264 CallLoadIC(NOT_CONTEXTUAL);
2227 } else { 2265 } else {
2228 CallLoadIC(NOT_CONTEXTUAL, prop->PropertyFeedbackId()); 2266 CallLoadIC(NOT_CONTEXTUAL, prop->PropertyFeedbackId());
2229 } 2267 }
2230 } 2268 }
2231 2269
2232 2270
2233 void FullCodeGenerator::EmitKeyedPropertyLoad(Property* prop) { 2271 void FullCodeGenerator::EmitKeyedPropertyLoad(Property* prop) {
2234 SetSourcePosition(prop->position()); 2272 SetSourcePosition(prop->position());
2273
2235 Handle<Code> ic = isolate()->builtins()->KeyedLoadIC_Initialize(); 2274 Handle<Code> ic = isolate()->builtins()->KeyedLoadIC_Initialize();
2236 if (FLAG_vector_ics) { 2275 if (FLAG_vector_ics) {
2237 __ mov(VectorLoadConvention::SlotRegister(), 2276 __ mov(VectorLoadConvention::SlotRegister(),
2238 Immediate(Smi::FromInt(prop->PropertyFeedbackSlot()))); 2277 Immediate(Smi::FromInt(prop->PropertyFeedbackSlot())));
2239 CallIC(ic); 2278 CallIC(ic);
2240 } else { 2279 } else {
2241 CallIC(ic, prop->PropertyFeedbackId()); 2280 CallIC(ic, prop->PropertyFeedbackId());
2242 } 2281 }
2243 } 2282 }
2244 2283
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
2554 : CallIC::METHOD; 2593 : CallIC::METHOD;
2555 // Get the target function. 2594 // Get the target function.
2556 if (call_type == CallIC::FUNCTION) { 2595 if (call_type == CallIC::FUNCTION) {
2557 { StackValueContext context(this); 2596 { StackValueContext context(this);
2558 EmitVariableLoad(callee->AsVariableProxy()); 2597 EmitVariableLoad(callee->AsVariableProxy());
2559 PrepareForBailout(callee, NO_REGISTERS); 2598 PrepareForBailout(callee, NO_REGISTERS);
2560 } 2599 }
2561 // Push undefined as receiver. This is patched in the method prologue if it 2600 // Push undefined as receiver. This is patched in the method prologue if it
2562 // is a sloppy mode method. 2601 // is a sloppy mode method.
2563 __ push(Immediate(isolate()->factory()->undefined_value())); 2602 __ push(Immediate(isolate()->factory()->undefined_value()));
2603 } else if (callee->AsProperty()->IsSuperAccess()) {
2604 Property* prop = callee->AsProperty();
2605 SetSourcePosition(prop->position());
2606 Literal* key = prop->key()->AsLiteral();
2607 DCHECK(!key->value()->IsSmi());
2608 // Load the function from the receiver.
2609 SuperReference* super_ref = callee->AsProperty()->obj()->AsSuperReference();
2610 VisitForAccumulatorValue(super_ref->this_var());
2611 __ push(eax);
2612 __ push(Operand(esp, kPointerSize));
2613 __ push(eax);
2614 __ push(Immediate(key->value()));
2615 __ CallRuntime(Runtime::kLoadFromSuper, 3);
2616 __ mov(Operand(esp, kPointerSize), eax);
2564 } else { 2617 } else {
2565 // Load the function from the receiver. 2618 // Load the function from the receiver.
2566 DCHECK(callee->IsProperty()); 2619 DCHECK(callee->IsProperty());
2567 __ mov(LoadConvention::ReceiverRegister(), Operand(esp, 0)); 2620 __ mov(LoadConvention::ReceiverRegister(), Operand(esp, 0));
2568 EmitNamedPropertyLoad(callee->AsProperty()); 2621 EmitNamedPropertyLoad(callee->AsProperty());
2569 PrepareForBailoutForId(callee->AsProperty()->LoadId(), TOS_REG); 2622 PrepareForBailoutForId(callee->AsProperty()->LoadId(), TOS_REG);
2570 // Push the target function under the receiver. 2623 // Push the target function under the receiver.
2571 __ push(Operand(esp, 0)); 2624 __ push(Operand(esp, 0));
2572 __ mov(Operand(esp, kPointerSize), eax); 2625 __ mov(Operand(esp, kPointerSize), eax);
2573 } 2626 }
(...skipping 11 matching lines...) Expand all
2585 Expression* callee = expr->expression(); 2638 Expression* callee = expr->expression();
2586 2639
2587 // Load the function from the receiver. 2640 // Load the function from the receiver.
2588 DCHECK(callee->IsProperty()); 2641 DCHECK(callee->IsProperty());
2589 __ mov(LoadConvention::ReceiverRegister(), Operand(esp, 0)); 2642 __ mov(LoadConvention::ReceiverRegister(), Operand(esp, 0));
2590 __ mov(LoadConvention::NameRegister(), eax); 2643 __ mov(LoadConvention::NameRegister(), eax);
2591 EmitKeyedPropertyLoad(callee->AsProperty()); 2644 EmitKeyedPropertyLoad(callee->AsProperty());
2592 PrepareForBailoutForId(callee->AsProperty()->LoadId(), TOS_REG); 2645 PrepareForBailoutForId(callee->AsProperty()->LoadId(), TOS_REG);
2593 2646
2594 // Push the target function under the receiver. 2647 // Push the target function under the receiver.
2595 __ push(Operand(esp, 0)); 2648 if (callee->AsProperty()->IsSuperAccess()) {
2596 __ mov(Operand(esp, kPointerSize), eax); 2649 __ mov(Operand(esp, 0), eax);
2650 SuperReference* super_ref = callee->AsProperty()->obj()->AsSuperReference();
2651 VisitForStackValue(super_ref->this_var());
2652 } else {
2653 __ push(Operand(esp, 0));
2654 __ mov(Operand(esp, kPointerSize), eax);
2655 }
2597 2656
2598 EmitCall(expr, CallIC::METHOD); 2657 EmitCall(expr, CallIC::METHOD);
2599 } 2658 }
2600 2659
2601 2660
2602 void FullCodeGenerator::EmitCall(Call* expr, CallIC::CallType call_type) { 2661 void FullCodeGenerator::EmitCall(Call* expr, CallIC::CallType call_type) {
2603 // Load the arguments. 2662 // Load the arguments.
2604 ZoneList<Expression*>* args = expr->arguments(); 2663 ZoneList<Expression*>* args = expr->arguments();
2605 int arg_count = args->length(); 2664 int arg_count = args->length();
2606 { PreservePositionScope scope(masm()->positions_recorder()); 2665 { PreservePositionScope scope(masm()->positions_recorder());
(...skipping 2219 matching lines...) Expand 10 before | Expand all | Expand 10 after
4826 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), 4885 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(),
4827 Assembler::target_address_at(call_target_address, 4886 Assembler::target_address_at(call_target_address,
4828 unoptimized_code)); 4887 unoptimized_code));
4829 return OSR_AFTER_STACK_CHECK; 4888 return OSR_AFTER_STACK_CHECK;
4830 } 4889 }
4831 4890
4832 4891
4833 } } // namespace v8::internal 4892 } } // namespace v8::internal
4834 4893
4835 #endif // V8_TARGET_ARCH_IA32 4894 #endif // V8_TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698