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

Side by Side Diff: src/top.h

Issue 7366: Split window support from V8. ... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 12 years, 2 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-ia32.cc ('k') | src/top.cc » ('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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 24 matching lines...) Expand all
35 35
36 #define RETURN_IF_SCHEDULED_EXCEPTION() \ 36 #define RETURN_IF_SCHEDULED_EXCEPTION() \
37 if (Top::has_scheduled_exception()) return Top::PromoteScheduledException() 37 if (Top::has_scheduled_exception()) return Top::PromoteScheduledException()
38 38
39 // Top has static variables used for JavaScript execution. 39 // Top has static variables used for JavaScript execution.
40 40
41 class SaveContext; // Forward decleration. 41 class SaveContext; // Forward decleration.
42 42
43 class ThreadLocalTop BASE_EMBEDDED { 43 class ThreadLocalTop BASE_EMBEDDED {
44 public: 44 public:
45 Context* security_context_;
46 // The context where the current execution method is created and for variable 45 // The context where the current execution method is created and for variable
47 // lookups. 46 // lookups.
48 Context* context_; 47 Context* context_;
49 Object* pending_exception_; 48 Object* pending_exception_;
50 // Use a separate value for scheduled exceptions to preserve the 49 // Use a separate value for scheduled exceptions to preserve the
51 // invariants that hold about pending_exception. We may want to 50 // invariants that hold about pending_exception. We may want to
52 // unify them later. 51 // unify them later.
53 Object* scheduled_exception_; 52 Object* scheduled_exception_;
54 bool external_caught_exception_; 53 bool external_caught_exception_;
55 v8::TryCatch* try_catch_handler_; 54 v8::TryCatch* try_catch_handler_;
56 SaveContext* save_context_; 55 SaveContext* save_context_;
57 56
58 // Stack. 57 // Stack.
59 Address c_entry_fp_; // the frame pointer of the top c entry frame 58 Address c_entry_fp_; // the frame pointer of the top c entry frame
60 Address handler_; // try-blocks are chained through the stack 59 Address handler_; // try-blocks are chained through the stack
61 bool stack_is_cooked_; 60 bool stack_is_cooked_;
62 inline bool stack_is_cooked() { return stack_is_cooked_; } 61 inline bool stack_is_cooked() { return stack_is_cooked_; }
63 inline void set_stack_is_cooked(bool value) { stack_is_cooked_ = value; } 62 inline void set_stack_is_cooked(bool value) { stack_is_cooked_ = value; }
64 63
65 // Generated code scratch locations. 64 // Generated code scratch locations.
66 int32_t formal_count_; 65 int32_t formal_count_;
67 66
68 // Call back function to report unsafe JS accesses. 67 // Call back function to report unsafe JS accesses.
69 v8::FailedAccessCheckCallback failed_access_check_callback_; 68 v8::FailedAccessCheckCallback failed_access_check_callback_;
70 }; 69 };
71 70
72 #define TOP_ADDRESS_LIST(C) \ 71 #define TOP_ADDRESS_LIST(C) \
73 C(handler_address) \ 72 C(handler_address) \
74 C(c_entry_fp_address) \ 73 C(c_entry_fp_address) \
75 C(context_address) \ 74 C(context_address) \
76 C(pending_exception_address) \ 75 C(pending_exception_address) \
77 C(external_caught_exception_address) \ 76 C(external_caught_exception_address)
78 C(security_context_address)
79 77
80 class Top { 78 class Top {
81 public: 79 public:
82 enum AddressId { 80 enum AddressId {
83 #define C(name) k_##name, 81 #define C(name) k_##name,
84 TOP_ADDRESS_LIST(C) 82 TOP_ADDRESS_LIST(C)
85 #undef C 83 #undef C
86 k_top_address_count 84 k_top_address_count
87 }; 85 };
88 86
89 static Address get_address_from_id(AddressId id); 87 static Address get_address_from_id(AddressId id);
90 88
91 // Access to the security context from which JS execution started.
92 // In a browser world, it is the JS context of the frame which initiated
93 // JavaScript execution.
94 static Context* security_context() { return thread_local_.security_context_; }
95 static void set_security_context(Context* context) {
96 ASSERT(context == NULL || context->IsGlobalContext());
97 thread_local_.security_context_ = context;
98 }
99 static Context** security_context_address() {
100 return &thread_local_.security_context_;
101 }
102
103 // Access to top context (where the current function object was created). 89 // Access to top context (where the current function object was created).
104 static Context* context() { return thread_local_.context_; } 90 static Context* context() { return thread_local_.context_; }
105 static void set_context(Context* context) { 91 static void set_context(Context* context) {
106 thread_local_.context_ = context; 92 thread_local_.context_ = context;
107 } 93 }
108 static Context** context_address() { return &thread_local_.context_; } 94 static Context** context_address() { return &thread_local_.context_; }
109 95
110 static SaveContext* save_context() {return thread_local_.save_context_; } 96 static SaveContext* save_context() {return thread_local_.save_context_; }
111 static void set_save_context(SaveContext* save) { 97 static void set_save_context(SaveContext* save) {
112 thread_local_.save_context_ = save; 98 thread_local_.save_context_ = save;
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 // Out of resource exception helpers. 222 // Out of resource exception helpers.
237 static Failure* StackOverflow(); 223 static Failure* StackOverflow();
238 224
239 // Administration 225 // Administration
240 static void Initialize(); 226 static void Initialize();
241 static void TearDown(); 227 static void TearDown();
242 static void Iterate(ObjectVisitor* v); 228 static void Iterate(ObjectVisitor* v);
243 static void Iterate(ObjectVisitor* v, ThreadLocalTop* t); 229 static void Iterate(ObjectVisitor* v, ThreadLocalTop* t);
244 static char* Iterate(ObjectVisitor* v, char* t); 230 static char* Iterate(ObjectVisitor* v, char* t);
245 231
246 static Handle<JSObject> global() { 232 // Returns the global object of the current context. It could be
247 return Handle<JSObject>(context()->global()); 233 // a builtin object, or a js global object.
234 static Handle<GlobalObject> global() {
235 return Handle<GlobalObject>(context()->global());
248 } 236 }
237
238 // Returns the global proxy object of the current context.
239 static Object* global_proxy() {
240 return context()->global_proxy();
241 }
242
249 static Handle<Context> global_context(); 243 static Handle<Context> global_context();
250 244
251 static Handle<JSBuiltinsObject> builtins() { 245 static Handle<JSBuiltinsObject> builtins() {
252 return Handle<JSBuiltinsObject>(thread_local_.context_->builtins()); 246 return Handle<JSBuiltinsObject>(thread_local_.context_->builtins());
253 } 247 }
254 static Handle<JSBuiltinsObject> security_context_builtins() {
255 return Handle<JSBuiltinsObject>(
256 thread_local_.security_context_->builtins());
257 }
258 248
259 static Object* LookupSpecialFunction(JSObject* receiver, 249 static Object* LookupSpecialFunction(JSObject* receiver,
260 JSObject* prototype, 250 JSObject* prototype,
261 JSFunction* value); 251 JSFunction* value);
262 252
263 static void RegisterTryCatchHandler(v8::TryCatch* that); 253 static void RegisterTryCatchHandler(v8::TryCatch* that);
264 static void UnregisterTryCatchHandler(v8::TryCatch* that); 254 static void UnregisterTryCatchHandler(v8::TryCatch* that);
265 255
266 #define TOP_GLOBAL_CONTEXT_FIELD_ACCESSOR(index, type, name) \ 256 #define TOP_GLOBAL_CONTEXT_FIELD_ACCESSOR(index, type, name) \
267 static Handle<type> name() { \ 257 static Handle<type> name() { \
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 friend class ExecutionAccess; 291 friend class ExecutionAccess;
302 292
303 static void FillCache(); 293 static void FillCache();
304 }; 294 };
305 295
306 296
307 class SaveContext BASE_EMBEDDED { 297 class SaveContext BASE_EMBEDDED {
308 public: 298 public:
309 SaveContext() : 299 SaveContext() :
310 context_(Top::context()), 300 context_(Top::context()),
311 security_context_(Top::security_context()),
312 prev_(Top::save_context()) { 301 prev_(Top::save_context()) {
313 Top::set_save_context(this); 302 Top::set_save_context(this);
314 } 303 }
315 304
316 ~SaveContext() { 305 ~SaveContext() {
317 Top::set_context(*context_); 306 Top::set_context(*context_);
318 Top::set_security_context(*security_context_);
319 Top::set_save_context(prev_); 307 Top::set_save_context(prev_);
320 } 308 }
321 309
322 Handle<Context> context() { return context_; } 310 Handle<Context> context() { return context_; }
323 Handle<Context> security_context() { return security_context_; }
324 SaveContext* prev() { return prev_; } 311 SaveContext* prev() { return prev_; }
325 312
326 private: 313 private:
327 Handle<Context> context_; 314 Handle<Context> context_;
328 Handle<Context> security_context_;
329 SaveContext* prev_; 315 SaveContext* prev_;
330 }; 316 };
331 317
332 318
333 class AssertNoContextChange BASE_EMBEDDED { 319 class AssertNoContextChange BASE_EMBEDDED {
334 #ifdef DEBUG 320 #ifdef DEBUG
335 public: 321 public:
336 AssertNoContextChange() : 322 AssertNoContextChange() :
337 context_(Top::context()), 323 context_(Top::context()) {
338 security_context_(Top::security_context()) {
339 } 324 }
340 325
341 ~AssertNoContextChange() { 326 ~AssertNoContextChange() {
342 ASSERT(Top::context() == *context_); 327 ASSERT(Top::context() == *context_);
343 ASSERT(Top::security_context() == *security_context_);
344 } 328 }
345 329
346 private: 330 private:
347 HandleScope scope_; 331 HandleScope scope_;
348 Handle<Context> context_; 332 Handle<Context> context_;
349 Handle<Context> security_context_;
350 #else 333 #else
351 public: 334 public:
352 AssertNoContextChange() { } 335 AssertNoContextChange() { }
353 #endif 336 #endif
354 }; 337 };
355 338
356 339
357 class ExecutionAccess BASE_EMBEDDED { 340 class ExecutionAccess BASE_EMBEDDED {
358 public: 341 public:
359 ExecutionAccess(); 342 ExecutionAccess();
360 ~ExecutionAccess(); 343 ~ExecutionAccess();
361 }; 344 };
362 345
363 } } // namespace v8::internal 346 } } // namespace v8::internal
364 347
365 #endif // V8_TOP_H_ 348 #endif // V8_TOP_H_
OLDNEW
« no previous file with comments | « src/stub-cache-ia32.cc ('k') | src/top.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698