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

Side by Side Diff: src/execution.cc

Issue 10832342: Rename "global context" to "native context", (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 4 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
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 while (fun->IsJSFunctionProxy()) { 239 while (fun->IsJSFunctionProxy()) {
240 fun = JSFunctionProxy::cast(fun)->call_trap(); 240 fun = JSFunctionProxy::cast(fun)->call_trap();
241 } 241 }
242 if (fun->IsJSFunction()) return Handle<Object>(fun); 242 if (fun->IsJSFunction()) return Handle<Object>(fun);
243 243
244 // Objects created through the API can have an instance-call handler 244 // Objects created through the API can have an instance-call handler
245 // that should be used when calling the object as a function. 245 // that should be used when calling the object as a function.
246 if (fun->IsHeapObject() && 246 if (fun->IsHeapObject() &&
247 HeapObject::cast(fun)->map()->has_instance_call_handler()) { 247 HeapObject::cast(fun)->map()->has_instance_call_handler()) {
248 return Handle<JSFunction>( 248 return Handle<JSFunction>(
249 isolate->global_context()->call_as_function_delegate()); 249 isolate->native_context()->call_as_function_delegate());
250 } 250 }
251 251
252 return factory->undefined_value(); 252 return factory->undefined_value();
253 } 253 }
254 254
255 255
256 Handle<Object> Execution::TryGetFunctionDelegate(Handle<Object> object, 256 Handle<Object> Execution::TryGetFunctionDelegate(Handle<Object> object,
257 bool* has_pending_exception) { 257 bool* has_pending_exception) {
258 ASSERT(!object->IsJSFunction()); 258 ASSERT(!object->IsJSFunction());
259 Isolate* isolate = Isolate::Current(); 259 Isolate* isolate = Isolate::Current();
260 260
261 // If object is a function proxy, get its handler. Iterate if necessary. 261 // If object is a function proxy, get its handler. Iterate if necessary.
262 Object* fun = *object; 262 Object* fun = *object;
263 while (fun->IsJSFunctionProxy()) { 263 while (fun->IsJSFunctionProxy()) {
264 fun = JSFunctionProxy::cast(fun)->call_trap(); 264 fun = JSFunctionProxy::cast(fun)->call_trap();
265 } 265 }
266 if (fun->IsJSFunction()) return Handle<Object>(fun); 266 if (fun->IsJSFunction()) return Handle<Object>(fun);
267 267
268 // Objects created through the API can have an instance-call handler 268 // Objects created through the API can have an instance-call handler
269 // that should be used when calling the object as a function. 269 // that should be used when calling the object as a function.
270 if (fun->IsHeapObject() && 270 if (fun->IsHeapObject() &&
271 HeapObject::cast(fun)->map()->has_instance_call_handler()) { 271 HeapObject::cast(fun)->map()->has_instance_call_handler()) {
272 return Handle<JSFunction>( 272 return Handle<JSFunction>(
273 isolate->global_context()->call_as_function_delegate()); 273 isolate->native_context()->call_as_function_delegate());
274 } 274 }
275 275
276 // If the Object doesn't have an instance-call handler we should 276 // If the Object doesn't have an instance-call handler we should
277 // throw a non-callable exception. 277 // throw a non-callable exception.
278 i::Handle<i::Object> error_obj = isolate->factory()->NewTypeError( 278 i::Handle<i::Object> error_obj = isolate->factory()->NewTypeError(
279 "called_non_callable", i::HandleVector<i::Object>(&object, 1)); 279 "called_non_callable", i::HandleVector<i::Object>(&object, 1));
280 isolate->Throw(*error_obj); 280 isolate->Throw(*error_obj);
281 *has_pending_exception = true; 281 *has_pending_exception = true;
282 282
283 return isolate->factory()->undefined_value(); 283 return isolate->factory()->undefined_value();
(...skipping 12 matching lines...) Expand all
296 while (fun->IsJSFunctionProxy()) { 296 while (fun->IsJSFunctionProxy()) {
297 fun = JSFunctionProxy::cast(fun)->call_trap(); 297 fun = JSFunctionProxy::cast(fun)->call_trap();
298 } 298 }
299 if (fun->IsJSFunction()) return Handle<Object>(fun); 299 if (fun->IsJSFunction()) return Handle<Object>(fun);
300 300
301 // Objects created through the API can have an instance-call handler 301 // Objects created through the API can have an instance-call handler
302 // that should be used when calling the object as a function. 302 // that should be used when calling the object as a function.
303 if (fun->IsHeapObject() && 303 if (fun->IsHeapObject() &&
304 HeapObject::cast(fun)->map()->has_instance_call_handler()) { 304 HeapObject::cast(fun)->map()->has_instance_call_handler()) {
305 return Handle<JSFunction>( 305 return Handle<JSFunction>(
306 isolate->global_context()->call_as_constructor_delegate()); 306 isolate->native_context()->call_as_constructor_delegate());
307 } 307 }
308 308
309 return isolate->factory()->undefined_value(); 309 return isolate->factory()->undefined_value();
310 } 310 }
311 311
312 312
313 Handle<Object> Execution::TryGetConstructorDelegate( 313 Handle<Object> Execution::TryGetConstructorDelegate(
314 Handle<Object> object, 314 Handle<Object> object,
315 bool* has_pending_exception) { 315 bool* has_pending_exception) {
316 ASSERT(!object->IsJSFunction()); 316 ASSERT(!object->IsJSFunction());
317 Isolate* isolate = Isolate::Current(); 317 Isolate* isolate = Isolate::Current();
318 318
319 // If you return a function from here, it will be called when an 319 // If you return a function from here, it will be called when an
320 // attempt is made to call the given object as a constructor. 320 // attempt is made to call the given object as a constructor.
321 321
322 // If object is a function proxies, get its handler. Iterate if necessary. 322 // If object is a function proxies, get its handler. Iterate if necessary.
323 Object* fun = *object; 323 Object* fun = *object;
324 while (fun->IsJSFunctionProxy()) { 324 while (fun->IsJSFunctionProxy()) {
325 fun = JSFunctionProxy::cast(fun)->call_trap(); 325 fun = JSFunctionProxy::cast(fun)->call_trap();
326 } 326 }
327 if (fun->IsJSFunction()) return Handle<Object>(fun); 327 if (fun->IsJSFunction()) return Handle<Object>(fun);
328 328
329 // Objects created through the API can have an instance-call handler 329 // Objects created through the API can have an instance-call handler
330 // that should be used when calling the object as a function. 330 // that should be used when calling the object as a function.
331 if (fun->IsHeapObject() && 331 if (fun->IsHeapObject() &&
332 HeapObject::cast(fun)->map()->has_instance_call_handler()) { 332 HeapObject::cast(fun)->map()->has_instance_call_handler()) {
333 return Handle<JSFunction>( 333 return Handle<JSFunction>(
334 isolate->global_context()->call_as_constructor_delegate()); 334 isolate->native_context()->call_as_constructor_delegate());
335 } 335 }
336 336
337 // If the Object doesn't have an instance-call handler we should 337 // If the Object doesn't have an instance-call handler we should
338 // throw a non-callable exception. 338 // throw a non-callable exception.
339 i::Handle<i::Object> error_obj = isolate->factory()->NewTypeError( 339 i::Handle<i::Object> error_obj = isolate->factory()->NewTypeError(
340 "called_non_callable", i::HandleVector<i::Object>(&object, 1)); 340 "called_non_callable", i::HandleVector<i::Object>(&object, 1));
341 isolate->Throw(*error_obj); 341 isolate->Throw(*error_obj);
342 *has_pending_exception = true; 342 *has_pending_exception = true;
343 343
344 return isolate->factory()->undefined_value(); 344 return isolate->factory()->undefined_value();
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 } 673 }
674 674
675 675
676 #undef RETURN_NATIVE_CALL 676 #undef RETURN_NATIVE_CALL
677 677
678 678
679 Handle<JSRegExp> Execution::NewJSRegExp(Handle<String> pattern, 679 Handle<JSRegExp> Execution::NewJSRegExp(Handle<String> pattern,
680 Handle<String> flags, 680 Handle<String> flags,
681 bool* exc) { 681 bool* exc) {
682 Handle<JSFunction> function = Handle<JSFunction>( 682 Handle<JSFunction> function = Handle<JSFunction>(
683 pattern->GetIsolate()->global_context()->regexp_function()); 683 pattern->GetIsolate()->native_context()->regexp_function());
684 Handle<Object> re_obj = RegExpImpl::CreateRegExpLiteral( 684 Handle<Object> re_obj = RegExpImpl::CreateRegExpLiteral(
685 function, pattern, flags, exc); 685 function, pattern, flags, exc);
686 if (*exc) return Handle<JSRegExp>(); 686 if (*exc) return Handle<JSRegExp>();
687 return Handle<JSRegExp>::cast(re_obj); 687 return Handle<JSRegExp>::cast(re_obj);
688 } 688 }
689 689
690 690
691 Handle<Object> Execution::CharAt(Handle<String> string, uint32_t index) { 691 Handle<Object> Execution::CharAt(Handle<String> string, uint32_t index) {
692 Isolate* isolate = string->GetIsolate(); 692 Isolate* isolate = string->GetIsolate();
693 Factory* factory = isolate->factory(); 693 Factory* factory = isolate->factory();
(...skipping 25 matching lines...) Expand all
719 } 719 }
720 720
721 721
722 Handle<JSFunction> Execution::InstantiateFunction( 722 Handle<JSFunction> Execution::InstantiateFunction(
723 Handle<FunctionTemplateInfo> data, 723 Handle<FunctionTemplateInfo> data,
724 bool* exc) { 724 bool* exc) {
725 Isolate* isolate = data->GetIsolate(); 725 Isolate* isolate = data->GetIsolate();
726 // Fast case: see if the function has already been instantiated 726 // Fast case: see if the function has already been instantiated
727 int serial_number = Smi::cast(data->serial_number())->value(); 727 int serial_number = Smi::cast(data->serial_number())->value();
728 Object* elm = 728 Object* elm =
729 isolate->global_context()->function_cache()-> 729 isolate->native_context()->function_cache()->
730 GetElementNoExceptionThrown(serial_number); 730 GetElementNoExceptionThrown(serial_number);
731 if (elm->IsJSFunction()) return Handle<JSFunction>(JSFunction::cast(elm)); 731 if (elm->IsJSFunction()) return Handle<JSFunction>(JSFunction::cast(elm));
732 // The function has not yet been instantiated in this context; do it. 732 // The function has not yet been instantiated in this context; do it.
733 Handle<Object> args[] = { data }; 733 Handle<Object> args[] = { data };
734 Handle<Object> result = Call(isolate->instantiate_fun(), 734 Handle<Object> result = Call(isolate->instantiate_fun(),
735 isolate->js_builtins_object(), 735 isolate->js_builtins_object(),
736 ARRAY_SIZE(args), 736 ARRAY_SIZE(args),
737 args, 737 args,
738 exc); 738 exc);
739 if (*exc) return Handle<JSFunction>::null(); 739 if (*exc) return Handle<JSFunction>::null();
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
961 } 961 }
962 if (stack_guard->IsInterrupted()) { 962 if (stack_guard->IsInterrupted()) {
963 stack_guard->Continue(INTERRUPT); 963 stack_guard->Continue(INTERRUPT);
964 return isolate->StackOverflow(); 964 return isolate->StackOverflow();
965 } 965 }
966 return isolate->heap()->undefined_value(); 966 return isolate->heap()->undefined_value();
967 } 967 }
968 968
969 969
970 } } // namespace v8::internal 970 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698