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

Side by Side Diff: src/x64/macro-assembler-x64.cc

Issue 155631: X64: Implement inline cache of monomorphic constant function call. Mark a de... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 5 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 | « no previous file | src/x64/stub-cache-x64.cc » ('j') | src/x64/stub-cache-x64.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 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 864 matching lines...) Expand 10 before | Expand all | Expand 10 after
875 // Push the return address to get ready to return. 875 // Push the return address to get ready to return.
876 push(rcx); 876 push(rcx);
877 877
878 // Clear the top frame. 878 // Clear the top frame.
879 ExternalReference c_entry_fp_address(Top::k_c_entry_fp_address); 879 ExternalReference c_entry_fp_address(Top::k_c_entry_fp_address);
880 movq(kScratchRegister, c_entry_fp_address); 880 movq(kScratchRegister, c_entry_fp_address);
881 movq(Operand(kScratchRegister, 0), Immediate(0)); 881 movq(Operand(kScratchRegister, 0), Immediate(0));
882 } 882 }
883 883
884 884
885 Register MacroAssembler::CheckMaps(JSObject* object, Register object_reg,
886 JSObject* holder, Register holder_reg,
887 Register scratch,
888 Label* miss) {
889 // Make sure there's no overlap between scratch and the other
890 // registers.
891 ASSERT(!scratch.is(object_reg) && !scratch.is(holder_reg));
892
893 // Keep track of the current object in register reg. On the first
894 // iteration, reg is an alias for object_reg, on later iterations,
895 // it is an alias for holder_reg.
896 Register reg = object_reg;
897 int depth = 1;
898
899 // Check the maps in the prototype chain.
900 // Traverse the prototype chain from the object and do map checks.
901 while (object != holder) {
902 depth++;
903
904 // Only global objects and objects that do not require access
905 // checks are allowed in stubs.
906 ASSERT(object->IsJSGlobalProxy() || !object->IsAccessCheckNeeded());
907
908 JSObject* prototype = JSObject::cast(object->GetPrototype());
909 if (Heap::InNewSpace(prototype)) {
910 // Get the map of the current object.
911 movq(scratch, FieldOperand(reg, HeapObject::kMapOffset));
912 Cmp(scratch, Handle<Map>(object->map()));
913 // Branch on the result of the map check.
914 j(not_equal, miss);
915 // Check access rights to the global object. This has to happen
916 // after the map check so that we know that the object is
917 // actually a global object.
918 if (object->IsJSGlobalProxy()) {
919 CheckAccessGlobalProxy(reg, scratch, miss);
920
921 // Restore scratch register to be the map of the object.
922 // We load the prototype from the map in the scratch register.
923 movq(scratch, FieldOperand(reg, HeapObject::kMapOffset));
924 }
925 // The prototype is in new space; we cannot store a reference
926 // to it in the code. Load it from the map.
927 reg = holder_reg; // from now the object is in holder_reg
928 movq(reg, FieldOperand(scratch, Map::kPrototypeOffset));
929
930 } else {
931 // Check the map of the current object.
932 Cmp(FieldOperand(reg, HeapObject::kMapOffset),
933 Handle<Map>(object->map()));
934 // Branch on the result of the map check.
935 j(not_equal, miss);
936 // Check access rights to the global object. This has to happen
937 // after the map check so that we know that the object is
938 // actually a global object.
939 if (object->IsJSGlobalProxy()) {
940 CheckAccessGlobalProxy(reg, scratch, miss);
941 }
942 // The prototype is in old space; load it directly.
943 reg = holder_reg; // from now the object is in holder_reg
944 Move(reg, Handle<JSObject>(prototype));
945 }
946
947 // Go to the next object in the prototype chain.
948 object = prototype;
949 }
950
951 // Check the holder map.
952 Cmp(FieldOperand(reg, HeapObject::kMapOffset),
953 Handle<Map>(holder->map()));
954 j(not_equal, miss);
955
956 // Log the check depth.
957 LOG(IntEvent("check-maps-depth", depth));
958
959 // Perform security check for access to the global object and return
960 // the holder register.
961 ASSERT(object == holder);
962 ASSERT(object->IsJSGlobalProxy() || !object->IsAccessCheckNeeded());
963 if (object->IsJSGlobalProxy()) {
964 CheckAccessGlobalProxy(reg, scratch, miss);
965 }
966 return reg;
967 }
968
969
970
971
972 void MacroAssembler::CheckAccessGlobalProxy(Register holder_reg,
973 Register scratch,
974 Label* miss) {
975 Label same_contexts;
976
977 ASSERT(!holder_reg.is(scratch));
978 ASSERT(!scratch.is(kScratchRegister));
979 // Load current lexical context from the stack frame.
980 movq(scratch, Operand(rbp, StandardFrameConstants::kContextOffset));
981
982 // When generating debug code, make sure the lexical context is set.
983 if (FLAG_debug_code) {
984 cmpq(scratch, Immediate(0));
985 Check(not_equal, "we should not have an empty lexical context");
986 }
987 // Load the global context of the current context.
988 int offset = Context::kHeaderSize + Context::GLOBAL_INDEX * kPointerSize;
989 movq(scratch, FieldOperand(scratch, offset));
990 movq(scratch, FieldOperand(scratch, GlobalObject::kGlobalContextOffset));
991
992 // Check the context is a global context.
993 if (FLAG_debug_code) {
994 Cmp(FieldOperand(scratch, HeapObject::kMapOffset),
995 Factory::global_context_map());
996 Check(equal, "JSGlobalObject::global_context should be a global context.");
997 }
998
999 // Check if both contexts are the same.
1000 cmpq(scratch, FieldOperand(holder_reg, JSGlobalProxy::kContextOffset));
1001 j(equal, &same_contexts);
1002
1003 // Compare security tokens.
1004 // Check that the security token in the calling global object is
1005 // compatible with the security token in the receiving global
1006 // object.
1007
1008 // Check the context is a global context.
1009 if (FLAG_debug_code) {
1010 // Preserve original value of holder_reg.
1011 push(holder_reg);
1012 movq(holder_reg, FieldOperand(holder_reg, JSGlobalProxy::kContextOffset));
1013 Cmp(holder_reg, Factory::null_value());
1014 Check(not_equal, "JSGlobalProxy::context() should not be null.");
1015
1016 // Read the first word and compare to global_context_map(),
1017 movq(holder_reg, FieldOperand(holder_reg, HeapObject::kMapOffset));
1018 Cmp(holder_reg, Factory::global_context_map());
1019 Check(equal, "JSGlobalObject::global_context should be a global context.");
1020 pop(holder_reg);
1021 }
1022
1023 movq(kScratchRegister,
1024 FieldOperand(holder_reg, JSGlobalProxy::kContextOffset));
1025 int token_offset = Context::kHeaderSize +
1026 Context::SECURITY_TOKEN_INDEX * kPointerSize;
1027 movq(scratch, FieldOperand(scratch, token_offset));
1028 cmpq(scratch, FieldOperand(kScratchRegister, token_offset));
1029 j(not_equal, miss);
1030
1031 bind(&same_contexts);
1032 }
1033
1034
885 } } // namespace v8::internal 1035 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/x64/stub-cache-x64.cc » ('j') | src/x64/stub-cache-x64.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698