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

Side by Side Diff: src/accessors.cc

Issue 2626213002: [runtime] Change JavaScriptFrame::GetFunctions interface. (Closed)
Patch Set: Rebased. Created 3 years, 11 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
« no previous file with comments | « no previous file | src/frames.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/accessors.h" 5 #include "src/accessors.h"
6 6
7 #include "src/api.h" 7 #include "src/api.h"
8 #include "src/contexts.h" 8 #include "src/contexts.h"
9 #include "src/deoptimizer.h" 9 #include "src/deoptimizer.h"
10 #include "src/execution.h" 10 #include "src/execution.h"
(...skipping 826 matching lines...) Expand 10 before | Expand all | Expand 10 after
837 } 837 }
838 838
839 // Return the freshly allocated arguments object. 839 // Return the freshly allocated arguments object.
840 return arguments; 840 return arguments;
841 } 841 }
842 842
843 843
844 static int FindFunctionInFrame(JavaScriptFrame* frame, 844 static int FindFunctionInFrame(JavaScriptFrame* frame,
845 Handle<JSFunction> function) { 845 Handle<JSFunction> function) {
846 DisallowHeapAllocation no_allocation; 846 DisallowHeapAllocation no_allocation;
847 List<JSFunction*> functions(2); 847 List<FrameSummary> frames(2);
848 frame->GetFunctions(&functions); 848 frame->Summarize(&frames);
849 for (int i = functions.length() - 1; i >= 0; i--) { 849 for (int i = frames.length() - 1; i >= 0; i--) {
850 if (functions[i] == *function) return i; 850 if (*frames[i].AsJavaScript().function() == *function) return i;
851 } 851 }
852 return -1; 852 return -1;
853 } 853 }
854 854
855 855
856 namespace { 856 namespace {
857 857
858 Handle<Object> GetFunctionArguments(Isolate* isolate, 858 Handle<Object> GetFunctionArguments(Isolate* isolate,
859 Handle<JSFunction> function) { 859 Handle<JSFunction> function) {
860 // Find the top invocation of the function by traversing frames. 860 // Find the top invocation of the function by traversing frames.
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
944 944
945 static inline bool AllowAccessToFunction(Context* current_context, 945 static inline bool AllowAccessToFunction(Context* current_context,
946 JSFunction* function) { 946 JSFunction* function) {
947 return current_context->HasSameSecurityTokenAs(function->context()); 947 return current_context->HasSameSecurityTokenAs(function->context());
948 } 948 }
949 949
950 950
951 class FrameFunctionIterator { 951 class FrameFunctionIterator {
952 public: 952 public:
953 FrameFunctionIterator(Isolate* isolate, const DisallowHeapAllocation& promise) 953 FrameFunctionIterator(Isolate* isolate, const DisallowHeapAllocation& promise)
954 : isolate_(isolate), 954 : isolate_(isolate), frame_iterator_(isolate), frames_(2), index_(0) {
955 frame_iterator_(isolate), 955 GetFrames();
956 functions_(2),
957 index_(0) {
958 GetFunctions();
959 } 956 }
960 JSFunction* next() { 957 JSFunction* next() {
961 while (true) { 958 while (true) {
962 if (functions_.length() == 0) return NULL; 959 if (frames_.length() == 0) return NULL;
963 JSFunction* next_function = functions_[index_]; 960 JSFunction* next_function = *frames_[index_].AsJavaScript().function();
964 index_--; 961 index_--;
965 if (index_ < 0) { 962 if (index_ < 0) {
966 GetFunctions(); 963 GetFrames();
967 } 964 }
968 // Skip functions from other origins. 965 // Skip functions from other origins.
969 if (!AllowAccessToFunction(isolate_->context(), next_function)) continue; 966 if (!AllowAccessToFunction(isolate_->context(), next_function)) continue;
970 return next_function; 967 return next_function;
971 } 968 }
972 } 969 }
973 970
974 // Iterate through functions until the first occurence of 'function'. 971 // Iterate through functions until the first occurence of 'function'.
975 // Returns true if 'function' is found, and false if the iterator ends 972 // Returns true if 'function' is found, and false if the iterator ends
976 // without finding it. 973 // without finding it.
977 bool Find(JSFunction* function) { 974 bool Find(JSFunction* function) {
978 JSFunction* next_function; 975 JSFunction* next_function;
979 do { 976 do {
980 next_function = next(); 977 next_function = next();
981 if (next_function == function) return true; 978 if (next_function == function) return true;
982 } while (next_function != NULL); 979 } while (next_function != NULL);
983 return false; 980 return false;
984 } 981 }
985 982
986 private: 983 private:
987 void GetFunctions() { 984 void GetFrames() {
988 functions_.Rewind(0); 985 frames_.Rewind(0);
989 if (frame_iterator_.done()) return; 986 if (frame_iterator_.done()) return;
990 JavaScriptFrame* frame = frame_iterator_.frame(); 987 JavaScriptFrame* frame = frame_iterator_.frame();
991 frame->GetFunctions(&functions_); 988 frame->Summarize(&frames_);
992 DCHECK(functions_.length() > 0); 989 DCHECK(frames_.length() > 0);
993 frame_iterator_.Advance(); 990 frame_iterator_.Advance();
994 index_ = functions_.length() - 1; 991 index_ = frames_.length() - 1;
995 } 992 }
996 Isolate* isolate_; 993 Isolate* isolate_;
997 JavaScriptFrameIterator frame_iterator_; 994 JavaScriptFrameIterator frame_iterator_;
998 List<JSFunction*> functions_; 995 List<FrameSummary> frames_;
999 int index_; 996 int index_;
1000 }; 997 };
1001 998
1002 999
1003 MaybeHandle<JSFunction> FindCaller(Isolate* isolate, 1000 MaybeHandle<JSFunction> FindCaller(Isolate* isolate,
1004 Handle<JSFunction> function) { 1001 Handle<JSFunction> function) {
1005 DisallowHeapAllocation no_allocation; 1002 DisallowHeapAllocation no_allocation;
1006 FrameFunctionIterator it(isolate, no_allocation); 1003 FrameFunctionIterator it(isolate, no_allocation);
1007 if (function->shared()->native()) { 1004 if (function->shared()->native()) {
1008 return MaybeHandle<JSFunction>(); 1005 return MaybeHandle<JSFunction>();
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
1246 Handle<AccessorInfo> Accessors::ErrorStackInfo(Isolate* isolate, 1243 Handle<AccessorInfo> Accessors::ErrorStackInfo(Isolate* isolate,
1247 PropertyAttributes attributes) { 1244 PropertyAttributes attributes) {
1248 Handle<AccessorInfo> info = 1245 Handle<AccessorInfo> info =
1249 MakeAccessor(isolate, isolate->factory()->stack_string(), 1246 MakeAccessor(isolate, isolate->factory()->stack_string(),
1250 &ErrorStackGetter, &ErrorStackSetter, attributes); 1247 &ErrorStackGetter, &ErrorStackSetter, attributes);
1251 return info; 1248 return info;
1252 } 1249 }
1253 1250
1254 } // namespace internal 1251 } // namespace internal
1255 } // namespace v8 1252 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/frames.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698