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

Side by Side Diff: src/execution.cc

Issue 2840018: [Isolates] Moved more compilation-related globals (builtins, runtime, &c.)... (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/isolates/
Patch Set: rebase Created 10 years, 6 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 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 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 } 424 }
425 425
426 426
427 // --- C a l l s t o n a t i v e s --- 427 // --- C a l l s t o n a t i v e s ---
428 428
429 #define RETURN_NATIVE_CALL(name, argc, argv, has_pending_exception) \ 429 #define RETURN_NATIVE_CALL(name, argc, argv, has_pending_exception) \
430 do { \ 430 do { \
431 Object** args[argc] = argv; \ 431 Object** args[argc] = argv; \
432 ASSERT(has_pending_exception != NULL); \ 432 ASSERT(has_pending_exception != NULL); \
433 return Call(Isolate::Current()->name##_fun(), \ 433 return Call(Isolate::Current()->name##_fun(), \
434 Isolate::Current()->builtins(), argc, args, \ 434 Isolate::Current()->js_builtins_object(), argc, args, \
435 has_pending_exception); \ 435 has_pending_exception); \
436 } while (false) 436 } while (false)
437 437
438 438
439 Handle<Object> Execution::ToBoolean(Handle<Object> obj) { 439 Handle<Object> Execution::ToBoolean(Handle<Object> obj) {
440 // See the similar code in runtime.js:ToBoolean. 440 // See the similar code in runtime.js:ToBoolean.
441 if (obj->IsBoolean()) return obj; 441 if (obj->IsBoolean()) return obj;
442 bool result = true; 442 bool result = true;
443 if (obj->IsString()) { 443 if (obj->IsString()) {
444 result = Handle<String>::cast(obj)->length() != 0; 444 result = Handle<String>::cast(obj)->length() != 0;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 #undef RETURN_NATIVE_CALL 497 #undef RETURN_NATIVE_CALL
498 498
499 499
500 Handle<Object> Execution::CharAt(Handle<String> string, uint32_t index) { 500 Handle<Object> Execution::CharAt(Handle<String> string, uint32_t index) {
501 int int_index = static_cast<int>(index); 501 int int_index = static_cast<int>(index);
502 if (int_index < 0 || int_index >= string->length()) { 502 if (int_index < 0 || int_index >= string->length()) {
503 return Factory::undefined_value(); 503 return Factory::undefined_value();
504 } 504 }
505 505
506 Handle<Object> char_at = 506 Handle<Object> char_at =
507 GetProperty(Isolate::Current()->builtins(), Factory::char_at_symbol()); 507 GetProperty(Isolate::Current()->js_builtins_object(),
508 Factory::char_at_symbol());
508 if (!char_at->IsJSFunction()) { 509 if (!char_at->IsJSFunction()) {
509 return Factory::undefined_value(); 510 return Factory::undefined_value();
510 } 511 }
511 512
512 bool caught_exception; 513 bool caught_exception;
513 Handle<Object> index_object = Factory::NewNumberFromInt(int_index); 514 Handle<Object> index_object = Factory::NewNumberFromInt(int_index);
514 Object** index_arg[] = { index_object.location() }; 515 Object** index_arg[] = { index_object.location() };
515 Handle<Object> result = TryCall(Handle<JSFunction>::cast(char_at), 516 Handle<Object> result = TryCall(Handle<JSFunction>::cast(char_at),
516 string, 517 string,
517 ARRAY_SIZE(index_arg), 518 ARRAY_SIZE(index_arg),
(...skipping 11 matching lines...) Expand all
529 // Fast case: see if the function has already been instantiated 530 // Fast case: see if the function has already been instantiated
530 int serial_number = Smi::cast(data->serial_number())->value(); 531 int serial_number = Smi::cast(data->serial_number())->value();
531 Object* elm = 532 Object* elm =
532 Isolate::Current()->global_context()->function_cache()-> 533 Isolate::Current()->global_context()->function_cache()->
533 GetElement(serial_number); 534 GetElement(serial_number);
534 if (elm->IsJSFunction()) return Handle<JSFunction>(JSFunction::cast(elm)); 535 if (elm->IsJSFunction()) return Handle<JSFunction>(JSFunction::cast(elm));
535 // The function has not yet been instantiated in this context; do it. 536 // The function has not yet been instantiated in this context; do it.
536 Object** args[1] = { Handle<Object>::cast(data).location() }; 537 Object** args[1] = { Handle<Object>::cast(data).location() };
537 Handle<Object> result = 538 Handle<Object> result =
538 Call(Isolate::Current()->instantiate_fun(), 539 Call(Isolate::Current()->instantiate_fun(),
539 Isolate::Current()->builtins(), 1, args, exc); 540 Isolate::Current()->js_builtins_object(), 1, args, exc);
540 if (*exc) return Handle<JSFunction>::null(); 541 if (*exc) return Handle<JSFunction>::null();
541 return Handle<JSFunction>::cast(result); 542 return Handle<JSFunction>::cast(result);
542 } 543 }
543 544
544 545
545 Handle<JSObject> Execution::InstantiateObject(Handle<ObjectTemplateInfo> data, 546 Handle<JSObject> Execution::InstantiateObject(Handle<ObjectTemplateInfo> data,
546 bool* exc) { 547 bool* exc) {
547 if (data->property_list()->IsUndefined() && 548 if (data->property_list()->IsUndefined() &&
548 !data->constructor()->IsUndefined()) { 549 !data->constructor()->IsUndefined()) {
549 // Initialization to make gcc happy. 550 // Initialization to make gcc happy.
550 Object* result = NULL; 551 Object* result = NULL;
551 { 552 {
552 HandleScope scope; 553 HandleScope scope;
553 Handle<FunctionTemplateInfo> cons_template = 554 Handle<FunctionTemplateInfo> cons_template =
554 Handle<FunctionTemplateInfo>( 555 Handle<FunctionTemplateInfo>(
555 FunctionTemplateInfo::cast(data->constructor())); 556 FunctionTemplateInfo::cast(data->constructor()));
556 Handle<JSFunction> cons = InstantiateFunction(cons_template, exc); 557 Handle<JSFunction> cons = InstantiateFunction(cons_template, exc);
557 if (*exc) return Handle<JSObject>::null(); 558 if (*exc) return Handle<JSObject>::null();
558 Handle<Object> value = New(cons, 0, NULL, exc); 559 Handle<Object> value = New(cons, 0, NULL, exc);
559 if (*exc) return Handle<JSObject>::null(); 560 if (*exc) return Handle<JSObject>::null();
560 result = *value; 561 result = *value;
561 } 562 }
562 ASSERT(!*exc); 563 ASSERT(!*exc);
563 return Handle<JSObject>(JSObject::cast(result)); 564 return Handle<JSObject>(JSObject::cast(result));
564 } else { 565 } else {
565 Object** args[1] = { Handle<Object>::cast(data).location() }; 566 Object** args[1] = { Handle<Object>::cast(data).location() };
566 Handle<Object> result = 567 Handle<Object> result =
567 Call(Isolate::Current()->instantiate_fun(), 568 Call(Isolate::Current()->instantiate_fun(),
568 Isolate::Current()->builtins(), 1, args, exc); 569 Isolate::Current()->js_builtins_object(), 1, args, exc);
569 if (*exc) return Handle<JSObject>::null(); 570 if (*exc) return Handle<JSObject>::null();
570 return Handle<JSObject>::cast(result); 571 return Handle<JSObject>::cast(result);
571 } 572 }
572 } 573 }
573 574
574 575
575 void Execution::ConfigureInstance(Handle<Object> instance, 576 void Execution::ConfigureInstance(Handle<Object> instance,
576 Handle<Object> instance_template, 577 Handle<Object> instance_template,
577 bool* exc) { 578 bool* exc) {
578 Object** args[2] = { instance.location(), instance_template.location() }; 579 Object** args[2] = { instance.location(), instance_template.location() };
579 Execution::Call(Isolate::Current()->configure_instance_fun(), 580 Execution::Call(Isolate::Current()->configure_instance_fun(),
580 Isolate::Current()->builtins(), 2, args, exc); 581 Isolate::Current()->js_builtins_object(), 2, args, exc);
581 } 582 }
582 583
583 584
584 Handle<String> Execution::GetStackTraceLine(Handle<Object> recv, 585 Handle<String> Execution::GetStackTraceLine(Handle<Object> recv,
585 Handle<JSFunction> fun, 586 Handle<JSFunction> fun,
586 Handle<Object> pos, 587 Handle<Object> pos,
587 Handle<Object> is_global) { 588 Handle<Object> is_global) {
588 const int argc = 4; 589 const int argc = 4;
589 Object** args[argc] = { recv.location(), 590 Object** args[argc] = { recv.location(),
590 Handle<Object>::cast(fun).location(), 591 Handle<Object>::cast(fun).location(),
591 pos.location(), 592 pos.location(),
592 is_global.location() }; 593 is_global.location() };
593 bool caught_exception = false; 594 bool caught_exception = false;
594 Handle<Object> result = 595 Handle<Object> result =
595 TryCall(Isolate::Current()->get_stack_trace_line_fun(), 596 TryCall(Isolate::Current()->get_stack_trace_line_fun(),
596 Isolate::Current()->builtins(), argc, args, &caught_exception); 597 Isolate::Current()->js_builtins_object(), argc, args,
598 &caught_exception);
597 if (caught_exception || !result->IsString()) return Factory::empty_symbol(); 599 if (caught_exception || !result->IsString()) return Factory::empty_symbol();
598 return Handle<String>::cast(result); 600 return Handle<String>::cast(result);
599 } 601 }
600 602
601 603
602 static Object* RuntimePreempt() { 604 static Object* RuntimePreempt() {
603 Isolate* isolate = Isolate::Current(); 605 Isolate* isolate = Isolate::Current();
604 606
605 // Clear the preempt request flag. 607 // Clear the preempt request flag.
606 isolate->stack_guard()->Continue(PREEMPT); 608 isolate->stack_guard()->Continue(PREEMPT);
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
730 // All allocation spaces other than NEW_SPACE have the same effect. 732 // All allocation spaces other than NEW_SPACE have the same effect.
731 HEAP->CollectAllGarbage(false); 733 HEAP->CollectAllGarbage(false);
732 return v8::Undefined(); 734 return v8::Undefined();
733 } 735 }
734 736
735 737
736 static GCExtension kGCExtension; 738 static GCExtension kGCExtension;
737 v8::DeclareExtension kGCExtensionDeclaration(&kGCExtension); 739 v8::DeclareExtension kGCExtensionDeclaration(&kGCExtension);
738 740
739 } } // namespace v8::internal 741 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/disassembler.cc ('k') | src/factory.cc » ('j') | src/runtime.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698