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

Side by Side Diff: src/x64/stub-cache-x64.cc

Issue 6770011: Cleanup usage of HEAP and FACTORY in the cache stub compiler. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Minor reformatting. Created 9 years, 9 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/stub-cache.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 146
147 // Scale the index by multiplying by the entry size. 147 // Scale the index by multiplying by the entry size.
148 ASSERT(StringDictionary::kEntrySize == 3); 148 ASSERT(StringDictionary::kEntrySize == 3);
149 __ lea(index, Operand(index, index, times_2, 0)); // index *= 3. 149 __ lea(index, Operand(index, index, times_2, 0)); // index *= 3.
150 150
151 Register entity_name = r1; 151 Register entity_name = r1;
152 // Having undefined at this place means the name is not contained. 152 // Having undefined at this place means the name is not contained.
153 ASSERT_EQ(kSmiTagSize, 1); 153 ASSERT_EQ(kSmiTagSize, 1);
154 __ movq(entity_name, Operand(properties, index, times_pointer_size, 154 __ movq(entity_name, Operand(properties, index, times_pointer_size,
155 kElementsStartOffset - kHeapObjectTag)); 155 kElementsStartOffset - kHeapObjectTag));
156 __ Cmp(entity_name, FACTORY->undefined_value()); 156 __ Cmp(entity_name, masm->isolate()->factory()->undefined_value());
157 // __ jmp(miss_label); 157 // __ jmp(miss_label);
158 if (i != kProbes - 1) { 158 if (i != kProbes - 1) {
159 __ j(equal, &done); 159 __ j(equal, &done);
160 160
161 // Stop if found the property. 161 // Stop if found the property.
162 __ Cmp(entity_name, Handle<String>(name)); 162 __ Cmp(entity_name, Handle<String>(name));
163 __ j(equal, miss_label); 163 __ j(equal, miss_label);
164 164
165 // Check if the entry name is not a symbol. 165 // Check if the entry name is not a symbol.
166 __ movq(entity_name, FieldOperand(entity_name, HeapObject::kMapOffset)); 166 __ movq(entity_name, FieldOperand(entity_name, HeapObject::kMapOffset));
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 } 373 }
374 374
375 375
376 static void PushInterceptorArguments(MacroAssembler* masm, 376 static void PushInterceptorArguments(MacroAssembler* masm,
377 Register receiver, 377 Register receiver,
378 Register holder, 378 Register holder,
379 Register name, 379 Register name,
380 JSObject* holder_obj) { 380 JSObject* holder_obj) {
381 __ push(name); 381 __ push(name);
382 InterceptorInfo* interceptor = holder_obj->GetNamedInterceptor(); 382 InterceptorInfo* interceptor = holder_obj->GetNamedInterceptor();
383 ASSERT(!HEAP->InNewSpace(interceptor)); 383 ASSERT(!masm->isolate()->heap()->InNewSpace(interceptor));
384 __ Move(kScratchRegister, Handle<Object>(interceptor)); 384 __ Move(kScratchRegister, Handle<Object>(interceptor));
385 __ push(kScratchRegister); 385 __ push(kScratchRegister);
386 __ push(receiver); 386 __ push(receiver);
387 __ push(holder); 387 __ push(holder);
388 __ push(FieldOperand(kScratchRegister, InterceptorInfo::kDataOffset)); 388 __ push(FieldOperand(kScratchRegister, InterceptorInfo::kDataOffset));
389 } 389 }
390 390
391 391
392 static void CompileCallLoadPropertyWithInterceptor(MacroAssembler* masm, 392 static void CompileCallLoadPropertyWithInterceptor(MacroAssembler* masm,
393 Register receiver, 393 Register receiver,
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 // ----------------------------------- 465 // -----------------------------------
466 // Get the function and setup the context. 466 // Get the function and setup the context.
467 JSFunction* function = optimization.constant_function(); 467 JSFunction* function = optimization.constant_function();
468 __ Move(rdi, Handle<JSFunction>(function)); 468 __ Move(rdi, Handle<JSFunction>(function));
469 __ movq(rsi, FieldOperand(rdi, JSFunction::kContextOffset)); 469 __ movq(rsi, FieldOperand(rdi, JSFunction::kContextOffset));
470 470
471 // Pass the additional arguments. 471 // Pass the additional arguments.
472 __ movq(Operand(rsp, 2 * kPointerSize), rdi); 472 __ movq(Operand(rsp, 2 * kPointerSize), rdi);
473 Object* call_data = optimization.api_call_info()->data(); 473 Object* call_data = optimization.api_call_info()->data();
474 Handle<CallHandlerInfo> api_call_info_handle(optimization.api_call_info()); 474 Handle<CallHandlerInfo> api_call_info_handle(optimization.api_call_info());
475 if (HEAP->InNewSpace(call_data)) { 475 if (masm->isolate()->heap()->InNewSpace(call_data)) {
476 __ Move(rcx, api_call_info_handle); 476 __ Move(rcx, api_call_info_handle);
477 __ movq(rbx, FieldOperand(rcx, CallHandlerInfo::kDataOffset)); 477 __ movq(rbx, FieldOperand(rcx, CallHandlerInfo::kDataOffset));
478 __ movq(Operand(rsp, 3 * kPointerSize), rbx); 478 __ movq(Operand(rsp, 3 * kPointerSize), rbx);
479 } else { 479 } else {
480 __ Move(Operand(rsp, 3 * kPointerSize), Handle<Object>(call_data)); 480 __ Move(Operand(rsp, 3 * kPointerSize), Handle<Object>(call_data));
481 } 481 }
482 482
483 // Prepare arguments. 483 // Prepare arguments.
484 __ lea(rbx, Operand(rsp, 3 * kPointerSize)); 484 __ lea(rbx, Operand(rsp, 3 * kPointerSize));
485 485
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 } else { 560 } else {
561 CompileRegular(masm, 561 CompileRegular(masm,
562 object, 562 object,
563 receiver, 563 receiver,
564 scratch1, 564 scratch1,
565 scratch2, 565 scratch2,
566 scratch3, 566 scratch3,
567 name, 567 name,
568 holder, 568 holder,
569 miss); 569 miss);
570 return HEAP->undefined_value(); // Success. 570 return masm->isolate()->heap()->undefined_value(); // Success.
571 } 571 }
572 } 572 }
573 573
574 private: 574 private:
575 MaybeObject* CompileCacheable(MacroAssembler* masm, 575 MaybeObject* CompileCacheable(MacroAssembler* masm,
576 JSObject* object, 576 JSObject* object,
577 Register receiver, 577 Register receiver,
578 Register scratch1, 578 Register scratch1,
579 Register scratch2, 579 Register scratch2,
580 Register scratch3, 580 Register scratch3,
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
660 FreeSpaceForFastApiCall(masm, scratch1); 660 FreeSpaceForFastApiCall(masm, scratch1);
661 __ jmp(miss_label); 661 __ jmp(miss_label);
662 } 662 }
663 663
664 // Invoke a regular function. 664 // Invoke a regular function.
665 __ bind(&regular_invoke); 665 __ bind(&regular_invoke);
666 if (can_do_fast_api_call) { 666 if (can_do_fast_api_call) {
667 FreeSpaceForFastApiCall(masm, scratch1); 667 FreeSpaceForFastApiCall(masm, scratch1);
668 } 668 }
669 669
670 return HEAP->undefined_value(); // Success. 670 return masm->isolate()->heap()->undefined_value(); // Success.
671 } 671 }
672 672
673 void CompileRegular(MacroAssembler* masm, 673 void CompileRegular(MacroAssembler* masm,
674 JSObject* object, 674 JSObject* object,
675 Register receiver, 675 Register receiver,
676 Register scratch1, 676 Register scratch1,
677 Register scratch2, 677 Register scratch2,
678 Register scratch3, 678 Register scratch3,
679 String* name, 679 String* name,
680 JSObject* interceptor_holder, 680 JSObject* interceptor_holder,
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
840 Register scratch, 840 Register scratch,
841 Label* miss) { 841 Label* miss) {
842 Object* probe; 842 Object* probe;
843 { MaybeObject* maybe_probe = global->EnsurePropertyCell(name); 843 { MaybeObject* maybe_probe = global->EnsurePropertyCell(name);
844 if (!maybe_probe->ToObject(&probe)) return maybe_probe; 844 if (!maybe_probe->ToObject(&probe)) return maybe_probe;
845 } 845 }
846 JSGlobalPropertyCell* cell = JSGlobalPropertyCell::cast(probe); 846 JSGlobalPropertyCell* cell = JSGlobalPropertyCell::cast(probe);
847 ASSERT(cell->value()->IsTheHole()); 847 ASSERT(cell->value()->IsTheHole());
848 __ Move(scratch, Handle<Object>(cell)); 848 __ Move(scratch, Handle<Object>(cell));
849 __ Cmp(FieldOperand(scratch, JSGlobalPropertyCell::kValueOffset), 849 __ Cmp(FieldOperand(scratch, JSGlobalPropertyCell::kValueOffset),
850 FACTORY->the_hole_value()); 850 masm->isolate()->factory()->the_hole_value());
851 __ j(not_equal, miss); 851 __ j(not_equal, miss);
852 return cell; 852 return cell;
853 } 853 }
854 854
855 855
856 #undef __ 856 #undef __
857 #define __ ACCESS_MASM((masm())) 857 #define __ ACCESS_MASM((masm()))
858 858
859 859
860 Register StubCompiler::CheckPrototypes(JSObject* object, 860 Register StubCompiler::CheckPrototypes(JSObject* object,
(...skipping 28 matching lines...) Expand all
889 889
890 // Only global objects and objects that do not require access 890 // Only global objects and objects that do not require access
891 // checks are allowed in stubs. 891 // checks are allowed in stubs.
892 ASSERT(current->IsJSGlobalProxy() || !current->IsAccessCheckNeeded()); 892 ASSERT(current->IsJSGlobalProxy() || !current->IsAccessCheckNeeded());
893 893
894 JSObject* prototype = JSObject::cast(current->GetPrototype()); 894 JSObject* prototype = JSObject::cast(current->GetPrototype());
895 if (!current->HasFastProperties() && 895 if (!current->HasFastProperties() &&
896 !current->IsJSGlobalObject() && 896 !current->IsJSGlobalObject() &&
897 !current->IsJSGlobalProxy()) { 897 !current->IsJSGlobalProxy()) {
898 if (!name->IsSymbol()) { 898 if (!name->IsSymbol()) {
899 MaybeObject* lookup_result = HEAP->LookupSymbol(name); 899 MaybeObject* lookup_result = heap()->LookupSymbol(name);
900 if (lookup_result->IsFailure()) { 900 if (lookup_result->IsFailure()) {
901 set_failure(Failure::cast(lookup_result)); 901 set_failure(Failure::cast(lookup_result));
902 return reg; 902 return reg;
903 } else { 903 } else {
904 name = String::cast(lookup_result->ToObjectUnchecked()); 904 name = String::cast(lookup_result->ToObjectUnchecked());
905 } 905 }
906 } 906 }
907 ASSERT(current->property_dictionary()->FindEntry(name) == 907 ASSERT(current->property_dictionary()->FindEntry(name) ==
908 StringDictionary::kNotFound); 908 StringDictionary::kNotFound);
909 909
910 GenerateDictionaryNegativeLookup(masm(), 910 GenerateDictionaryNegativeLookup(masm(),
911 miss, 911 miss,
912 reg, 912 reg,
913 name, 913 name,
914 scratch1, 914 scratch1,
915 scratch2); 915 scratch2);
916 __ movq(scratch1, FieldOperand(reg, HeapObject::kMapOffset)); 916 __ movq(scratch1, FieldOperand(reg, HeapObject::kMapOffset));
917 reg = holder_reg; // from now the object is in holder_reg 917 reg = holder_reg; // from now the object is in holder_reg
918 __ movq(reg, FieldOperand(scratch1, Map::kPrototypeOffset)); 918 __ movq(reg, FieldOperand(scratch1, Map::kPrototypeOffset));
919 } else if (HEAP->InNewSpace(prototype)) { 919 } else if (heap()->InNewSpace(prototype)) {
920 // Get the map of the current object. 920 // Get the map of the current object.
921 __ movq(scratch1, FieldOperand(reg, HeapObject::kMapOffset)); 921 __ movq(scratch1, FieldOperand(reg, HeapObject::kMapOffset));
922 __ Cmp(scratch1, Handle<Map>(current->map())); 922 __ Cmp(scratch1, Handle<Map>(current->map()));
923 // Branch on the result of the map check. 923 // Branch on the result of the map check.
924 __ j(not_equal, miss); 924 __ j(not_equal, miss);
925 // Check access rights to the global object. This has to happen 925 // Check access rights to the global object. This has to happen
926 // after the map check so that we know that the object is 926 // after the map check so that we know that the object is
927 // actually a global object. 927 // actually a global object.
928 if (current->IsJSGlobalProxy()) { 928 if (current->IsJSGlobalProxy()) {
929 __ CheckAccessGlobalProxy(reg, scratch1, miss); 929 __ CheckAccessGlobalProxy(reg, scratch1, miss);
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
1043 scratch2, scratch3, name, miss); 1043 scratch2, scratch3, name, miss);
1044 1044
1045 Handle<AccessorInfo> callback_handle(callback); 1045 Handle<AccessorInfo> callback_handle(callback);
1046 1046
1047 // Insert additional parameters into the stack frame above return address. 1047 // Insert additional parameters into the stack frame above return address.
1048 ASSERT(!scratch2.is(reg)); 1048 ASSERT(!scratch2.is(reg));
1049 __ pop(scratch2); // Get return address to place it below. 1049 __ pop(scratch2); // Get return address to place it below.
1050 1050
1051 __ push(receiver); // receiver 1051 __ push(receiver); // receiver
1052 __ push(reg); // holder 1052 __ push(reg); // holder
1053 if (HEAP->InNewSpace(callback_handle->data())) { 1053 if (heap()->InNewSpace(callback_handle->data())) {
1054 __ Move(scratch1, callback_handle); 1054 __ Move(scratch1, callback_handle);
1055 __ push(FieldOperand(scratch1, AccessorInfo::kDataOffset)); // data 1055 __ push(FieldOperand(scratch1, AccessorInfo::kDataOffset)); // data
1056 } else { 1056 } else {
1057 __ Push(Handle<Object>(callback_handle->data())); 1057 __ Push(Handle<Object>(callback_handle->data()));
1058 } 1058 }
1059 __ push(name_reg); // name 1059 __ push(name_reg); // name
1060 // Save a pointer to where we pushed the arguments pointer. 1060 // Save a pointer to where we pushed the arguments pointer.
1061 // This will be passed as the const AccessorInfo& to the C++ callback. 1061 // This will be passed as the const AccessorInfo& to the C++ callback.
1062 1062
1063 #ifdef _WIN64 1063 #ifdef _WIN64
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
1235 __ push(receiver); 1235 __ push(receiver);
1236 __ push(holder_reg); 1236 __ push(holder_reg);
1237 __ Move(holder_reg, Handle<AccessorInfo>(callback)); 1237 __ Move(holder_reg, Handle<AccessorInfo>(callback));
1238 __ push(FieldOperand(holder_reg, AccessorInfo::kDataOffset)); 1238 __ push(FieldOperand(holder_reg, AccessorInfo::kDataOffset));
1239 __ push(holder_reg); 1239 __ push(holder_reg);
1240 __ push(name_reg); 1240 __ push(name_reg);
1241 __ push(scratch2); // restore return address 1241 __ push(scratch2); // restore return address
1242 1242
1243 ExternalReference ref = 1243 ExternalReference ref =
1244 ExternalReference(IC_Utility(IC::kLoadCallbackProperty), 1244 ExternalReference(IC_Utility(IC::kLoadCallbackProperty),
1245 masm()->isolate()); 1245 isolate());
1246 __ TailCallExternalReference(ref, 5, 1); 1246 __ TailCallExternalReference(ref, 5, 1);
1247 } 1247 }
1248 } else { // !compile_followup_inline 1248 } else { // !compile_followup_inline
1249 // Call the runtime system to load the interceptor. 1249 // Call the runtime system to load the interceptor.
1250 // Check that the maps haven't changed. 1250 // Check that the maps haven't changed.
1251 Register holder_reg = CheckPrototypes(object, receiver, interceptor_holder, 1251 Register holder_reg = CheckPrototypes(object, receiver, interceptor_holder,
1252 scratch1, scratch2, scratch3, 1252 scratch1, scratch2, scratch3,
1253 name, miss); 1253 name, miss);
1254 __ pop(scratch2); // save old return address 1254 __ pop(scratch2); // save old return address
1255 PushInterceptorArguments(masm(), receiver, holder_reg, 1255 PushInterceptorArguments(masm(), receiver, holder_reg,
1256 name_reg, interceptor_holder); 1256 name_reg, interceptor_holder);
1257 __ push(scratch2); // restore old return address 1257 __ push(scratch2); // restore old return address
1258 1258
1259 ExternalReference ref = ExternalReference( 1259 ExternalReference ref = ExternalReference(
1260 IC_Utility(IC::kLoadPropertyWithInterceptorForLoad), masm()->isolate()); 1260 IC_Utility(IC::kLoadPropertyWithInterceptorForLoad), isolate());
1261 __ TailCallExternalReference(ref, 5, 1); 1261 __ TailCallExternalReference(ref, 5, 1);
1262 } 1262 }
1263 } 1263 }
1264 1264
1265 1265
1266 void CallStubCompiler::GenerateNameCheck(String* name, Label* miss) { 1266 void CallStubCompiler::GenerateNameCheck(String* name, Label* miss) {
1267 if (kind_ == Code::KEYED_CALL_IC) { 1267 if (kind_ == Code::KEYED_CALL_IC) {
1268 __ Cmp(rcx, Handle<String>(name)); 1268 __ Cmp(rcx, Handle<String>(name));
1269 __ j(not_equal, miss); 1269 __ j(not_equal, miss);
1270 } 1270 }
(...skipping 25 matching lines...) Expand all
1296 1296
1297 1297
1298 void CallStubCompiler::GenerateLoadFunctionFromCell(JSGlobalPropertyCell* cell, 1298 void CallStubCompiler::GenerateLoadFunctionFromCell(JSGlobalPropertyCell* cell,
1299 JSFunction* function, 1299 JSFunction* function,
1300 Label* miss) { 1300 Label* miss) {
1301 // Get the value from the cell. 1301 // Get the value from the cell.
1302 __ Move(rdi, Handle<JSGlobalPropertyCell>(cell)); 1302 __ Move(rdi, Handle<JSGlobalPropertyCell>(cell));
1303 __ movq(rdi, FieldOperand(rdi, JSGlobalPropertyCell::kValueOffset)); 1303 __ movq(rdi, FieldOperand(rdi, JSGlobalPropertyCell::kValueOffset));
1304 1304
1305 // Check that the cell contains the same function. 1305 // Check that the cell contains the same function.
1306 if (HEAP->InNewSpace(function)) { 1306 if (heap()->InNewSpace(function)) {
1307 // We can't embed a pointer to a function in new space so we have 1307 // We can't embed a pointer to a function in new space so we have
1308 // to verify that the shared function info is unchanged. This has 1308 // to verify that the shared function info is unchanged. This has
1309 // the nice side effect that multiple closures based on the same 1309 // the nice side effect that multiple closures based on the same
1310 // function can all use this call IC. Before we load through the 1310 // function can all use this call IC. Before we load through the
1311 // function, we have to verify that it still is a function. 1311 // function, we have to verify that it still is a function.
1312 __ JumpIfSmi(rdi, miss); 1312 __ JumpIfSmi(rdi, miss);
1313 __ CmpObjectType(rdi, JS_FUNCTION_TYPE, rax); 1313 __ CmpObjectType(rdi, JS_FUNCTION_TYPE, rax);
1314 __ j(not_equal, miss); 1314 __ j(not_equal, miss);
1315 1315
1316 // Check the shared function info. Make sure it hasn't changed. 1316 // Check the shared function info. Make sure it hasn't changed.
1317 __ Move(rax, Handle<SharedFunctionInfo>(function->shared())); 1317 __ Move(rax, Handle<SharedFunctionInfo>(function->shared()));
1318 __ cmpq(FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset), rax); 1318 __ cmpq(FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset), rax);
1319 __ j(not_equal, miss); 1319 __ j(not_equal, miss);
1320 } else { 1320 } else {
1321 __ Cmp(rdi, Handle<JSFunction>(function)); 1321 __ Cmp(rdi, Handle<JSFunction>(function));
1322 __ j(not_equal, miss); 1322 __ j(not_equal, miss);
1323 } 1323 }
1324 } 1324 }
1325 1325
1326 1326
1327 MaybeObject* CallStubCompiler::GenerateMissBranch() { 1327 MaybeObject* CallStubCompiler::GenerateMissBranch() {
1328 MaybeObject* maybe_obj = masm()->isolate()->stub_cache()->ComputeCallMiss( 1328 MaybeObject* maybe_obj = isolate()->stub_cache()->ComputeCallMiss(
1329 arguments().immediate(), kind_); 1329 arguments().immediate(), kind_);
1330 Object* obj; 1330 Object* obj;
1331 if (!maybe_obj->ToObject(&obj)) return maybe_obj; 1331 if (!maybe_obj->ToObject(&obj)) return maybe_obj;
1332 __ Jump(Handle<Code>(Code::cast(obj)), RelocInfo::CODE_TARGET); 1332 __ Jump(Handle<Code>(Code::cast(obj)), RelocInfo::CODE_TARGET);
1333 return obj; 1333 return obj;
1334 } 1334 }
1335 1335
1336 1336
1337 MaybeObject* CallStubCompiler::CompileCallField(JSObject* object, 1337 MaybeObject* CallStubCompiler::CompileCallField(JSObject* object,
1338 JSObject* holder, 1338 JSObject* holder,
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1396 String* name) { 1396 String* name) {
1397 // ----------- S t a t e ------------- 1397 // ----------- S t a t e -------------
1398 // -- rcx : name 1398 // -- rcx : name
1399 // -- rsp[0] : return address 1399 // -- rsp[0] : return address
1400 // -- rsp[(argc - n) * 8] : arg[n] (zero-based) 1400 // -- rsp[(argc - n) * 8] : arg[n] (zero-based)
1401 // -- ... 1401 // -- ...
1402 // -- rsp[(argc + 1) * 8] : receiver 1402 // -- rsp[(argc + 1) * 8] : receiver
1403 // ----------------------------------- 1403 // -----------------------------------
1404 1404
1405 // If object is not an array, bail out to regular call. 1405 // If object is not an array, bail out to regular call.
1406 if (!object->IsJSArray() || cell != NULL) return HEAP->undefined_value(); 1406 if (!object->IsJSArray() || cell != NULL) return heap()->undefined_value();
1407 1407
1408 Label miss; 1408 Label miss;
1409 1409
1410 GenerateNameCheck(name, &miss); 1410 GenerateNameCheck(name, &miss);
1411 1411
1412 // Get the receiver from the stack. 1412 // Get the receiver from the stack.
1413 const int argc = arguments().immediate(); 1413 const int argc = arguments().immediate();
1414 __ movq(rdx, Operand(rsp, (argc + 1) * kPointerSize)); 1414 __ movq(rdx, Operand(rsp, (argc + 1) * kPointerSize));
1415 1415
1416 // Check that the receiver isn't a smi. 1416 // Check that the receiver isn't a smi.
(...skipping 13 matching lines...) Expand all
1430 __ movq(rax, FieldOperand(rdx, JSArray::kLengthOffset)); 1430 __ movq(rax, FieldOperand(rdx, JSArray::kLengthOffset));
1431 __ ret((argc + 1) * kPointerSize); 1431 __ ret((argc + 1) * kPointerSize);
1432 } else { 1432 } else {
1433 Label call_builtin; 1433 Label call_builtin;
1434 1434
1435 // Get the elements array of the object. 1435 // Get the elements array of the object.
1436 __ movq(rbx, FieldOperand(rdx, JSArray::kElementsOffset)); 1436 __ movq(rbx, FieldOperand(rdx, JSArray::kElementsOffset));
1437 1437
1438 // Check that the elements are in fast mode and writable. 1438 // Check that the elements are in fast mode and writable.
1439 __ Cmp(FieldOperand(rbx, HeapObject::kMapOffset), 1439 __ Cmp(FieldOperand(rbx, HeapObject::kMapOffset),
1440 FACTORY->fixed_array_map()); 1440 factory()->fixed_array_map());
1441 __ j(not_equal, &call_builtin); 1441 __ j(not_equal, &call_builtin);
1442 1442
1443 if (argc == 1) { // Otherwise fall through to call builtin. 1443 if (argc == 1) { // Otherwise fall through to call builtin.
1444 Label exit, with_write_barrier, attempt_to_grow_elements; 1444 Label exit, with_write_barrier, attempt_to_grow_elements;
1445 1445
1446 // Get the array's length into rax and calculate new length. 1446 // Get the array's length into rax and calculate new length.
1447 __ SmiToInteger32(rax, FieldOperand(rdx, JSArray::kLengthOffset)); 1447 __ SmiToInteger32(rax, FieldOperand(rdx, JSArray::kLengthOffset));
1448 STATIC_ASSERT(FixedArray::kMaxLength < Smi::kMaxValue); 1448 STATIC_ASSERT(FixedArray::kMaxLength < Smi::kMaxValue);
1449 __ addl(rax, Immediate(argc)); 1449 __ addl(rax, Immediate(argc));
1450 1450
(...skipping 28 matching lines...) Expand all
1479 1479
1480 __ RecordWriteHelper(rbx, rdx, rcx); 1480 __ RecordWriteHelper(rbx, rdx, rcx);
1481 1481
1482 __ ret((argc + 1) * kPointerSize); 1482 __ ret((argc + 1) * kPointerSize);
1483 1483
1484 __ bind(&attempt_to_grow_elements); 1484 __ bind(&attempt_to_grow_elements);
1485 if (!FLAG_inline_new) { 1485 if (!FLAG_inline_new) {
1486 __ jmp(&call_builtin); 1486 __ jmp(&call_builtin);
1487 } 1487 }
1488 1488
1489 Isolate* isolate = masm()->isolate();
1490 ExternalReference new_space_allocation_top = 1489 ExternalReference new_space_allocation_top =
1491 ExternalReference::new_space_allocation_top_address(isolate); 1490 ExternalReference::new_space_allocation_top_address(isolate());
1492 ExternalReference new_space_allocation_limit = 1491 ExternalReference new_space_allocation_limit =
1493 ExternalReference::new_space_allocation_limit_address(isolate); 1492 ExternalReference::new_space_allocation_limit_address(isolate());
1494 1493
1495 const int kAllocationDelta = 4; 1494 const int kAllocationDelta = 4;
1496 // Load top. 1495 // Load top.
1497 __ Load(rcx, new_space_allocation_top); 1496 __ Load(rcx, new_space_allocation_top);
1498 1497
1499 // Check if it's the end of elements. 1498 // Check if it's the end of elements.
1500 __ lea(rdx, FieldOperand(rbx, 1499 __ lea(rdx, FieldOperand(rbx,
1501 rax, times_pointer_size, 1500 rax, times_pointer_size,
1502 FixedArray::kHeaderSize - argc * kPointerSize)); 1501 FixedArray::kHeaderSize - argc * kPointerSize));
1503 __ cmpq(rdx, rcx); 1502 __ cmpq(rdx, rcx);
(...skipping 26 matching lines...) Expand all
1530 // Make new length a smi before returning it. 1529 // Make new length a smi before returning it.
1531 __ Integer32ToSmi(rax, rax); 1530 __ Integer32ToSmi(rax, rax);
1532 __ movq(FieldOperand(rdx, JSArray::kLengthOffset), rax); 1531 __ movq(FieldOperand(rdx, JSArray::kLengthOffset), rax);
1533 1532
1534 // Elements are in new space, so write barrier is not required. 1533 // Elements are in new space, so write barrier is not required.
1535 __ ret((argc + 1) * kPointerSize); 1534 __ ret((argc + 1) * kPointerSize);
1536 } 1535 }
1537 1536
1538 __ bind(&call_builtin); 1537 __ bind(&call_builtin);
1539 __ TailCallExternalReference(ExternalReference(Builtins::c_ArrayPush, 1538 __ TailCallExternalReference(ExternalReference(Builtins::c_ArrayPush,
1540 masm()->isolate()), 1539 isolate()),
1541 argc + 1, 1540 argc + 1,
1542 1); 1541 1);
1543 } 1542 }
1544 1543
1545 __ bind(&miss); 1544 __ bind(&miss);
1546 MaybeObject* maybe_result = GenerateMissBranch(); 1545 MaybeObject* maybe_result = GenerateMissBranch();
1547 if (maybe_result->IsFailure()) return maybe_result; 1546 if (maybe_result->IsFailure()) return maybe_result;
1548 1547
1549 // Return the generated code. 1548 // Return the generated code.
1550 return GetCode(function); 1549 return GetCode(function);
1551 } 1550 }
1552 1551
1553 1552
1554 MaybeObject* CallStubCompiler::CompileArrayPopCall(Object* object, 1553 MaybeObject* CallStubCompiler::CompileArrayPopCall(Object* object,
1555 JSObject* holder, 1554 JSObject* holder,
1556 JSGlobalPropertyCell* cell, 1555 JSGlobalPropertyCell* cell,
1557 JSFunction* function, 1556 JSFunction* function,
1558 String* name) { 1557 String* name) {
1559 // ----------- S t a t e ------------- 1558 // ----------- S t a t e -------------
1560 // -- rcx : name 1559 // -- rcx : name
1561 // -- rsp[0] : return address 1560 // -- rsp[0] : return address
1562 // -- rsp[(argc - n) * 8] : arg[n] (zero-based) 1561 // -- rsp[(argc - n) * 8] : arg[n] (zero-based)
1563 // -- ... 1562 // -- ...
1564 // -- rsp[(argc + 1) * 8] : receiver 1563 // -- rsp[(argc + 1) * 8] : receiver
1565 // ----------------------------------- 1564 // -----------------------------------
1566 1565
1567 // If object is not an array, bail out to regular call. 1566 // If object is not an array, bail out to regular call.
1568 if (!object->IsJSArray() || cell != NULL) return HEAP->undefined_value(); 1567 if (!object->IsJSArray() || cell != NULL) return heap()->undefined_value();
1569 1568
1570 Label miss, return_undefined, call_builtin; 1569 Label miss, return_undefined, call_builtin;
1571 1570
1572 GenerateNameCheck(name, &miss); 1571 GenerateNameCheck(name, &miss);
1573 1572
1574 // Get the receiver from the stack. 1573 // Get the receiver from the stack.
1575 const int argc = arguments().immediate(); 1574 const int argc = arguments().immediate();
1576 __ movq(rdx, Operand(rsp, (argc + 1) * kPointerSize)); 1575 __ movq(rdx, Operand(rsp, (argc + 1) * kPointerSize));
1577 1576
1578 // Check that the receiver isn't a smi. 1577 // Check that the receiver isn't a smi.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1614 FixedArray::kHeaderSize), 1613 FixedArray::kHeaderSize),
1615 r9); 1614 r9);
1616 __ ret((argc + 1) * kPointerSize); 1615 __ ret((argc + 1) * kPointerSize);
1617 1616
1618 __ bind(&return_undefined); 1617 __ bind(&return_undefined);
1619 __ LoadRoot(rax, Heap::kUndefinedValueRootIndex); 1618 __ LoadRoot(rax, Heap::kUndefinedValueRootIndex);
1620 __ ret((argc + 1) * kPointerSize); 1619 __ ret((argc + 1) * kPointerSize);
1621 1620
1622 __ bind(&call_builtin); 1621 __ bind(&call_builtin);
1623 __ TailCallExternalReference( 1622 __ TailCallExternalReference(
1624 ExternalReference(Builtins::c_ArrayPop, masm()->isolate()), 1623 ExternalReference(Builtins::c_ArrayPop, isolate()),
1625 argc + 1, 1624 argc + 1,
1626 1); 1625 1);
1627 1626
1628 __ bind(&miss); 1627 __ bind(&miss);
1629 MaybeObject* maybe_result = GenerateMissBranch(); 1628 MaybeObject* maybe_result = GenerateMissBranch();
1630 if (maybe_result->IsFailure()) return maybe_result; 1629 if (maybe_result->IsFailure()) return maybe_result;
1631 1630
1632 // Return the generated code. 1631 // Return the generated code.
1633 return GetCode(function); 1632 return GetCode(function);
1634 } 1633 }
1635 1634
1636 1635
1637 MaybeObject* CallStubCompiler::CompileStringCharCodeAtCall( 1636 MaybeObject* CallStubCompiler::CompileStringCharCodeAtCall(
1638 Object* object, 1637 Object* object,
1639 JSObject* holder, 1638 JSObject* holder,
1640 JSGlobalPropertyCell* cell, 1639 JSGlobalPropertyCell* cell,
1641 JSFunction* function, 1640 JSFunction* function,
1642 String* name) { 1641 String* name) {
1643 // ----------- S t a t e ------------- 1642 // ----------- S t a t e -------------
1644 // -- rcx : function name 1643 // -- rcx : function name
1645 // -- rsp[0] : return address 1644 // -- rsp[0] : return address
1646 // -- rsp[(argc - n) * 8] : arg[n] (zero-based) 1645 // -- rsp[(argc - n) * 8] : arg[n] (zero-based)
1647 // -- ... 1646 // -- ...
1648 // -- rsp[(argc + 1) * 8] : receiver 1647 // -- rsp[(argc + 1) * 8] : receiver
1649 // ----------------------------------- 1648 // -----------------------------------
1650 1649
1651 // If object is not a string, bail out to regular call. 1650 // If object is not a string, bail out to regular call.
1652 if (!object->IsString() || cell != NULL) return HEAP->undefined_value(); 1651 if (!object->IsString() || cell != NULL) return heap()->undefined_value();
1653 1652
1654 const int argc = arguments().immediate(); 1653 const int argc = arguments().immediate();
1655 1654
1656 Label miss; 1655 Label miss;
1657 Label name_miss; 1656 Label name_miss;
1658 Label index_out_of_range; 1657 Label index_out_of_range;
1659 Label* index_out_of_range_label = &index_out_of_range; 1658 Label* index_out_of_range_label = &index_out_of_range;
1660 1659
1661 if (kind_ == Code::CALL_IC && extra_ic_state_ == DEFAULT_STRING_STUB) { 1660 if (kind_ == Code::CALL_IC && extra_ic_state_ == DEFAULT_STRING_STUB) {
1662 index_out_of_range_label = &miss; 1661 index_out_of_range_label = &miss;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1724 String* name) { 1723 String* name) {
1725 // ----------- S t a t e ------------- 1724 // ----------- S t a t e -------------
1726 // -- rcx : function name 1725 // -- rcx : function name
1727 // -- rsp[0] : return address 1726 // -- rsp[0] : return address
1728 // -- rsp[(argc - n) * 8] : arg[n] (zero-based) 1727 // -- rsp[(argc - n) * 8] : arg[n] (zero-based)
1729 // -- ... 1728 // -- ...
1730 // -- rsp[(argc + 1) * 8] : receiver 1729 // -- rsp[(argc + 1) * 8] : receiver
1731 // ----------------------------------- 1730 // -----------------------------------
1732 1731
1733 // If object is not a string, bail out to regular call. 1732 // If object is not a string, bail out to regular call.
1734 if (!object->IsString() || cell != NULL) return HEAP->undefined_value(); 1733 if (!object->IsString() || cell != NULL) return heap()->undefined_value();
1735 1734
1736 const int argc = arguments().immediate(); 1735 const int argc = arguments().immediate();
1737 1736
1738 Label miss; 1737 Label miss;
1739 Label name_miss; 1738 Label name_miss;
1740 Label index_out_of_range; 1739 Label index_out_of_range;
1741 Label* index_out_of_range_label = &index_out_of_range; 1740 Label* index_out_of_range_label = &index_out_of_range;
1742 1741
1743 if (kind_ == Code::CALL_IC && extra_ic_state_ == DEFAULT_STRING_STUB) { 1742 if (kind_ == Code::CALL_IC && extra_ic_state_ == DEFAULT_STRING_STUB) {
1744 index_out_of_range_label = &miss; 1743 index_out_of_range_label = &miss;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1811 // -- rsp[0] : return address 1810 // -- rsp[0] : return address
1812 // -- rsp[(argc - n) * 8] : arg[n] (zero-based) 1811 // -- rsp[(argc - n) * 8] : arg[n] (zero-based)
1813 // -- ... 1812 // -- ...
1814 // -- rsp[(argc + 1) * 8] : receiver 1813 // -- rsp[(argc + 1) * 8] : receiver
1815 // ----------------------------------- 1814 // -----------------------------------
1816 1815
1817 const int argc = arguments().immediate(); 1816 const int argc = arguments().immediate();
1818 1817
1819 // If the object is not a JSObject or we got an unexpected number of 1818 // If the object is not a JSObject or we got an unexpected number of
1820 // arguments, bail out to the regular call. 1819 // arguments, bail out to the regular call.
1821 if (!object->IsJSObject() || argc != 1) return HEAP->undefined_value(); 1820 if (!object->IsJSObject() || argc != 1) return heap()->undefined_value();
1822 1821
1823 Label miss; 1822 Label miss;
1824 GenerateNameCheck(name, &miss); 1823 GenerateNameCheck(name, &miss);
1825 1824
1826 if (cell == NULL) { 1825 if (cell == NULL) {
1827 __ movq(rdx, Operand(rsp, 2 * kPointerSize)); 1826 __ movq(rdx, Operand(rsp, 2 * kPointerSize));
1828 1827
1829 __ JumpIfSmi(rdx, &miss); 1828 __ JumpIfSmi(rdx, &miss);
1830 1829
1831 CheckPrototypes(JSObject::cast(object), rdx, holder, rbx, rax, rdi, name, 1830 CheckPrototypes(JSObject::cast(object), rdx, holder, rbx, rax, rdi, name,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1868 return (cell == NULL) ? GetCode(function) : GetCode(NORMAL, name); 1867 return (cell == NULL) ? GetCode(function) : GetCode(NORMAL, name);
1869 } 1868 }
1870 1869
1871 1870
1872 MaybeObject* CallStubCompiler::CompileMathFloorCall(Object* object, 1871 MaybeObject* CallStubCompiler::CompileMathFloorCall(Object* object,
1873 JSObject* holder, 1872 JSObject* holder,
1874 JSGlobalPropertyCell* cell, 1873 JSGlobalPropertyCell* cell,
1875 JSFunction* function, 1874 JSFunction* function,
1876 String* name) { 1875 String* name) {
1877 // TODO(872): implement this. 1876 // TODO(872): implement this.
1878 return HEAP->undefined_value(); 1877 return heap()->undefined_value();
1879 } 1878 }
1880 1879
1881 1880
1882 MaybeObject* CallStubCompiler::CompileMathAbsCall(Object* object, 1881 MaybeObject* CallStubCompiler::CompileMathAbsCall(Object* object,
1883 JSObject* holder, 1882 JSObject* holder,
1884 JSGlobalPropertyCell* cell, 1883 JSGlobalPropertyCell* cell,
1885 JSFunction* function, 1884 JSFunction* function,
1886 String* name) { 1885 String* name) {
1887 // ----------- S t a t e ------------- 1886 // ----------- S t a t e -------------
1888 // -- rcx : function name 1887 // -- rcx : function name
1889 // -- rsp[0] : return address 1888 // -- rsp[0] : return address
1890 // -- rsp[(argc - n) * 8] : arg[n] (zero-based) 1889 // -- rsp[(argc - n) * 8] : arg[n] (zero-based)
1891 // -- ... 1890 // -- ...
1892 // -- rsp[(argc + 1) * 8] : receiver 1891 // -- rsp[(argc + 1) * 8] : receiver
1893 // ----------------------------------- 1892 // -----------------------------------
1894 1893
1895 const int argc = arguments().immediate(); 1894 const int argc = arguments().immediate();
1896 1895
1897 // If the object is not a JSObject or we got an unexpected number of 1896 // If the object is not a JSObject or we got an unexpected number of
1898 // arguments, bail out to the regular call. 1897 // arguments, bail out to the regular call.
1899 if (!object->IsJSObject() || argc != 1) return HEAP->undefined_value(); 1898 if (!object->IsJSObject() || argc != 1) return heap()->undefined_value();
1900 1899
1901 Label miss; 1900 Label miss;
1902 GenerateNameCheck(name, &miss); 1901 GenerateNameCheck(name, &miss);
1903 1902
1904 if (cell == NULL) { 1903 if (cell == NULL) {
1905 __ movq(rdx, Operand(rsp, 2 * kPointerSize)); 1904 __ movq(rdx, Operand(rsp, 2 * kPointerSize));
1906 1905
1907 __ JumpIfSmi(rdx, &miss); 1906 __ JumpIfSmi(rdx, &miss);
1908 1907
1909 CheckPrototypes(JSObject::cast(object), rdx, holder, rbx, rax, rdi, name, 1908 CheckPrototypes(JSObject::cast(object), rdx, holder, rbx, rax, rdi, name,
(...skipping 28 matching lines...) Expand all
1938 // This only happens for the most negative smi. 1937 // This only happens for the most negative smi.
1939 Label slow; 1938 Label slow;
1940 __ j(negative, &slow); 1939 __ j(negative, &slow);
1941 1940
1942 // Smi case done. 1941 // Smi case done.
1943 __ Integer32ToSmi(rax, rax); 1942 __ Integer32ToSmi(rax, rax);
1944 __ ret(2 * kPointerSize); 1943 __ ret(2 * kPointerSize);
1945 1944
1946 // Check if the argument is a heap number and load its value. 1945 // Check if the argument is a heap number and load its value.
1947 __ bind(&not_smi); 1946 __ bind(&not_smi);
1948 __ CheckMap(rax, FACTORY->heap_number_map(), &slow, true); 1947 __ CheckMap(rax, factory()->heap_number_map(), &slow, true);
1949 __ movq(rbx, FieldOperand(rax, HeapNumber::kValueOffset)); 1948 __ movq(rbx, FieldOperand(rax, HeapNumber::kValueOffset));
1950 1949
1951 // Check the sign of the argument. If the argument is positive, 1950 // Check the sign of the argument. If the argument is positive,
1952 // just return it. 1951 // just return it.
1953 Label negative_sign; 1952 Label negative_sign;
1954 const int sign_mask_shift = 1953 const int sign_mask_shift =
1955 (HeapNumber::kExponentOffset - HeapNumber::kValueOffset) * kBitsPerByte; 1954 (HeapNumber::kExponentOffset - HeapNumber::kValueOffset) * kBitsPerByte;
1956 __ movq(rdi, static_cast<int64_t>(HeapNumber::kSignMask) << sign_mask_shift, 1955 __ movq(rdi, static_cast<int64_t>(HeapNumber::kSignMask) << sign_mask_shift,
1957 RelocInfo::NONE); 1956 RelocInfo::NONE);
1958 __ testq(rbx, rdi); 1957 __ testq(rbx, rdi);
(...skipping 26 matching lines...) Expand all
1985 MaybeObject* CallStubCompiler::CompileFastApiCall( 1984 MaybeObject* CallStubCompiler::CompileFastApiCall(
1986 const CallOptimization& optimization, 1985 const CallOptimization& optimization,
1987 Object* object, 1986 Object* object,
1988 JSObject* holder, 1987 JSObject* holder,
1989 JSGlobalPropertyCell* cell, 1988 JSGlobalPropertyCell* cell,
1990 JSFunction* function, 1989 JSFunction* function,
1991 String* name) { 1990 String* name) {
1992 ASSERT(optimization.is_simple_api_call()); 1991 ASSERT(optimization.is_simple_api_call());
1993 // Bail out if object is a global object as we don't want to 1992 // Bail out if object is a global object as we don't want to
1994 // repatch it to global receiver. 1993 // repatch it to global receiver.
1995 if (object->IsGlobalObject()) return HEAP->undefined_value(); 1994 if (object->IsGlobalObject()) return heap()->undefined_value();
1996 if (cell != NULL) return HEAP->undefined_value(); 1995 if (cell != NULL) return heap()->undefined_value();
1997 int depth = optimization.GetPrototypeDepthOfExpectedType( 1996 int depth = optimization.GetPrototypeDepthOfExpectedType(
1998 JSObject::cast(object), holder); 1997 JSObject::cast(object), holder);
1999 if (depth == kInvalidProtoDepth) return HEAP->undefined_value(); 1998 if (depth == kInvalidProtoDepth) return heap()->undefined_value();
2000 1999
2001 Label miss, miss_before_stack_reserved; 2000 Label miss, miss_before_stack_reserved;
2002 2001
2003 GenerateNameCheck(name, &miss_before_stack_reserved); 2002 GenerateNameCheck(name, &miss_before_stack_reserved);
2004 2003
2005 // Get the receiver from the stack. 2004 // Get the receiver from the stack.
2006 const int argc = arguments().immediate(); 2005 const int argc = arguments().immediate();
2007 __ movq(rdx, Operand(rsp, (argc + 1) * kPointerSize)); 2006 __ movq(rdx, Operand(rsp, (argc + 1) * kPointerSize));
2008 2007
2009 // Check that the receiver isn't a smi. 2008 // Check that the receiver isn't a smi.
2010 __ JumpIfSmi(rdx, &miss_before_stack_reserved); 2009 __ JumpIfSmi(rdx, &miss_before_stack_reserved);
2011 2010
2012 Counters* counters = masm()->isolate()->counters(); 2011 Counters* counters = isolate()->counters();
2013 __ IncrementCounter(counters->call_const(), 1); 2012 __ IncrementCounter(counters->call_const(), 1);
2014 __ IncrementCounter(counters->call_const_fast_api(), 1); 2013 __ IncrementCounter(counters->call_const_fast_api(), 1);
2015 2014
2016 // Allocate space for v8::Arguments implicit values. Must be initialized 2015 // Allocate space for v8::Arguments implicit values. Must be initialized
2017 // before calling any runtime function. 2016 // before calling any runtime function.
2018 __ subq(rsp, Immediate(kFastApiCallArguments * kPointerSize)); 2017 __ subq(rsp, Immediate(kFastApiCallArguments * kPointerSize));
2019 2018
2020 // Check that the maps haven't changed and find a Holder as a side effect. 2019 // Check that the maps haven't changed and find a Holder as a side effect.
2021 CheckPrototypes(JSObject::cast(object), rdx, holder, 2020 CheckPrototypes(JSObject::cast(object), rdx, holder,
2022 rbx, rax, rdi, name, depth, &miss); 2021 rbx, rax, rdi, name, depth, &miss);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
2074 2073
2075 // Check that the receiver isn't a smi. 2074 // Check that the receiver isn't a smi.
2076 if (check != NUMBER_CHECK) { 2075 if (check != NUMBER_CHECK) {
2077 __ JumpIfSmi(rdx, &miss); 2076 __ JumpIfSmi(rdx, &miss);
2078 } 2077 }
2079 2078
2080 // Make sure that it's okay not to patch the on stack receiver 2079 // Make sure that it's okay not to patch the on stack receiver
2081 // unless we're doing a receiver map check. 2080 // unless we're doing a receiver map check.
2082 ASSERT(!object->IsGlobalObject() || check == RECEIVER_MAP_CHECK); 2081 ASSERT(!object->IsGlobalObject() || check == RECEIVER_MAP_CHECK);
2083 2082
2084 Counters* counters = masm()->isolate()->counters(); 2083 Counters* counters = isolate()->counters();
2085 SharedFunctionInfo* function_info = function->shared(); 2084 SharedFunctionInfo* function_info = function->shared();
2086 switch (check) { 2085 switch (check) {
2087 case RECEIVER_MAP_CHECK: 2086 case RECEIVER_MAP_CHECK:
2088 __ IncrementCounter(counters->call_const(), 1); 2087 __ IncrementCounter(counters->call_const(), 1);
2089 2088
2090 // Check that the maps haven't changed. 2089 // Check that the maps haven't changed.
2091 CheckPrototypes(JSObject::cast(object), rdx, holder, 2090 CheckPrototypes(JSObject::cast(object), rdx, holder,
2092 rbx, rax, rdi, name, &miss); 2091 rbx, rax, rdi, name, &miss);
2093 2092
2094 // Patch the receiver on the stack with the global proxy if 2093 // Patch the receiver on the stack with the global proxy if
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
2280 // Patch the receiver on the stack with the global proxy. 2279 // Patch the receiver on the stack with the global proxy.
2281 if (object->IsGlobalObject()) { 2280 if (object->IsGlobalObject()) {
2282 __ movq(rdx, FieldOperand(rdx, GlobalObject::kGlobalReceiverOffset)); 2281 __ movq(rdx, FieldOperand(rdx, GlobalObject::kGlobalReceiverOffset));
2283 __ movq(Operand(rsp, (argc + 1) * kPointerSize), rdx); 2282 __ movq(Operand(rsp, (argc + 1) * kPointerSize), rdx);
2284 } 2283 }
2285 2284
2286 // Setup the context (function already in rdi). 2285 // Setup the context (function already in rdi).
2287 __ movq(rsi, FieldOperand(rdi, JSFunction::kContextOffset)); 2286 __ movq(rsi, FieldOperand(rdi, JSFunction::kContextOffset));
2288 2287
2289 // Jump to the cached code (tail call). 2288 // Jump to the cached code (tail call).
2290 Counters* counters = masm()->isolate()->counters(); 2289 Counters* counters = isolate()->counters();
2291 __ IncrementCounter(counters->call_global_inline(), 1); 2290 __ IncrementCounter(counters->call_global_inline(), 1);
2292 ASSERT(function->is_compiled()); 2291 ASSERT(function->is_compiled());
2293 ParameterCount expected(function->shared()->formal_parameter_count()); 2292 ParameterCount expected(function->shared()->formal_parameter_count());
2294 if (V8::UseCrankshaft()) { 2293 if (V8::UseCrankshaft()) {
2295 // TODO(kasperl): For now, we always call indirectly through the 2294 // TODO(kasperl): For now, we always call indirectly through the
2296 // code field in the function to allow recompilation to take effect 2295 // code field in the function to allow recompilation to take effect
2297 // without changing any of the call sites. 2296 // without changing any of the call sites.
2298 __ movq(rdx, FieldOperand(rdi, JSFunction::kCodeEntryOffset)); 2297 __ movq(rdx, FieldOperand(rdi, JSFunction::kCodeEntryOffset));
2299 __ InvokeCode(rdx, expected, arguments(), JUMP_FUNCTION); 2298 __ InvokeCode(rdx, expected, arguments(), JUMP_FUNCTION);
2300 } else { 2299 } else {
(...skipping 27 matching lines...) Expand all
2328 // Generate store field code. Preserves receiver and name on jump to miss. 2327 // Generate store field code. Preserves receiver and name on jump to miss.
2329 GenerateStoreField(masm(), 2328 GenerateStoreField(masm(),
2330 object, 2329 object,
2331 index, 2330 index,
2332 transition, 2331 transition,
2333 rdx, rcx, rbx, 2332 rdx, rcx, rbx,
2334 &miss); 2333 &miss);
2335 2334
2336 // Handle store cache miss. 2335 // Handle store cache miss.
2337 __ bind(&miss); 2336 __ bind(&miss);
2338 Handle<Code> ic = masm()->isolate()->builtins()->StoreIC_Miss(); 2337 Handle<Code> ic = isolate()->builtins()->StoreIC_Miss();
2339 __ Jump(ic, RelocInfo::CODE_TARGET); 2338 __ Jump(ic, RelocInfo::CODE_TARGET);
2340 2339
2341 // Return the generated code. 2340 // Return the generated code.
2342 return GetCode(transition == NULL ? FIELD : MAP_TRANSITION, name); 2341 return GetCode(transition == NULL ? FIELD : MAP_TRANSITION, name);
2343 } 2342 }
2344 2343
2345 2344
2346 MaybeObject* StoreStubCompiler::CompileStoreCallback(JSObject* object, 2345 MaybeObject* StoreStubCompiler::CompileStoreCallback(JSObject* object,
2347 AccessorInfo* callback, 2346 AccessorInfo* callback,
2348 String* name) { 2347 String* name) {
(...skipping 24 matching lines...) Expand all
2373 2372
2374 __ pop(rbx); // remove the return address 2373 __ pop(rbx); // remove the return address
2375 __ push(rdx); // receiver 2374 __ push(rdx); // receiver
2376 __ Push(Handle<AccessorInfo>(callback)); // callback info 2375 __ Push(Handle<AccessorInfo>(callback)); // callback info
2377 __ push(rcx); // name 2376 __ push(rcx); // name
2378 __ push(rax); // value 2377 __ push(rax); // value
2379 __ push(rbx); // restore return address 2378 __ push(rbx); // restore return address
2380 2379
2381 // Do tail-call to the runtime system. 2380 // Do tail-call to the runtime system.
2382 ExternalReference store_callback_property = 2381 ExternalReference store_callback_property =
2383 ExternalReference(IC_Utility(IC::kStoreCallbackProperty), 2382 ExternalReference(IC_Utility(IC::kStoreCallbackProperty), isolate());
2384 masm()->isolate());
2385 __ TailCallExternalReference(store_callback_property, 4, 1); 2383 __ TailCallExternalReference(store_callback_property, 4, 1);
2386 2384
2387 // Handle store cache miss. 2385 // Handle store cache miss.
2388 __ bind(&miss); 2386 __ bind(&miss);
2389 Handle<Code> ic = masm()->isolate()->builtins()->StoreIC_Miss(); 2387 Handle<Code> ic = isolate()->builtins()->StoreIC_Miss();
2390 __ Jump(ic, RelocInfo::CODE_TARGET); 2388 __ Jump(ic, RelocInfo::CODE_TARGET);
2391 2389
2392 // Return the generated code. 2390 // Return the generated code.
2393 return GetCode(CALLBACKS, name); 2391 return GetCode(CALLBACKS, name);
2394 } 2392 }
2395 2393
2396 2394
2397 MaybeObject* StoreStubCompiler::CompileStoreInterceptor(JSObject* receiver, 2395 MaybeObject* StoreStubCompiler::CompileStoreInterceptor(JSObject* receiver,
2398 String* name) { 2396 String* name) {
2399 // ----------- S t a t e ------------- 2397 // ----------- S t a t e -------------
(...skipping 23 matching lines...) Expand all
2423 2421
2424 __ pop(rbx); // remove the return address 2422 __ pop(rbx); // remove the return address
2425 __ push(rdx); // receiver 2423 __ push(rdx); // receiver
2426 __ push(rcx); // name 2424 __ push(rcx); // name
2427 __ push(rax); // value 2425 __ push(rax); // value
2428 __ Push(Smi::FromInt(strict_mode_)); 2426 __ Push(Smi::FromInt(strict_mode_));
2429 __ push(rbx); // restore return address 2427 __ push(rbx); // restore return address
2430 2428
2431 // Do tail-call to the runtime system. 2429 // Do tail-call to the runtime system.
2432 ExternalReference store_ic_property = 2430 ExternalReference store_ic_property =
2433 ExternalReference(IC_Utility(IC::kStoreInterceptorProperty), 2431 ExternalReference(IC_Utility(IC::kStoreInterceptorProperty), isolate());
2434 masm()->isolate());
2435 __ TailCallExternalReference(store_ic_property, 4, 1); 2432 __ TailCallExternalReference(store_ic_property, 4, 1);
2436 2433
2437 // Handle store cache miss. 2434 // Handle store cache miss.
2438 __ bind(&miss); 2435 __ bind(&miss);
2439 Handle<Code> ic = masm()->isolate()->builtins()->StoreIC_Miss(); 2436 Handle<Code> ic = isolate()->builtins()->StoreIC_Miss();
2440 __ Jump(ic, RelocInfo::CODE_TARGET); 2437 __ Jump(ic, RelocInfo::CODE_TARGET);
2441 2438
2442 // Return the generated code. 2439 // Return the generated code.
2443 return GetCode(INTERCEPTOR, name); 2440 return GetCode(INTERCEPTOR, name);
2444 } 2441 }
2445 2442
2446 2443
2447 MaybeObject* StoreStubCompiler::CompileStoreGlobal(GlobalObject* object, 2444 MaybeObject* StoreStubCompiler::CompileStoreGlobal(GlobalObject* object,
2448 JSGlobalPropertyCell* cell, 2445 JSGlobalPropertyCell* cell,
2449 String* name) { 2446 String* name) {
(...skipping 16 matching lines...) Expand all
2466 // global object. We bail out to the runtime system to do that. 2463 // global object. We bail out to the runtime system to do that.
2467 __ Move(rbx, Handle<JSGlobalPropertyCell>(cell)); 2464 __ Move(rbx, Handle<JSGlobalPropertyCell>(cell));
2468 __ CompareRoot(FieldOperand(rbx, JSGlobalPropertyCell::kValueOffset), 2465 __ CompareRoot(FieldOperand(rbx, JSGlobalPropertyCell::kValueOffset),
2469 Heap::kTheHoleValueRootIndex); 2466 Heap::kTheHoleValueRootIndex);
2470 __ j(equal, &miss); 2467 __ j(equal, &miss);
2471 2468
2472 // Store the value in the cell. 2469 // Store the value in the cell.
2473 __ movq(FieldOperand(rbx, JSGlobalPropertyCell::kValueOffset), rax); 2470 __ movq(FieldOperand(rbx, JSGlobalPropertyCell::kValueOffset), rax);
2474 2471
2475 // Return the value (register rax). 2472 // Return the value (register rax).
2476 Counters* counters = masm()->isolate()->counters(); 2473 Counters* counters = isolate()->counters();
2477 __ IncrementCounter(counters->named_store_global_inline(), 1); 2474 __ IncrementCounter(counters->named_store_global_inline(), 1);
2478 __ ret(0); 2475 __ ret(0);
2479 2476
2480 // Handle store cache miss. 2477 // Handle store cache miss.
2481 __ bind(&miss); 2478 __ bind(&miss);
2482 __ IncrementCounter(counters->named_store_global_inline_miss(), 1); 2479 __ IncrementCounter(counters->named_store_global_inline_miss(), 1);
2483 Handle<Code> ic = masm()->isolate()->builtins()->StoreIC_Miss(); 2480 Handle<Code> ic = isolate()->builtins()->StoreIC_Miss();
2484 __ Jump(ic, RelocInfo::CODE_TARGET); 2481 __ Jump(ic, RelocInfo::CODE_TARGET);
2485 2482
2486 // Return the generated code. 2483 // Return the generated code.
2487 return GetCode(NORMAL, name); 2484 return GetCode(NORMAL, name);
2488 } 2485 }
2489 2486
2490 2487
2491 MaybeObject* KeyedStoreStubCompiler::CompileStoreField(JSObject* object, 2488 MaybeObject* KeyedStoreStubCompiler::CompileStoreField(JSObject* object,
2492 int index, 2489 int index,
2493 Map* transition, 2490 Map* transition,
2494 String* name) { 2491 String* name) {
2495 // ----------- S t a t e ------------- 2492 // ----------- S t a t e -------------
2496 // -- rax : value 2493 // -- rax : value
2497 // -- rcx : key 2494 // -- rcx : key
2498 // -- rdx : receiver 2495 // -- rdx : receiver
2499 // -- rsp[0] : return address 2496 // -- rsp[0] : return address
2500 // ----------------------------------- 2497 // -----------------------------------
2501 Label miss; 2498 Label miss;
2502 2499
2503 Counters* counters = masm()->isolate()->counters(); 2500 Counters* counters = isolate()->counters();
2504 __ IncrementCounter(counters->keyed_store_field(), 1); 2501 __ IncrementCounter(counters->keyed_store_field(), 1);
2505 2502
2506 // Check that the name has not changed. 2503 // Check that the name has not changed.
2507 __ Cmp(rcx, Handle<String>(name)); 2504 __ Cmp(rcx, Handle<String>(name));
2508 __ j(not_equal, &miss); 2505 __ j(not_equal, &miss);
2509 2506
2510 // Generate store field code. Preserves receiver and name on jump to miss. 2507 // Generate store field code. Preserves receiver and name on jump to miss.
2511 GenerateStoreField(masm(), 2508 GenerateStoreField(masm(),
2512 object, 2509 object,
2513 index, 2510 index,
2514 transition, 2511 transition,
2515 rdx, rcx, rbx, 2512 rdx, rcx, rbx,
2516 &miss); 2513 &miss);
2517 2514
2518 // Handle store cache miss. 2515 // Handle store cache miss.
2519 __ bind(&miss); 2516 __ bind(&miss);
2520 __ DecrementCounter(counters->keyed_store_field(), 1); 2517 __ DecrementCounter(counters->keyed_store_field(), 1);
2521 Handle<Code> ic = masm()->isolate()->builtins()->KeyedStoreIC_Miss(); 2518 Handle<Code> ic = isolate()->builtins()->KeyedStoreIC_Miss();
2522 __ Jump(ic, RelocInfo::CODE_TARGET); 2519 __ Jump(ic, RelocInfo::CODE_TARGET);
2523 2520
2524 // Return the generated code. 2521 // Return the generated code.
2525 return GetCode(transition == NULL ? FIELD : MAP_TRANSITION, name); 2522 return GetCode(transition == NULL ? FIELD : MAP_TRANSITION, name);
2526 } 2523 }
2527 2524
2528 2525
2529 MaybeObject* KeyedStoreStubCompiler::CompileStoreSpecialized( 2526 MaybeObject* KeyedStoreStubCompiler::CompileStoreSpecialized(
2530 JSObject* receiver) { 2527 JSObject* receiver) {
2531 // ----------- S t a t e ------------- 2528 // ----------- S t a t e -------------
(...skipping 11 matching lines...) Expand all
2543 __ Cmp(FieldOperand(rdx, HeapObject::kMapOffset), 2540 __ Cmp(FieldOperand(rdx, HeapObject::kMapOffset),
2544 Handle<Map>(receiver->map())); 2541 Handle<Map>(receiver->map()));
2545 __ j(not_equal, &miss); 2542 __ j(not_equal, &miss);
2546 2543
2547 // Check that the key is a smi. 2544 // Check that the key is a smi.
2548 __ JumpIfNotSmi(rcx, &miss); 2545 __ JumpIfNotSmi(rcx, &miss);
2549 2546
2550 // Get the elements array and make sure it is a fast element array, not 'cow'. 2547 // Get the elements array and make sure it is a fast element array, not 'cow'.
2551 __ movq(rdi, FieldOperand(rdx, JSObject::kElementsOffset)); 2548 __ movq(rdi, FieldOperand(rdx, JSObject::kElementsOffset));
2552 __ Cmp(FieldOperand(rdi, HeapObject::kMapOffset), 2549 __ Cmp(FieldOperand(rdi, HeapObject::kMapOffset),
2553 FACTORY->fixed_array_map()); 2550 factory()->fixed_array_map());
2554 __ j(not_equal, &miss); 2551 __ j(not_equal, &miss);
2555 2552
2556 // Check that the key is within bounds. 2553 // Check that the key is within bounds.
2557 if (receiver->IsJSArray()) { 2554 if (receiver->IsJSArray()) {
2558 __ SmiCompare(rcx, FieldOperand(rdx, JSArray::kLengthOffset)); 2555 __ SmiCompare(rcx, FieldOperand(rdx, JSArray::kLengthOffset));
2559 __ j(above_equal, &miss); 2556 __ j(above_equal, &miss);
2560 } else { 2557 } else {
2561 __ SmiCompare(rcx, FieldOperand(rdi, FixedArray::kLengthOffset)); 2558 __ SmiCompare(rcx, FieldOperand(rdi, FixedArray::kLengthOffset));
2562 __ j(above_equal, &miss); 2559 __ j(above_equal, &miss);
2563 } 2560 }
2564 2561
2565 // Do the store and update the write barrier. Make sure to preserve 2562 // Do the store and update the write barrier. Make sure to preserve
2566 // the value in register eax. 2563 // the value in register eax.
2567 __ movq(rdx, rax); 2564 __ movq(rdx, rax);
2568 __ SmiToInteger32(rcx, rcx); 2565 __ SmiToInteger32(rcx, rcx);
2569 __ movq(FieldOperand(rdi, rcx, times_pointer_size, FixedArray::kHeaderSize), 2566 __ movq(FieldOperand(rdi, rcx, times_pointer_size, FixedArray::kHeaderSize),
2570 rax); 2567 rax);
2571 __ RecordWrite(rdi, 0, rdx, rcx); 2568 __ RecordWrite(rdi, 0, rdx, rcx);
2572 2569
2573 // Done. 2570 // Done.
2574 __ ret(0); 2571 __ ret(0);
2575 2572
2576 // Handle store cache miss. 2573 // Handle store cache miss.
2577 __ bind(&miss); 2574 __ bind(&miss);
2578 Handle<Code> ic = masm()->isolate()->builtins()->KeyedStoreIC_Miss(); 2575 Handle<Code> ic = isolate()->builtins()->KeyedStoreIC_Miss();
2579 __ jmp(ic, RelocInfo::CODE_TARGET); 2576 __ jmp(ic, RelocInfo::CODE_TARGET);
2580 2577
2581 // Return the generated code. 2578 // Return the generated code.
2582 return GetCode(NORMAL, NULL); 2579 return GetCode(NORMAL, NULL);
2583 } 2580 }
2584 2581
2585 2582
2586 MaybeObject* LoadStubCompiler::CompileLoadNonexistent(String* name, 2583 MaybeObject* LoadStubCompiler::CompileLoadNonexistent(String* name,
2587 JSObject* object, 2584 JSObject* object,
2588 JSObject* last) { 2585 JSObject* last) {
(...skipping 28 matching lines...) Expand all
2617 2614
2618 // Return undefined if maps of the full prototype chain are still the 2615 // Return undefined if maps of the full prototype chain are still the
2619 // same and no global property with this name contains a value. 2616 // same and no global property with this name contains a value.
2620 __ LoadRoot(rax, Heap::kUndefinedValueRootIndex); 2617 __ LoadRoot(rax, Heap::kUndefinedValueRootIndex);
2621 __ ret(0); 2618 __ ret(0);
2622 2619
2623 __ bind(&miss); 2620 __ bind(&miss);
2624 GenerateLoadMiss(masm(), Code::LOAD_IC); 2621 GenerateLoadMiss(masm(), Code::LOAD_IC);
2625 2622
2626 // Return the generated code. 2623 // Return the generated code.
2627 return GetCode(NONEXISTENT, HEAP->empty_string()); 2624 return GetCode(NONEXISTENT, heap()->empty_string());
2628 } 2625 }
2629 2626
2630 2627
2631 MaybeObject* LoadStubCompiler::CompileLoadField(JSObject* object, 2628 MaybeObject* LoadStubCompiler::CompileLoadField(JSObject* object,
2632 JSObject* holder, 2629 JSObject* holder,
2633 int index, 2630 int index,
2634 String* name) { 2631 String* name) {
2635 // ----------- S t a t e ------------- 2632 // ----------- S t a t e -------------
2636 // -- rax : receiver 2633 // -- rax : receiver
2637 // -- rcx : name 2634 // -- rcx : name
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
2756 2753
2757 // Check for deleted property if property can actually be deleted. 2754 // Check for deleted property if property can actually be deleted.
2758 if (!is_dont_delete) { 2755 if (!is_dont_delete) {
2759 __ CompareRoot(rbx, Heap::kTheHoleValueRootIndex); 2756 __ CompareRoot(rbx, Heap::kTheHoleValueRootIndex);
2760 __ j(equal, &miss); 2757 __ j(equal, &miss);
2761 } else if (FLAG_debug_code) { 2758 } else if (FLAG_debug_code) {
2762 __ CompareRoot(rbx, Heap::kTheHoleValueRootIndex); 2759 __ CompareRoot(rbx, Heap::kTheHoleValueRootIndex);
2763 __ Check(not_equal, "DontDelete cells can't contain the hole"); 2760 __ Check(not_equal, "DontDelete cells can't contain the hole");
2764 } 2761 }
2765 2762
2766 Counters* counters = masm()->isolate()->counters(); 2763 Counters* counters = isolate()->counters();
2767 __ IncrementCounter(counters->named_load_global_stub(), 1); 2764 __ IncrementCounter(counters->named_load_global_stub(), 1);
2768 __ movq(rax, rbx); 2765 __ movq(rax, rbx);
2769 __ ret(0); 2766 __ ret(0);
2770 2767
2771 __ bind(&miss); 2768 __ bind(&miss);
2772 __ IncrementCounter(counters->named_load_global_stub_miss(), 1); 2769 __ IncrementCounter(counters->named_load_global_stub_miss(), 1);
2773 GenerateLoadMiss(masm(), Code::LOAD_IC); 2770 GenerateLoadMiss(masm(), Code::LOAD_IC);
2774 2771
2775 // Return the generated code. 2772 // Return the generated code.
2776 return GetCode(NORMAL, name); 2773 return GetCode(NORMAL, name);
2777 } 2774 }
2778 2775
2779 2776
2780 MaybeObject* KeyedLoadStubCompiler::CompileLoadField(String* name, 2777 MaybeObject* KeyedLoadStubCompiler::CompileLoadField(String* name,
2781 JSObject* receiver, 2778 JSObject* receiver,
2782 JSObject* holder, 2779 JSObject* holder,
2783 int index) { 2780 int index) {
2784 // ----------- S t a t e ------------- 2781 // ----------- S t a t e -------------
2785 // -- rax : key 2782 // -- rax : key
2786 // -- rdx : receiver 2783 // -- rdx : receiver
2787 // -- rsp[0] : return address 2784 // -- rsp[0] : return address
2788 // ----------------------------------- 2785 // -----------------------------------
2789 Label miss; 2786 Label miss;
2790 2787
2791 Counters* counters = masm()->isolate()->counters(); 2788 Counters* counters = isolate()->counters();
2792 __ IncrementCounter(counters->keyed_load_field(), 1); 2789 __ IncrementCounter(counters->keyed_load_field(), 1);
2793 2790
2794 // Check that the name has not changed. 2791 // Check that the name has not changed.
2795 __ Cmp(rax, Handle<String>(name)); 2792 __ Cmp(rax, Handle<String>(name));
2796 __ j(not_equal, &miss); 2793 __ j(not_equal, &miss);
2797 2794
2798 GenerateLoadField(receiver, holder, rdx, rbx, rcx, rdi, index, name, &miss); 2795 GenerateLoadField(receiver, holder, rdx, rbx, rcx, rdi, index, name, &miss);
2799 2796
2800 __ bind(&miss); 2797 __ bind(&miss);
2801 __ DecrementCounter(counters->keyed_load_field(), 1); 2798 __ DecrementCounter(counters->keyed_load_field(), 1);
2802 GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC); 2799 GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC);
2803 2800
2804 // Return the generated code. 2801 // Return the generated code.
2805 return GetCode(FIELD, name); 2802 return GetCode(FIELD, name);
2806 } 2803 }
2807 2804
2808 2805
2809 MaybeObject* KeyedLoadStubCompiler::CompileLoadCallback( 2806 MaybeObject* KeyedLoadStubCompiler::CompileLoadCallback(
2810 String* name, 2807 String* name,
2811 JSObject* receiver, 2808 JSObject* receiver,
2812 JSObject* holder, 2809 JSObject* holder,
2813 AccessorInfo* callback) { 2810 AccessorInfo* callback) {
2814 // ----------- S t a t e ------------- 2811 // ----------- S t a t e -------------
2815 // -- rax : key 2812 // -- rax : key
2816 // -- rdx : receiver 2813 // -- rdx : receiver
2817 // -- rsp[0] : return address 2814 // -- rsp[0] : return address
2818 // ----------------------------------- 2815 // -----------------------------------
2819 Label miss; 2816 Label miss;
2820 2817
2821 Counters* counters = masm()->isolate()->counters(); 2818 Counters* counters = isolate()->counters();
2822 __ IncrementCounter(counters->keyed_load_callback(), 1); 2819 __ IncrementCounter(counters->keyed_load_callback(), 1);
2823 2820
2824 // Check that the name has not changed. 2821 // Check that the name has not changed.
2825 __ Cmp(rax, Handle<String>(name)); 2822 __ Cmp(rax, Handle<String>(name));
2826 __ j(not_equal, &miss); 2823 __ j(not_equal, &miss);
2827 2824
2828 MaybeObject* result = GenerateLoadCallback(receiver, holder, rdx, rax, rbx, 2825 MaybeObject* result = GenerateLoadCallback(receiver, holder, rdx, rax, rbx,
2829 rcx, rdi, callback, name, &miss); 2826 rcx, rdi, callback, name, &miss);
2830 if (result->IsFailure()) { 2827 if (result->IsFailure()) {
2831 miss.Unuse(); 2828 miss.Unuse();
(...skipping 14 matching lines...) Expand all
2846 JSObject* receiver, 2843 JSObject* receiver,
2847 JSObject* holder, 2844 JSObject* holder,
2848 Object* value) { 2845 Object* value) {
2849 // ----------- S t a t e ------------- 2846 // ----------- S t a t e -------------
2850 // -- rax : key 2847 // -- rax : key
2851 // -- rdx : receiver 2848 // -- rdx : receiver
2852 // -- rsp[0] : return address 2849 // -- rsp[0] : return address
2853 // ----------------------------------- 2850 // -----------------------------------
2854 Label miss; 2851 Label miss;
2855 2852
2856 Counters* counters = masm()->isolate()->counters(); 2853 Counters* counters = isolate()->counters();
2857 __ IncrementCounter(counters->keyed_load_constant_function(), 1); 2854 __ IncrementCounter(counters->keyed_load_constant_function(), 1);
2858 2855
2859 // Check that the name has not changed. 2856 // Check that the name has not changed.
2860 __ Cmp(rax, Handle<String>(name)); 2857 __ Cmp(rax, Handle<String>(name));
2861 __ j(not_equal, &miss); 2858 __ j(not_equal, &miss);
2862 2859
2863 GenerateLoadConstant(receiver, holder, rdx, rbx, rcx, rdi, 2860 GenerateLoadConstant(receiver, holder, rdx, rbx, rcx, rdi,
2864 value, name, &miss); 2861 value, name, &miss);
2865 __ bind(&miss); 2862 __ bind(&miss);
2866 __ DecrementCounter(counters->keyed_load_constant_function(), 1); 2863 __ DecrementCounter(counters->keyed_load_constant_function(), 1);
2867 GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC); 2864 GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC);
2868 2865
2869 // Return the generated code. 2866 // Return the generated code.
2870 return GetCode(CONSTANT_FUNCTION, name); 2867 return GetCode(CONSTANT_FUNCTION, name);
2871 } 2868 }
2872 2869
2873 2870
2874 MaybeObject* KeyedLoadStubCompiler::CompileLoadInterceptor(JSObject* receiver, 2871 MaybeObject* KeyedLoadStubCompiler::CompileLoadInterceptor(JSObject* receiver,
2875 JSObject* holder, 2872 JSObject* holder,
2876 String* name) { 2873 String* name) {
2877 // ----------- S t a t e ------------- 2874 // ----------- S t a t e -------------
2878 // -- rax : key 2875 // -- rax : key
2879 // -- rdx : receiver 2876 // -- rdx : receiver
2880 // -- rsp[0] : return address 2877 // -- rsp[0] : return address
2881 // ----------------------------------- 2878 // -----------------------------------
2882 Label miss; 2879 Label miss;
2883 2880
2884 Counters* counters = masm()->isolate()->counters(); 2881 Counters* counters = isolate()->counters();
2885 __ IncrementCounter(counters->keyed_load_interceptor(), 1); 2882 __ IncrementCounter(counters->keyed_load_interceptor(), 1);
2886 2883
2887 // Check that the name has not changed. 2884 // Check that the name has not changed.
2888 __ Cmp(rax, Handle<String>(name)); 2885 __ Cmp(rax, Handle<String>(name));
2889 __ j(not_equal, &miss); 2886 __ j(not_equal, &miss);
2890 2887
2891 LookupResult lookup; 2888 LookupResult lookup;
2892 LookupPostInterceptor(holder, name, &lookup); 2889 LookupPostInterceptor(holder, name, &lookup);
2893 GenerateLoadInterceptor(receiver, 2890 GenerateLoadInterceptor(receiver,
2894 holder, 2891 holder,
(...skipping 15 matching lines...) Expand all
2910 2907
2911 2908
2912 MaybeObject* KeyedLoadStubCompiler::CompileLoadArrayLength(String* name) { 2909 MaybeObject* KeyedLoadStubCompiler::CompileLoadArrayLength(String* name) {
2913 // ----------- S t a t e ------------- 2910 // ----------- S t a t e -------------
2914 // -- rax : key 2911 // -- rax : key
2915 // -- rdx : receiver 2912 // -- rdx : receiver
2916 // -- rsp[0] : return address 2913 // -- rsp[0] : return address
2917 // ----------------------------------- 2914 // -----------------------------------
2918 Label miss; 2915 Label miss;
2919 2916
2920 Counters* counters = masm()->isolate()->counters(); 2917 Counters* counters = isolate()->counters();
2921 __ IncrementCounter(counters->keyed_load_array_length(), 1); 2918 __ IncrementCounter(counters->keyed_load_array_length(), 1);
2922 2919
2923 // Check that the name has not changed. 2920 // Check that the name has not changed.
2924 __ Cmp(rax, Handle<String>(name)); 2921 __ Cmp(rax, Handle<String>(name));
2925 __ j(not_equal, &miss); 2922 __ j(not_equal, &miss);
2926 2923
2927 GenerateLoadArrayLength(masm(), rdx, rcx, &miss); 2924 GenerateLoadArrayLength(masm(), rdx, rcx, &miss);
2928 __ bind(&miss); 2925 __ bind(&miss);
2929 __ DecrementCounter(counters->keyed_load_array_length(), 1); 2926 __ DecrementCounter(counters->keyed_load_array_length(), 1);
2930 GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC); 2927 GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC);
2931 2928
2932 // Return the generated code. 2929 // Return the generated code.
2933 return GetCode(CALLBACKS, name); 2930 return GetCode(CALLBACKS, name);
2934 } 2931 }
2935 2932
2936 2933
2937 MaybeObject* KeyedLoadStubCompiler::CompileLoadStringLength(String* name) { 2934 MaybeObject* KeyedLoadStubCompiler::CompileLoadStringLength(String* name) {
2938 // ----------- S t a t e ------------- 2935 // ----------- S t a t e -------------
2939 // -- rax : key 2936 // -- rax : key
2940 // -- rdx : receiver 2937 // -- rdx : receiver
2941 // -- rsp[0] : return address 2938 // -- rsp[0] : return address
2942 // ----------------------------------- 2939 // -----------------------------------
2943 Label miss; 2940 Label miss;
2944 2941
2945 Counters* counters = masm()->isolate()->counters(); 2942 Counters* counters = isolate()->counters();
2946 __ IncrementCounter(counters->keyed_load_string_length(), 1); 2943 __ IncrementCounter(counters->keyed_load_string_length(), 1);
2947 2944
2948 // Check that the name has not changed. 2945 // Check that the name has not changed.
2949 __ Cmp(rax, Handle<String>(name)); 2946 __ Cmp(rax, Handle<String>(name));
2950 __ j(not_equal, &miss); 2947 __ j(not_equal, &miss);
2951 2948
2952 GenerateLoadStringLength(masm(), rdx, rcx, rbx, &miss, true); 2949 GenerateLoadStringLength(masm(), rdx, rcx, rbx, &miss, true);
2953 __ bind(&miss); 2950 __ bind(&miss);
2954 __ DecrementCounter(counters->keyed_load_string_length(), 1); 2951 __ DecrementCounter(counters->keyed_load_string_length(), 1);
2955 GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC); 2952 GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC);
2956 2953
2957 // Return the generated code. 2954 // Return the generated code.
2958 return GetCode(CALLBACKS, name); 2955 return GetCode(CALLBACKS, name);
2959 } 2956 }
2960 2957
2961 2958
2962 MaybeObject* KeyedLoadStubCompiler::CompileLoadFunctionPrototype(String* name) { 2959 MaybeObject* KeyedLoadStubCompiler::CompileLoadFunctionPrototype(String* name) {
2963 // ----------- S t a t e ------------- 2960 // ----------- S t a t e -------------
2964 // -- rax : key 2961 // -- rax : key
2965 // -- rdx : receiver 2962 // -- rdx : receiver
2966 // -- rsp[0] : return address 2963 // -- rsp[0] : return address
2967 // ----------------------------------- 2964 // -----------------------------------
2968 Label miss; 2965 Label miss;
2969 2966
2970 Counters* counters = masm()->isolate()->counters(); 2967 Counters* counters = isolate()->counters();
2971 __ IncrementCounter(counters->keyed_load_function_prototype(), 1); 2968 __ IncrementCounter(counters->keyed_load_function_prototype(), 1);
2972 2969
2973 // Check that the name has not changed. 2970 // Check that the name has not changed.
2974 __ Cmp(rax, Handle<String>(name)); 2971 __ Cmp(rax, Handle<String>(name));
2975 __ j(not_equal, &miss); 2972 __ j(not_equal, &miss);
2976 2973
2977 GenerateLoadFunctionPrototype(masm(), rdx, rcx, rbx, &miss); 2974 GenerateLoadFunctionPrototype(masm(), rdx, rcx, rbx, &miss);
2978 __ bind(&miss); 2975 __ bind(&miss);
2979 __ DecrementCounter(counters->keyed_load_function_prototype(), 1); 2976 __ DecrementCounter(counters->keyed_load_function_prototype(), 1);
2980 GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC); 2977 GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
3035 MaybeObject* ConstructStubCompiler::CompileConstructStub(JSFunction* function) { 3032 MaybeObject* ConstructStubCompiler::CompileConstructStub(JSFunction* function) {
3036 // ----------- S t a t e ------------- 3033 // ----------- S t a t e -------------
3037 // -- rax : argc 3034 // -- rax : argc
3038 // -- rdi : constructor 3035 // -- rdi : constructor
3039 // -- rsp[0] : return address 3036 // -- rsp[0] : return address
3040 // -- rsp[4] : last argument 3037 // -- rsp[4] : last argument
3041 // ----------------------------------- 3038 // -----------------------------------
3042 Label generic_stub_call; 3039 Label generic_stub_call;
3043 3040
3044 // Use r8 for holding undefined which is used in several places below. 3041 // Use r8 for holding undefined which is used in several places below.
3045 __ Move(r8, FACTORY->undefined_value()); 3042 __ Move(r8, factory()->undefined_value());
3046 3043
3047 #ifdef ENABLE_DEBUGGER_SUPPORT 3044 #ifdef ENABLE_DEBUGGER_SUPPORT
3048 // Check to see whether there are any break points in the function code. If 3045 // Check to see whether there are any break points in the function code. If
3049 // there are jump to the generic constructor stub which calls the actual 3046 // there are jump to the generic constructor stub which calls the actual
3050 // code for the function thereby hitting the break points. 3047 // code for the function thereby hitting the break points.
3051 __ movq(rbx, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset)); 3048 __ movq(rbx, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset));
3052 __ movq(rbx, FieldOperand(rbx, SharedFunctionInfo::kDebugInfoOffset)); 3049 __ movq(rbx, FieldOperand(rbx, SharedFunctionInfo::kDebugInfoOffset));
3053 __ cmpq(rbx, r8); 3050 __ cmpq(rbx, r8);
3054 __ j(not_equal, &generic_stub_call); 3051 __ j(not_equal, &generic_stub_call);
3055 #endif 3052 #endif
(...skipping 23 matching lines...) Expand all
3079 rdx, 3076 rdx,
3080 rcx, 3077 rcx,
3081 no_reg, 3078 no_reg,
3082 &generic_stub_call, 3079 &generic_stub_call,
3083 NO_ALLOCATION_FLAGS); 3080 NO_ALLOCATION_FLAGS);
3084 3081
3085 // Allocated the JSObject, now initialize the fields and add the heap tag. 3082 // Allocated the JSObject, now initialize the fields and add the heap tag.
3086 // rbx: initial map 3083 // rbx: initial map
3087 // rdx: JSObject (untagged) 3084 // rdx: JSObject (untagged)
3088 __ movq(Operand(rdx, JSObject::kMapOffset), rbx); 3085 __ movq(Operand(rdx, JSObject::kMapOffset), rbx);
3089 __ Move(rbx, FACTORY->empty_fixed_array()); 3086 __ Move(rbx, factory()->empty_fixed_array());
3090 __ movq(Operand(rdx, JSObject::kPropertiesOffset), rbx); 3087 __ movq(Operand(rdx, JSObject::kPropertiesOffset), rbx);
3091 __ movq(Operand(rdx, JSObject::kElementsOffset), rbx); 3088 __ movq(Operand(rdx, JSObject::kElementsOffset), rbx);
3092 3089
3093 // rax: argc 3090 // rax: argc
3094 // rdx: JSObject (untagged) 3091 // rdx: JSObject (untagged)
3095 // Load the address of the first in-object property into r9. 3092 // Load the address of the first in-object property into r9.
3096 __ lea(r9, Operand(rdx, JSObject::kHeaderSize)); 3093 __ lea(r9, Operand(rdx, JSObject::kHeaderSize));
3097 // Calculate the location of the first argument. The stack contains only the 3094 // Calculate the location of the first argument. The stack contains only the
3098 // return address on top of the argc arguments. 3095 // return address on top of the argc arguments.
3099 __ lea(rcx, Operand(rsp, rax, times_pointer_size, 0)); 3096 __ lea(rcx, Operand(rsp, rax, times_pointer_size, 0));
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
3138 __ movq(rbx, rax); 3135 __ movq(rbx, rax);
3139 __ movq(rax, rdx); 3136 __ movq(rax, rdx);
3140 __ or_(rax, Immediate(kHeapObjectTag)); 3137 __ or_(rax, Immediate(kHeapObjectTag));
3141 3138
3142 // rax: JSObject 3139 // rax: JSObject
3143 // rbx: argc 3140 // rbx: argc
3144 // Remove caller arguments and receiver from the stack and return. 3141 // Remove caller arguments and receiver from the stack and return.
3145 __ pop(rcx); 3142 __ pop(rcx);
3146 __ lea(rsp, Operand(rsp, rbx, times_pointer_size, 1 * kPointerSize)); 3143 __ lea(rsp, Operand(rsp, rbx, times_pointer_size, 1 * kPointerSize));
3147 __ push(rcx); 3144 __ push(rcx);
3148 Counters* counters = masm()->isolate()->counters(); 3145 Counters* counters = isolate()->counters();
3149 __ IncrementCounter(counters->constructed_objects(), 1); 3146 __ IncrementCounter(counters->constructed_objects(), 1);
3150 __ IncrementCounter(counters->constructed_objects_stub(), 1); 3147 __ IncrementCounter(counters->constructed_objects_stub(), 1);
3151 __ ret(0); 3148 __ ret(0);
3152 3149
3153 // Jump to the generic stub in case the specialized code cannot handle the 3150 // Jump to the generic stub in case the specialized code cannot handle the
3154 // construction. 3151 // construction.
3155 __ bind(&generic_stub_call); 3152 __ bind(&generic_stub_call);
3156 Code* code = 3153 Code* code =
3157 masm()->isolate()->builtins()->builtin(Builtins::kJSConstructStubGeneric); 3154 isolate()->builtins()->builtin(Builtins::kJSConstructStubGeneric);
3158 Handle<Code> generic_construct_stub(code); 3155 Handle<Code> generic_construct_stub(code);
3159 __ Jump(generic_construct_stub, RelocInfo::CODE_TARGET); 3156 __ Jump(generic_construct_stub, RelocInfo::CODE_TARGET);
3160 3157
3161 // Return the generated code. 3158 // Return the generated code.
3162 return GetCode(); 3159 return GetCode();
3163 } 3160 }
3164 3161
3165 3162
3166 MaybeObject* ExternalArrayStubCompiler::CompileKeyedLoadStub( 3163 MaybeObject* ExternalArrayStubCompiler::CompileKeyedLoadStub(
3167 JSObject* receiver, ExternalArrayType array_type, Code::Flags flags) { 3164 JSObject* receiver, ExternalArrayType array_type, Code::Flags flags) {
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
3262 __ movsd(FieldOperand(rcx, HeapNumber::kValueOffset), xmm0); 3259 __ movsd(FieldOperand(rcx, HeapNumber::kValueOffset), xmm0);
3263 __ movq(rax, rcx); 3260 __ movq(rax, rcx);
3264 __ ret(0); 3261 __ ret(0);
3265 } else { 3262 } else {
3266 __ Integer32ToSmi(rax, rcx); 3263 __ Integer32ToSmi(rax, rcx);
3267 __ ret(0); 3264 __ ret(0);
3268 } 3265 }
3269 3266
3270 // Slow case: Jump to runtime. 3267 // Slow case: Jump to runtime.
3271 __ bind(&slow); 3268 __ bind(&slow);
3272 Counters* counters = masm()->isolate()->counters(); 3269 Counters* counters = isolate()->counters();
3273 __ IncrementCounter(counters->keyed_load_external_array_slow(), 1); 3270 __ IncrementCounter(counters->keyed_load_external_array_slow(), 1);
3274 3271
3275 // ----------- S t a t e ------------- 3272 // ----------- S t a t e -------------
3276 // -- rax : key 3273 // -- rax : key
3277 // -- rdx : receiver 3274 // -- rdx : receiver
3278 // -- rsp[0] : return address 3275 // -- rsp[0] : return address
3279 // ----------------------------------- 3276 // -----------------------------------
3280 3277
3281 __ pop(rbx); 3278 __ pop(rbx);
3282 __ push(rdx); // receiver 3279 __ push(rdx); // receiver
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
3454 __ TailCallRuntime(Runtime::kSetProperty, 5, 1); 3451 __ TailCallRuntime(Runtime::kSetProperty, 5, 1);
3455 3452
3456 return GetCode(flags); 3453 return GetCode(flags);
3457 } 3454 }
3458 3455
3459 #undef __ 3456 #undef __
3460 3457
3461 } } // namespace v8::internal 3458 } } // namespace v8::internal
3462 3459
3463 #endif // V8_TARGET_ARCH_X64 3460 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/stub-cache.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698