OLD | NEW |
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 #if V8_TARGET_ARCH_X64 | 5 #if V8_TARGET_ARCH_X64 |
6 | 6 |
7 #include "src/code-factory.h" | 7 #include "src/code-factory.h" |
8 #include "src/codegen.h" | 8 #include "src/codegen.h" |
9 #include "src/deoptimizer.h" | 9 #include "src/deoptimizer.h" |
10 #include "src/full-codegen/full-codegen.h" | 10 #include "src/full-codegen/full-codegen.h" |
(...skipping 1279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1290 | 1290 |
1291 void Builtins::Generate_NotifySoftDeoptimized(MacroAssembler* masm) { | 1291 void Builtins::Generate_NotifySoftDeoptimized(MacroAssembler* masm) { |
1292 Generate_NotifyDeoptimizedHelper(masm, Deoptimizer::SOFT); | 1292 Generate_NotifyDeoptimizedHelper(masm, Deoptimizer::SOFT); |
1293 } | 1293 } |
1294 | 1294 |
1295 void Builtins::Generate_NotifyLazyDeoptimized(MacroAssembler* masm) { | 1295 void Builtins::Generate_NotifyLazyDeoptimized(MacroAssembler* masm) { |
1296 Generate_NotifyDeoptimizedHelper(masm, Deoptimizer::LAZY); | 1296 Generate_NotifyDeoptimizedHelper(masm, Deoptimizer::LAZY); |
1297 } | 1297 } |
1298 | 1298 |
1299 // static | 1299 // static |
1300 void Builtins::Generate_DatePrototype_GetField(MacroAssembler* masm, | |
1301 int field_index) { | |
1302 // ----------- S t a t e ------------- | |
1303 // -- rax : number of arguments | |
1304 // -- rdi : function | |
1305 // -- rsi : context | |
1306 // -- rsp[0] : return address | |
1307 // -- rsp[8] : receiver | |
1308 // ----------------------------------- | |
1309 | |
1310 // 1. Load receiver into rax and check that it's actually a JSDate object. | |
1311 Label receiver_not_date; | |
1312 { | |
1313 StackArgumentsAccessor args(rsp, 0); | |
1314 __ movp(rax, args.GetReceiverOperand()); | |
1315 __ JumpIfSmi(rax, &receiver_not_date); | |
1316 __ CmpObjectType(rax, JS_DATE_TYPE, rbx); | |
1317 __ j(not_equal, &receiver_not_date); | |
1318 } | |
1319 | |
1320 // 2. Load the specified date field, falling back to the runtime as necessary. | |
1321 if (field_index == JSDate::kDateValue) { | |
1322 __ movp(rax, FieldOperand(rax, JSDate::kValueOffset)); | |
1323 } else { | |
1324 if (field_index < JSDate::kFirstUncachedField) { | |
1325 Label stamp_mismatch; | |
1326 __ Load(rdx, ExternalReference::date_cache_stamp(masm->isolate())); | |
1327 __ cmpp(rdx, FieldOperand(rax, JSDate::kCacheStampOffset)); | |
1328 __ j(not_equal, &stamp_mismatch, Label::kNear); | |
1329 __ movp(rax, FieldOperand( | |
1330 rax, JSDate::kValueOffset + field_index * kPointerSize)); | |
1331 __ ret(1 * kPointerSize); | |
1332 __ bind(&stamp_mismatch); | |
1333 } | |
1334 FrameScope scope(masm, StackFrame::INTERNAL); | |
1335 __ PrepareCallCFunction(2); | |
1336 __ Move(arg_reg_1, rax); | |
1337 __ Move(arg_reg_2, Smi::FromInt(field_index)); | |
1338 __ CallCFunction( | |
1339 ExternalReference::get_date_field_function(masm->isolate()), 2); | |
1340 } | |
1341 __ ret(1 * kPointerSize); | |
1342 | |
1343 // 3. Raise a TypeError if the receiver is not a date. | |
1344 __ bind(&receiver_not_date); | |
1345 { | |
1346 FrameScope scope(masm, StackFrame::MANUAL); | |
1347 __ Move(rbx, Smi::FromInt(0)); | |
1348 __ EnterBuiltinFrame(rsi, rdi, rbx); | |
1349 __ CallRuntime(Runtime::kThrowNotDateError); | |
1350 | |
1351 // It's far from obvious, but this final trailing instruction after the call | |
1352 // is required for StackFrame::LookupCode to work correctly. To illustrate | |
1353 // why: if call were the final instruction in the code object, then the pc | |
1354 // (== return address) would point beyond the code object when the stack is | |
1355 // traversed. When we then try to look up the code object through | |
1356 // StackFrame::LookupCode, we actually return the next code object that | |
1357 // happens to be on the same page in memory. | |
1358 // TODO(jgruber): A proper fix for this would be nice. | |
1359 __ int3(); | |
1360 } | |
1361 } | |
1362 | |
1363 // static | |
1364 void Builtins::Generate_FunctionPrototypeApply(MacroAssembler* masm) { | 1300 void Builtins::Generate_FunctionPrototypeApply(MacroAssembler* masm) { |
1365 // ----------- S t a t e ------------- | 1301 // ----------- S t a t e ------------- |
1366 // -- rax : argc | 1302 // -- rax : argc |
1367 // -- rsp[0] : return address | 1303 // -- rsp[0] : return address |
1368 // -- rsp[8] : argArray | 1304 // -- rsp[8] : argArray |
1369 // -- rsp[16] : thisArg | 1305 // -- rsp[16] : thisArg |
1370 // -- rsp[24] : receiver | 1306 // -- rsp[24] : receiver |
1371 // ----------------------------------- | 1307 // ----------------------------------- |
1372 | 1308 |
1373 // 1. Load receiver into rdi, argArray into rax (if present), remove all | 1309 // 1. Load receiver into rdi, argArray into rax (if present), remove all |
(...skipping 1736 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3110 void Builtins::Generate_InterpreterOnStackReplacement(MacroAssembler* masm) { | 3046 void Builtins::Generate_InterpreterOnStackReplacement(MacroAssembler* masm) { |
3111 Generate_OnStackReplacementHelper(masm, true); | 3047 Generate_OnStackReplacementHelper(masm, true); |
3112 } | 3048 } |
3113 | 3049 |
3114 #undef __ | 3050 #undef __ |
3115 | 3051 |
3116 } // namespace internal | 3052 } // namespace internal |
3117 } // namespace v8 | 3053 } // namespace v8 |
3118 | 3054 |
3119 #endif // V8_TARGET_ARCH_X64 | 3055 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |