OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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_ARM64 | 7 #if V8_TARGET_ARCH_ARM64 |
8 | 8 |
9 #include "src/code-factory.h" | 9 #include "src/code-factory.h" |
10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
(...skipping 1323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1334 context()->Plug(x0); | 1334 context()->Plug(x0); |
1335 } | 1335 } |
1336 | 1336 |
1337 | 1337 |
1338 void FullCodeGenerator::VisitVariableProxy(VariableProxy* expr) { | 1338 void FullCodeGenerator::VisitVariableProxy(VariableProxy* expr) { |
1339 Comment cmnt(masm_, "[ VariableProxy"); | 1339 Comment cmnt(masm_, "[ VariableProxy"); |
1340 EmitVariableLoad(expr); | 1340 EmitVariableLoad(expr); |
1341 } | 1341 } |
1342 | 1342 |
1343 | 1343 |
| 1344 void FullCodeGenerator::EmitLoadHomeObject(SuperReference* expr) { |
| 1345 Comment cnmt(masm_, "[ SuperReference "); |
| 1346 |
| 1347 __ ldr(LoadDescriptor::ReceiverRegister(), |
| 1348 MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
| 1349 |
| 1350 Handle<Symbol> home_object_symbol(isolate()->heap()->home_object_symbol()); |
| 1351 __ Mov(LoadDescriptor::NameRegister(), Operand(home_object_symbol)); |
| 1352 |
| 1353 CallLoadIC(NOT_CONTEXTUAL, expr->HomeObjectFeedbackId()); |
| 1354 |
| 1355 __ Mov(x10, Operand(isolate()->factory()->undefined_value())); |
| 1356 __ cmp(x0, x10); |
| 1357 Label done; |
| 1358 __ b(&done, ne); |
| 1359 __ CallRuntime(Runtime::kThrowNonMethodError, 0); |
| 1360 __ bind(&done); |
| 1361 } |
| 1362 |
| 1363 |
1344 void FullCodeGenerator::EmitLoadGlobalCheckExtensions(VariableProxy* proxy, | 1364 void FullCodeGenerator::EmitLoadGlobalCheckExtensions(VariableProxy* proxy, |
1345 TypeofState typeof_state, | 1365 TypeofState typeof_state, |
1346 Label* slow) { | 1366 Label* slow) { |
1347 Register current = cp; | 1367 Register current = cp; |
1348 Register next = x10; | 1368 Register next = x10; |
1349 Register temp = x11; | 1369 Register temp = x11; |
1350 | 1370 |
1351 Scope* s = scope(); | 1371 Scope* s = scope(); |
1352 while (s != NULL) { | 1372 while (s != NULL) { |
1353 if (s->num_heap_slots() > 0) { | 1373 if (s->num_heap_slots() > 0) { |
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1942 case KEYED_PROPERTY: | 1962 case KEYED_PROPERTY: |
1943 EmitKeyedPropertyAssignment(expr); | 1963 EmitKeyedPropertyAssignment(expr); |
1944 break; | 1964 break; |
1945 } | 1965 } |
1946 } | 1966 } |
1947 | 1967 |
1948 | 1968 |
1949 void FullCodeGenerator::EmitNamedPropertyLoad(Property* prop) { | 1969 void FullCodeGenerator::EmitNamedPropertyLoad(Property* prop) { |
1950 SetSourcePosition(prop->position()); | 1970 SetSourcePosition(prop->position()); |
1951 Literal* key = prop->key()->AsLiteral(); | 1971 Literal* key = prop->key()->AsLiteral(); |
| 1972 DCHECK(!prop->IsSuperAccess()); |
| 1973 |
1952 __ Mov(LoadDescriptor::NameRegister(), Operand(key->value())); | 1974 __ Mov(LoadDescriptor::NameRegister(), Operand(key->value())); |
1953 if (FLAG_vector_ics) { | 1975 if (FLAG_vector_ics) { |
1954 __ Mov(VectorLoadICDescriptor::SlotRegister(), | 1976 __ Mov(VectorLoadICDescriptor::SlotRegister(), |
1955 Smi::FromInt(prop->PropertyFeedbackSlot())); | 1977 Smi::FromInt(prop->PropertyFeedbackSlot())); |
1956 CallLoadIC(NOT_CONTEXTUAL); | 1978 CallLoadIC(NOT_CONTEXTUAL); |
1957 } else { | 1979 } else { |
1958 CallLoadIC(NOT_CONTEXTUAL, prop->PropertyFeedbackId()); | 1980 CallLoadIC(NOT_CONTEXTUAL, prop->PropertyFeedbackId()); |
1959 } | 1981 } |
1960 } | 1982 } |
1961 | 1983 |
1962 | 1984 |
| 1985 void FullCodeGenerator::EmitNamedSuperPropertyLoad(Property* prop) { |
| 1986 SetSourcePosition(prop->position()); |
| 1987 Literal* key = prop->key()->AsLiteral(); |
| 1988 DCHECK(!key->value()->IsSmi()); |
| 1989 DCHECK(prop->IsSuperAccess()); |
| 1990 |
| 1991 SuperReference* super_ref = prop->obj()->AsSuperReference(); |
| 1992 EmitLoadHomeObject(super_ref); |
| 1993 __ Push(x0); |
| 1994 VisitForStackValue(super_ref->this_var()); |
| 1995 __ Push(key->value()); |
| 1996 __ CallRuntime(Runtime::kLoadFromSuper, 3); |
| 1997 } |
| 1998 |
| 1999 |
1963 void FullCodeGenerator::EmitKeyedPropertyLoad(Property* prop) { | 2000 void FullCodeGenerator::EmitKeyedPropertyLoad(Property* prop) { |
1964 SetSourcePosition(prop->position()); | 2001 SetSourcePosition(prop->position()); |
1965 // Call keyed load IC. It has arguments key and receiver in r0 and r1. | 2002 // Call keyed load IC. It has arguments key and receiver in r0 and r1. |
1966 Handle<Code> ic = CodeFactory::KeyedLoadIC(isolate()).code(); | 2003 Handle<Code> ic = CodeFactory::KeyedLoadIC(isolate()).code(); |
1967 if (FLAG_vector_ics) { | 2004 if (FLAG_vector_ics) { |
1968 __ Mov(VectorLoadICDescriptor::SlotRegister(), | 2005 __ Mov(VectorLoadICDescriptor::SlotRegister(), |
1969 Smi::FromInt(prop->PropertyFeedbackSlot())); | 2006 Smi::FromInt(prop->PropertyFeedbackSlot())); |
1970 CallIC(ic); | 2007 CallIC(ic); |
1971 } else { | 2008 } else { |
1972 CallIC(ic, prop->PropertyFeedbackId()); | 2009 CallIC(ic, prop->PropertyFeedbackId()); |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2256 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); | 2293 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); |
2257 context()->Plug(x0); | 2294 context()->Plug(x0); |
2258 } | 2295 } |
2259 | 2296 |
2260 | 2297 |
2261 void FullCodeGenerator::VisitProperty(Property* expr) { | 2298 void FullCodeGenerator::VisitProperty(Property* expr) { |
2262 Comment cmnt(masm_, "[ Property"); | 2299 Comment cmnt(masm_, "[ Property"); |
2263 Expression* key = expr->key(); | 2300 Expression* key = expr->key(); |
2264 | 2301 |
2265 if (key->IsPropertyName()) { | 2302 if (key->IsPropertyName()) { |
2266 VisitForAccumulatorValue(expr->obj()); | 2303 if (!expr->IsSuperAccess()) { |
2267 __ Move(LoadDescriptor::ReceiverRegister(), x0); | 2304 VisitForAccumulatorValue(expr->obj()); |
2268 EmitNamedPropertyLoad(expr); | 2305 __ Move(LoadDescriptor::ReceiverRegister(), x0); |
| 2306 EmitNamedPropertyLoad(expr); |
| 2307 } else { |
| 2308 EmitNamedSuperPropertyLoad(expr); |
| 2309 } |
2269 PrepareForBailoutForId(expr->LoadId(), TOS_REG); | 2310 PrepareForBailoutForId(expr->LoadId(), TOS_REG); |
2270 context()->Plug(x0); | 2311 context()->Plug(x0); |
2271 } else { | 2312 } else { |
2272 VisitForStackValue(expr->obj()); | 2313 VisitForStackValue(expr->obj()); |
2273 VisitForAccumulatorValue(expr->key()); | 2314 VisitForAccumulatorValue(expr->key()); |
2274 __ Move(LoadDescriptor::NameRegister(), x0); | 2315 __ Move(LoadDescriptor::NameRegister(), x0); |
2275 __ Pop(LoadDescriptor::ReceiverRegister()); | 2316 __ Pop(LoadDescriptor::ReceiverRegister()); |
2276 EmitKeyedPropertyLoad(expr); | 2317 EmitKeyedPropertyLoad(expr); |
2277 context()->Plug(x0); | 2318 context()->Plug(x0); |
2278 } | 2319 } |
(...skipping 21 matching lines...) Expand all Loading... |
2300 { StackValueContext context(this); | 2341 { StackValueContext context(this); |
2301 EmitVariableLoad(callee->AsVariableProxy()); | 2342 EmitVariableLoad(callee->AsVariableProxy()); |
2302 PrepareForBailout(callee, NO_REGISTERS); | 2343 PrepareForBailout(callee, NO_REGISTERS); |
2303 } | 2344 } |
2304 // Push undefined as receiver. This is patched in the method prologue if it | 2345 // Push undefined as receiver. This is patched in the method prologue if it |
2305 // is a sloppy mode method. | 2346 // is a sloppy mode method. |
2306 __ Push(isolate()->factory()->undefined_value()); | 2347 __ Push(isolate()->factory()->undefined_value()); |
2307 } else { | 2348 } else { |
2308 // Load the function from the receiver. | 2349 // Load the function from the receiver. |
2309 DCHECK(callee->IsProperty()); | 2350 DCHECK(callee->IsProperty()); |
| 2351 DCHECK(!callee->AsProperty()->IsSuperAccess()); |
2310 __ Peek(LoadDescriptor::ReceiverRegister(), 0); | 2352 __ Peek(LoadDescriptor::ReceiverRegister(), 0); |
2311 EmitNamedPropertyLoad(callee->AsProperty()); | 2353 EmitNamedPropertyLoad(callee->AsProperty()); |
2312 PrepareForBailoutForId(callee->AsProperty()->LoadId(), TOS_REG); | 2354 PrepareForBailoutForId(callee->AsProperty()->LoadId(), TOS_REG); |
2313 // Push the target function under the receiver. | 2355 // Push the target function under the receiver. |
2314 __ Pop(x10); | 2356 __ Pop(x10); |
2315 __ Push(x0, x10); | 2357 __ Push(x0, x10); |
2316 } | 2358 } |
2317 | 2359 |
2318 EmitCall(expr, call_type); | 2360 EmitCall(expr, call_type); |
2319 } | 2361 } |
2320 | 2362 |
2321 | 2363 |
| 2364 void FullCodeGenerator::EmitSuperCallWithLoadIC(Call* expr) { |
| 2365 Expression* callee = expr->expression(); |
| 2366 DCHECK(callee->IsProperty()); |
| 2367 Property* prop = callee->AsProperty(); |
| 2368 DCHECK(prop->IsSuperAccess()); |
| 2369 |
| 2370 SetSourcePosition(prop->position()); |
| 2371 Literal* key = prop->key()->AsLiteral(); |
| 2372 DCHECK(!key->value()->IsSmi()); |
| 2373 |
| 2374 // Load the function from the receiver. |
| 2375 const Register scratch = x10; |
| 2376 SuperReference* super_ref = callee->AsProperty()->obj()->AsSuperReference(); |
| 2377 EmitLoadHomeObject(super_ref); |
| 2378 __ Push(x0); |
| 2379 VisitForAccumulatorValue(super_ref->this_var()); |
| 2380 __ Push(x0); |
| 2381 __ Peek(scratch, kPointerSize); |
| 2382 __ Push(scratch, x0); |
| 2383 __ Push(key->value()); |
| 2384 |
| 2385 // Stack here: |
| 2386 // - home_object |
| 2387 // - this (receiver) |
| 2388 // - home_object <-- LoadFromSuper will pop here and below. |
| 2389 // - this (receiver) |
| 2390 // - key |
| 2391 __ CallRuntime(Runtime::kLoadFromSuper, 3); |
| 2392 |
| 2393 // Replace home_object with target function. |
| 2394 __ Poke(x0, kPointerSize); |
| 2395 |
| 2396 // Stack here: |
| 2397 // - target function |
| 2398 // - this (receiver) |
| 2399 EmitCall(expr, CallICState::METHOD); |
| 2400 } |
| 2401 |
| 2402 |
2322 // Code common for calls using the IC. | 2403 // Code common for calls using the IC. |
2323 void FullCodeGenerator::EmitKeyedCallWithLoadIC(Call* expr, | 2404 void FullCodeGenerator::EmitKeyedCallWithLoadIC(Call* expr, |
2324 Expression* key) { | 2405 Expression* key) { |
2325 // Load the key. | 2406 // Load the key. |
2326 VisitForAccumulatorValue(key); | 2407 VisitForAccumulatorValue(key); |
2327 | 2408 |
2328 Expression* callee = expr->expression(); | 2409 Expression* callee = expr->expression(); |
2329 | 2410 |
2330 // Load the function from the receiver. | 2411 // Load the function from the receiver. |
2331 DCHECK(callee->IsProperty()); | 2412 DCHECK(callee->IsProperty()); |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2484 __ LoadRoot(x1, Heap::kUndefinedValueRootIndex); | 2565 __ LoadRoot(x1, Heap::kUndefinedValueRootIndex); |
2485 __ Push(x0, x1); | 2566 __ Push(x0, x1); |
2486 __ Bind(&call); | 2567 __ Bind(&call); |
2487 } | 2568 } |
2488 | 2569 |
2489 // The receiver is either the global receiver or an object found | 2570 // The receiver is either the global receiver or an object found |
2490 // by LoadContextSlot. | 2571 // by LoadContextSlot. |
2491 EmitCall(expr); | 2572 EmitCall(expr); |
2492 } else if (call_type == Call::PROPERTY_CALL) { | 2573 } else if (call_type == Call::PROPERTY_CALL) { |
2493 Property* property = callee->AsProperty(); | 2574 Property* property = callee->AsProperty(); |
2494 { PreservePositionScope scope(masm()->positions_recorder()); | 2575 bool is_named_call = property->key()->IsPropertyName(); |
2495 VisitForStackValue(property->obj()); | 2576 // super.x() is handled in EmitCallWithLoadIC. |
| 2577 if (property->IsSuperAccess() && is_named_call) { |
| 2578 EmitSuperCallWithLoadIC(expr); |
| 2579 } else { |
| 2580 { |
| 2581 PreservePositionScope scope(masm()->positions_recorder()); |
| 2582 VisitForStackValue(property->obj()); |
| 2583 } |
| 2584 if (is_named_call) { |
| 2585 EmitCallWithLoadIC(expr); |
| 2586 } else { |
| 2587 EmitKeyedCallWithLoadIC(expr, property->key()); |
| 2588 } |
2496 } | 2589 } |
2497 if (property->key()->IsPropertyName()) { | |
2498 EmitCallWithLoadIC(expr); | |
2499 } else { | |
2500 EmitKeyedCallWithLoadIC(expr, property->key()); | |
2501 } | |
2502 | |
2503 } else { | 2590 } else { |
2504 DCHECK(call_type == Call::OTHER_CALL); | 2591 DCHECK(call_type == Call::OTHER_CALL); |
2505 // Call to an arbitrary expression not handled specially above. | 2592 // Call to an arbitrary expression not handled specially above. |
2506 { PreservePositionScope scope(masm()->positions_recorder()); | 2593 { PreservePositionScope scope(masm()->positions_recorder()); |
2507 VisitForStackValue(callee); | 2594 VisitForStackValue(callee); |
2508 } | 2595 } |
2509 __ LoadRoot(x1, Heap::kUndefinedValueRootIndex); | 2596 __ LoadRoot(x1, Heap::kUndefinedValueRootIndex); |
2510 __ Push(x1); | 2597 __ Push(x1); |
2511 // Emit function call. | 2598 // Emit function call. |
2512 EmitCall(expr); | 2599 EmitCall(expr); |
(...skipping 2396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4909 return previous_; | 4996 return previous_; |
4910 } | 4997 } |
4911 | 4998 |
4912 | 4999 |
4913 #undef __ | 5000 #undef __ |
4914 | 5001 |
4915 | 5002 |
4916 } } // namespace v8::internal | 5003 } } // namespace v8::internal |
4917 | 5004 |
4918 #endif // V8_TARGET_ARCH_ARM64 | 5005 #endif // V8_TARGET_ARCH_ARM64 |
OLD | NEW |