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

Side by Side Diff: src/api.cc

Issue 153953005: A64: Synchronize with r16993. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 10 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/accessors.cc ('k') | src/arguments.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 // 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 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 i::FlagList::SetFlagsFromString(str, length); 466 i::FlagList::SetFlagsFromString(str, length);
467 } 467 }
468 468
469 469
470 void V8::SetFlagsFromCommandLine(int* argc, char** argv, bool remove_flags) { 470 void V8::SetFlagsFromCommandLine(int* argc, char** argv, bool remove_flags) {
471 i::FlagList::SetFlagsFromCommandLine(argc, argv, remove_flags); 471 i::FlagList::SetFlagsFromCommandLine(argc, argv, remove_flags);
472 } 472 }
473 473
474 474
475 v8::Handle<Value> ThrowException(v8::Handle<v8::Value> value) { 475 v8::Handle<Value> ThrowException(v8::Handle<v8::Value> value) {
476 i::Isolate* isolate = i::Isolate::Current(); 476 return v8::Isolate::GetCurrent()->ThrowException(value);
477 ENTER_V8(isolate);
478 // If we're passed an empty handle, we throw an undefined exception
479 // to deal more gracefully with out of memory situations.
480 if (value.IsEmpty()) {
481 isolate->ScheduleThrow(isolate->heap()->undefined_value());
482 } else {
483 isolate->ScheduleThrow(*Utils::OpenHandle(*value));
484 }
485 return v8::Undefined();
486 } 477 }
487 478
488 479
489 RegisteredExtension* RegisteredExtension::first_extension_ = NULL; 480 RegisteredExtension* RegisteredExtension::first_extension_ = NULL;
490 481
491 482
492 RegisteredExtension::RegisteredExtension(Extension* extension) 483 RegisteredExtension::RegisteredExtension(Extension* extension)
493 : extension_(extension) { } 484 : extension_(extension) { }
494 485
495 486
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 return v8::Handle<Boolean>(); 556 return v8::Handle<Boolean>();
566 } 557 }
567 return ToApiHandle<Boolean>(isolate->factory()->false_value()); 558 return ToApiHandle<Boolean>(isolate->factory()->false_value());
568 } 559 }
569 560
570 561
571 ResourceConstraints::ResourceConstraints() 562 ResourceConstraints::ResourceConstraints()
572 : max_young_space_size_(0), 563 : max_young_space_size_(0),
573 max_old_space_size_(0), 564 max_old_space_size_(0),
574 max_executable_size_(0), 565 max_executable_size_(0),
575 stack_limit_(NULL), 566 stack_limit_(NULL) { }
576 is_memory_constrained_() { }
577 567
578 568
579 bool SetResourceConstraints(ResourceConstraints* constraints) { 569 bool SetResourceConstraints(ResourceConstraints* constraints) {
580 i::Isolate* isolate = EnterIsolateIfNeeded(); 570 i::Isolate* isolate = EnterIsolateIfNeeded();
581 571
582 int young_space_size = constraints->max_young_space_size(); 572 int young_space_size = constraints->max_young_space_size();
583 int old_gen_size = constraints->max_old_space_size(); 573 int old_gen_size = constraints->max_old_space_size();
584 int max_executable_size = constraints->max_executable_size(); 574 int max_executable_size = constraints->max_executable_size();
585 if (young_space_size != 0 || old_gen_size != 0 || max_executable_size != 0) { 575 if (young_space_size != 0 || old_gen_size != 0 || max_executable_size != 0) {
586 // After initialization it's too late to change Heap constraints. 576 // After initialization it's too late to change Heap constraints.
587 ASSERT(!isolate->IsInitialized()); 577 ASSERT(!isolate->IsInitialized());
588 bool result = isolate->heap()->ConfigureHeap(young_space_size / 2, 578 bool result = isolate->heap()->ConfigureHeap(young_space_size / 2,
589 old_gen_size, 579 old_gen_size,
590 max_executable_size); 580 max_executable_size);
591 if (!result) return false; 581 if (!result) return false;
592 } 582 }
593 if (constraints->stack_limit() != NULL) { 583 if (constraints->stack_limit() != NULL) {
594 uintptr_t limit = reinterpret_cast<uintptr_t>(constraints->stack_limit()); 584 uintptr_t limit = reinterpret_cast<uintptr_t>(constraints->stack_limit());
595 isolate->stack_guard()->SetStackLimit(limit); 585 isolate->stack_guard()->SetStackLimit(limit);
596 } 586 }
597 if (constraints->is_memory_constrained().has_value &&
598 !i::FLAG_force_memory_constrained.has_value) {
599 isolate->set_is_memory_constrained(
600 constraints->is_memory_constrained().value);
601 }
602 return true; 587 return true;
603 } 588 }
604 589
605 590
606 i::Object** V8::GlobalizeReference(i::Isolate* isolate, i::Object** obj) { 591 i::Object** V8::GlobalizeReference(i::Isolate* isolate, i::Object** obj) {
607 LOG_API(isolate, "Persistent::New"); 592 LOG_API(isolate, "Persistent::New");
608 i::Handle<i::Object> result = isolate->global_handles()->Create(*obj); 593 i::Handle<i::Object> result = isolate->global_handles()->Create(*obj);
609 #ifdef DEBUG 594 #ifdef DEBUG
610 (*obj)->Verify(); 595 (*obj)->Verify();
611 #endif // DEBUG 596 #endif // DEBUG
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
691 676
692 int HandleScope::NumberOfHandles() { 677 int HandleScope::NumberOfHandles() {
693 i::Isolate* isolate = i::Isolate::Current(); 678 i::Isolate* isolate = i::Isolate::Current();
694 if (!EnsureInitializedForIsolate(isolate, "HandleScope::NumberOfHandles")) { 679 if (!EnsureInitializedForIsolate(isolate, "HandleScope::NumberOfHandles")) {
695 return 0; 680 return 0;
696 } 681 }
697 return i::HandleScope::NumberOfHandles(isolate); 682 return i::HandleScope::NumberOfHandles(isolate);
698 } 683 }
699 684
700 685
701 i::Object** HandleScope::CreateHandle(i::Object* value) {
702 return i::HandleScope::CreateHandle(i::Isolate::Current(), value);
703 }
704
705
706 i::Object** HandleScope::CreateHandle(i::Isolate* isolate, i::Object* value) { 686 i::Object** HandleScope::CreateHandle(i::Isolate* isolate, i::Object* value) {
707 ASSERT(isolate == i::Isolate::Current());
708 return i::HandleScope::CreateHandle(isolate, value); 687 return i::HandleScope::CreateHandle(isolate, value);
709 } 688 }
710 689
711 690
712 i::Object** HandleScope::CreateHandle(i::HeapObject* value) { 691 i::Object** HandleScope::CreateHandle(i::HeapObject* heap_object,
713 ASSERT(value->IsHeapObject()); 692 i::Object* value) {
714 return reinterpret_cast<i::Object**>( 693 ASSERT(heap_object->IsHeapObject());
715 i::HandleScope::CreateHandle(value->GetIsolate(), value)); 694 return i::HandleScope::CreateHandle(heap_object->GetIsolate(), value);
716 } 695 }
717 696
718 697
698 EscapableHandleScope::EscapableHandleScope(Isolate* v8_isolate) {
699 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
700 escape_slot_ = CreateHandle(isolate, isolate->heap()->the_hole_value());
701 Initialize(v8_isolate);
702 }
703
704
705 i::Object** EscapableHandleScope::Escape(i::Object** escape_value) {
706 ApiCheck(*escape_slot_ == isolate_->heap()->the_hole_value(),
707 "EscapeableHandleScope::Escape",
708 "Escape value set twice");
709 if (escape_value == NULL) {
710 *escape_slot_ = isolate_->heap()->undefined_value();
711 return NULL;
712 }
713 *escape_slot_ = *escape_value;
714 return escape_slot_;
715 }
716
717
719 void Context::Enter() { 718 void Context::Enter() {
720 i::Handle<i::Context> env = Utils::OpenHandle(this); 719 i::Handle<i::Context> env = Utils::OpenHandle(this);
721 i::Isolate* isolate = env->GetIsolate(); 720 i::Isolate* isolate = env->GetIsolate();
722 ENTER_V8(isolate); 721 ENTER_V8(isolate);
723 isolate->handle_scope_implementer()->EnterContext(env); 722 isolate->handle_scope_implementer()->EnterContext(env);
724 isolate->handle_scope_implementer()->SaveContext(isolate->context()); 723 isolate->handle_scope_implementer()->SaveContext(isolate->context());
725 isolate->set_context(*env); 724 isolate->set_context(*env);
726 } 725 }
727 726
728 727
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
1012 i::Handle<i::FunctionTemplateInfo>::cast(struct_obj); 1011 i::Handle<i::FunctionTemplateInfo>::cast(struct_obj);
1013 InitializeFunctionTemplate(obj); 1012 InitializeFunctionTemplate(obj);
1014 obj->set_do_not_cache(do_not_cache); 1013 obj->set_do_not_cache(do_not_cache);
1015 int next_serial_number = 0; 1014 int next_serial_number = 0;
1016 if (!do_not_cache) { 1015 if (!do_not_cache) {
1017 next_serial_number = isolate->next_serial_number() + 1; 1016 next_serial_number = isolate->next_serial_number() + 1;
1018 isolate->set_next_serial_number(next_serial_number); 1017 isolate->set_next_serial_number(next_serial_number);
1019 } 1018 }
1020 obj->set_serial_number(i::Smi::FromInt(next_serial_number)); 1019 obj->set_serial_number(i::Smi::FromInt(next_serial_number));
1021 if (callback != 0) { 1020 if (callback != 0) {
1022 if (data.IsEmpty()) data = v8::Undefined(); 1021 if (data.IsEmpty()) {
1022 data = v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate));
1023 }
1023 Utils::ToLocal(obj)->SetCallHandler(callback, data); 1024 Utils::ToLocal(obj)->SetCallHandler(callback, data);
1024 } 1025 }
1025 obj->set_length(length); 1026 obj->set_length(length);
1026 obj->set_undetectable(false); 1027 obj->set_undetectable(false);
1027 obj->set_needs_access_check(false); 1028 obj->set_needs_access_check(false);
1028 if (!signature.IsEmpty()) 1029 if (!signature.IsEmpty())
1029 obj->set_signature(*Utils::OpenHandle(*signature)); 1030 obj->set_signature(*Utils::OpenHandle(*signature));
1030 return Utils::ToLocal(obj); 1031 return Utils::ToLocal(obj);
1031 } 1032 }
1032 1033
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
1236 void FunctionTemplate::SetCallHandler(FunctionCallback callback, 1237 void FunctionTemplate::SetCallHandler(FunctionCallback callback,
1237 v8::Handle<Value> data) { 1238 v8::Handle<Value> data) {
1238 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 1239 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1239 ENTER_V8(isolate); 1240 ENTER_V8(isolate);
1240 i::HandleScope scope(isolate); 1241 i::HandleScope scope(isolate);
1241 i::Handle<i::Struct> struct_obj = 1242 i::Handle<i::Struct> struct_obj =
1242 isolate->factory()->NewStruct(i::CALL_HANDLER_INFO_TYPE); 1243 isolate->factory()->NewStruct(i::CALL_HANDLER_INFO_TYPE);
1243 i::Handle<i::CallHandlerInfo> obj = 1244 i::Handle<i::CallHandlerInfo> obj =
1244 i::Handle<i::CallHandlerInfo>::cast(struct_obj); 1245 i::Handle<i::CallHandlerInfo>::cast(struct_obj);
1245 SET_FIELD_WRAPPED(obj, set_callback, callback); 1246 SET_FIELD_WRAPPED(obj, set_callback, callback);
1246 if (data.IsEmpty()) data = v8::Undefined(); 1247 if (data.IsEmpty()) {
1248 data = v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate));
1249 }
1247 obj->set_data(*Utils::OpenHandle(*data)); 1250 obj->set_data(*Utils::OpenHandle(*data));
1248 Utils::OpenHandle(this)->set_call_code(*obj); 1251 Utils::OpenHandle(this)->set_call_code(*obj);
1249 } 1252 }
1250 1253
1251 1254
1252 static i::Handle<i::AccessorInfo> SetAccessorInfoProperties( 1255 static i::Handle<i::AccessorInfo> SetAccessorInfoProperties(
1253 i::Handle<i::AccessorInfo> obj, 1256 i::Handle<i::AccessorInfo> obj,
1254 v8::Handle<String> name, 1257 v8::Handle<String> name,
1255 v8::AccessControl settings, 1258 v8::AccessControl settings,
1256 v8::PropertyAttribute attributes, 1259 v8::PropertyAttribute attributes,
(...skipping 17 matching lines...) Expand all
1274 Setter setter, 1277 Setter setter,
1275 v8::Handle<Value> data, 1278 v8::Handle<Value> data,
1276 v8::AccessControl settings, 1279 v8::AccessControl settings,
1277 v8::PropertyAttribute attributes, 1280 v8::PropertyAttribute attributes,
1278 v8::Handle<AccessorSignature> signature) { 1281 v8::Handle<AccessorSignature> signature) {
1279 i::Isolate* isolate = Utils::OpenHandle(*name)->GetIsolate(); 1282 i::Isolate* isolate = Utils::OpenHandle(*name)->GetIsolate();
1280 i::Handle<i::ExecutableAccessorInfo> obj = 1283 i::Handle<i::ExecutableAccessorInfo> obj =
1281 isolate->factory()->NewExecutableAccessorInfo(); 1284 isolate->factory()->NewExecutableAccessorInfo();
1282 SET_FIELD_WRAPPED(obj, set_getter, getter); 1285 SET_FIELD_WRAPPED(obj, set_getter, getter);
1283 SET_FIELD_WRAPPED(obj, set_setter, setter); 1286 SET_FIELD_WRAPPED(obj, set_setter, setter);
1284 if (data.IsEmpty()) data = v8::Undefined(); 1287 if (data.IsEmpty()) {
1288 data = v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate));
1289 }
1285 obj->set_data(*Utils::OpenHandle(*data)); 1290 obj->set_data(*Utils::OpenHandle(*data));
1286 return SetAccessorInfoProperties(obj, name, settings, attributes, signature); 1291 return SetAccessorInfoProperties(obj, name, settings, attributes, signature);
1287 } 1292 }
1288 1293
1289 1294
1290 static i::Handle<i::AccessorInfo> MakeAccessorInfo( 1295 static i::Handle<i::AccessorInfo> MakeAccessorInfo(
1291 v8::Handle<String> name, 1296 v8::Handle<String> name,
1292 v8::Handle<v8::DeclaredAccessorDescriptor> descriptor, 1297 v8::Handle<v8::DeclaredAccessorDescriptor> descriptor,
1293 void* setter_ignored, 1298 void* setter_ignored,
1294 void* data_ignored, 1299 void* data_ignored,
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
1502 isolate->factory()->NewStruct(i::INTERCEPTOR_INFO_TYPE); 1507 isolate->factory()->NewStruct(i::INTERCEPTOR_INFO_TYPE);
1503 i::Handle<i::InterceptorInfo> obj = 1508 i::Handle<i::InterceptorInfo> obj =
1504 i::Handle<i::InterceptorInfo>::cast(struct_obj); 1509 i::Handle<i::InterceptorInfo>::cast(struct_obj);
1505 1510
1506 if (getter != 0) SET_FIELD_WRAPPED(obj, set_getter, getter); 1511 if (getter != 0) SET_FIELD_WRAPPED(obj, set_getter, getter);
1507 if (setter != 0) SET_FIELD_WRAPPED(obj, set_setter, setter); 1512 if (setter != 0) SET_FIELD_WRAPPED(obj, set_setter, setter);
1508 if (query != 0) SET_FIELD_WRAPPED(obj, set_query, query); 1513 if (query != 0) SET_FIELD_WRAPPED(obj, set_query, query);
1509 if (remover != 0) SET_FIELD_WRAPPED(obj, set_deleter, remover); 1514 if (remover != 0) SET_FIELD_WRAPPED(obj, set_deleter, remover);
1510 if (enumerator != 0) SET_FIELD_WRAPPED(obj, set_enumerator, enumerator); 1515 if (enumerator != 0) SET_FIELD_WRAPPED(obj, set_enumerator, enumerator);
1511 1516
1512 if (data.IsEmpty()) data = v8::Undefined(); 1517 if (data.IsEmpty()) {
1518 data = v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate));
1519 }
1513 obj->set_data(*Utils::OpenHandle(*data)); 1520 obj->set_data(*Utils::OpenHandle(*data));
1514 cons->set_named_property_handler(*obj); 1521 cons->set_named_property_handler(*obj);
1515 } 1522 }
1516 1523
1517 1524
1518 void ObjectTemplate::MarkAsUndetectable() { 1525 void ObjectTemplate::MarkAsUndetectable() {
1519 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 1526 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1520 ENTER_V8(isolate); 1527 ENTER_V8(isolate);
1521 i::HandleScope scope(isolate); 1528 i::HandleScope scope(isolate);
1522 EnsureConstructor(this); 1529 EnsureConstructor(this);
(...skipping 15 matching lines...) Expand all
1538 EnsureConstructor(this); 1545 EnsureConstructor(this);
1539 1546
1540 i::Handle<i::Struct> struct_info = 1547 i::Handle<i::Struct> struct_info =
1541 isolate->factory()->NewStruct(i::ACCESS_CHECK_INFO_TYPE); 1548 isolate->factory()->NewStruct(i::ACCESS_CHECK_INFO_TYPE);
1542 i::Handle<i::AccessCheckInfo> info = 1549 i::Handle<i::AccessCheckInfo> info =
1543 i::Handle<i::AccessCheckInfo>::cast(struct_info); 1550 i::Handle<i::AccessCheckInfo>::cast(struct_info);
1544 1551
1545 SET_FIELD_WRAPPED(info, set_named_callback, named_callback); 1552 SET_FIELD_WRAPPED(info, set_named_callback, named_callback);
1546 SET_FIELD_WRAPPED(info, set_indexed_callback, indexed_callback); 1553 SET_FIELD_WRAPPED(info, set_indexed_callback, indexed_callback);
1547 1554
1548 if (data.IsEmpty()) data = v8::Undefined(); 1555 if (data.IsEmpty()) {
1556 data = v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate));
1557 }
1549 info->set_data(*Utils::OpenHandle(*data)); 1558 info->set_data(*Utils::OpenHandle(*data));
1550 1559
1551 i::FunctionTemplateInfo* constructor = 1560 i::FunctionTemplateInfo* constructor =
1552 i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor()); 1561 i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor());
1553 i::Handle<i::FunctionTemplateInfo> cons(constructor); 1562 i::Handle<i::FunctionTemplateInfo> cons(constructor);
1554 cons->set_access_check_info(*info); 1563 cons->set_access_check_info(*info);
1555 cons->set_needs_access_check(turned_on_by_default); 1564 cons->set_needs_access_check(turned_on_by_default);
1556 } 1565 }
1557 1566
1558 1567
(...skipping 15 matching lines...) Expand all
1574 isolate->factory()->NewStruct(i::INTERCEPTOR_INFO_TYPE); 1583 isolate->factory()->NewStruct(i::INTERCEPTOR_INFO_TYPE);
1575 i::Handle<i::InterceptorInfo> obj = 1584 i::Handle<i::InterceptorInfo> obj =
1576 i::Handle<i::InterceptorInfo>::cast(struct_obj); 1585 i::Handle<i::InterceptorInfo>::cast(struct_obj);
1577 1586
1578 if (getter != 0) SET_FIELD_WRAPPED(obj, set_getter, getter); 1587 if (getter != 0) SET_FIELD_WRAPPED(obj, set_getter, getter);
1579 if (setter != 0) SET_FIELD_WRAPPED(obj, set_setter, setter); 1588 if (setter != 0) SET_FIELD_WRAPPED(obj, set_setter, setter);
1580 if (query != 0) SET_FIELD_WRAPPED(obj, set_query, query); 1589 if (query != 0) SET_FIELD_WRAPPED(obj, set_query, query);
1581 if (remover != 0) SET_FIELD_WRAPPED(obj, set_deleter, remover); 1590 if (remover != 0) SET_FIELD_WRAPPED(obj, set_deleter, remover);
1582 if (enumerator != 0) SET_FIELD_WRAPPED(obj, set_enumerator, enumerator); 1591 if (enumerator != 0) SET_FIELD_WRAPPED(obj, set_enumerator, enumerator);
1583 1592
1584 if (data.IsEmpty()) data = v8::Undefined(); 1593 if (data.IsEmpty()) {
1594 data = v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate));
1595 }
1585 obj->set_data(*Utils::OpenHandle(*data)); 1596 obj->set_data(*Utils::OpenHandle(*data));
1586 cons->set_indexed_property_handler(*obj); 1597 cons->set_indexed_property_handler(*obj);
1587 } 1598 }
1588 1599
1589 1600
1590 void ObjectTemplate::SetCallAsFunctionHandler(FunctionCallback callback, 1601 void ObjectTemplate::SetCallAsFunctionHandler(FunctionCallback callback,
1591 Handle<Value> data) { 1602 Handle<Value> data) {
1592 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 1603 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1593 ENTER_V8(isolate); 1604 ENTER_V8(isolate);
1594 i::HandleScope scope(isolate); 1605 i::HandleScope scope(isolate);
1595 EnsureConstructor(this); 1606 EnsureConstructor(this);
1596 i::FunctionTemplateInfo* constructor = i::FunctionTemplateInfo::cast( 1607 i::FunctionTemplateInfo* constructor = i::FunctionTemplateInfo::cast(
1597 Utils::OpenHandle(this)->constructor()); 1608 Utils::OpenHandle(this)->constructor());
1598 i::Handle<i::FunctionTemplateInfo> cons(constructor); 1609 i::Handle<i::FunctionTemplateInfo> cons(constructor);
1599 i::Handle<i::Struct> struct_obj = 1610 i::Handle<i::Struct> struct_obj =
1600 isolate->factory()->NewStruct(i::CALL_HANDLER_INFO_TYPE); 1611 isolate->factory()->NewStruct(i::CALL_HANDLER_INFO_TYPE);
1601 i::Handle<i::CallHandlerInfo> obj = 1612 i::Handle<i::CallHandlerInfo> obj =
1602 i::Handle<i::CallHandlerInfo>::cast(struct_obj); 1613 i::Handle<i::CallHandlerInfo>::cast(struct_obj);
1603 SET_FIELD_WRAPPED(obj, set_callback, callback); 1614 SET_FIELD_WRAPPED(obj, set_callback, callback);
1604 if (data.IsEmpty()) data = v8::Undefined(); 1615 if (data.IsEmpty()) {
1616 data = v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate));
1617 }
1605 obj->set_data(*Utils::OpenHandle(*data)); 1618 obj->set_data(*Utils::OpenHandle(*data));
1606 cons->set_instance_call_handler(*obj); 1619 cons->set_instance_call_handler(*obj);
1607 } 1620 }
1608 1621
1609 1622
1610 int ObjectTemplate::InternalFieldCount() { 1623 int ObjectTemplate::InternalFieldCount() {
1611 return i::Smi::cast(Utils::OpenHandle(this)->internal_field_count())->value(); 1624 return i::Smi::cast(Utils::OpenHandle(this)->internal_field_count())->value();
1612 } 1625 }
1613 1626
1614 1627
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
1699 name_obj = Utils::OpenHandle(*origin->ResourceName()); 1712 name_obj = Utils::OpenHandle(*origin->ResourceName());
1700 } 1713 }
1701 if (!origin->ResourceLineOffset().IsEmpty()) { 1714 if (!origin->ResourceLineOffset().IsEmpty()) {
1702 line_offset = static_cast<int>(origin->ResourceLineOffset()->Value()); 1715 line_offset = static_cast<int>(origin->ResourceLineOffset()->Value());
1703 } 1716 }
1704 if (!origin->ResourceColumnOffset().IsEmpty()) { 1717 if (!origin->ResourceColumnOffset().IsEmpty()) {
1705 column_offset = 1718 column_offset =
1706 static_cast<int>(origin->ResourceColumnOffset()->Value()); 1719 static_cast<int>(origin->ResourceColumnOffset()->Value());
1707 } 1720 }
1708 if (!origin->ResourceIsSharedCrossOrigin().IsEmpty()) { 1721 if (!origin->ResourceIsSharedCrossOrigin().IsEmpty()) {
1722 v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate);
1709 is_shared_cross_origin = 1723 is_shared_cross_origin =
1710 origin->ResourceIsSharedCrossOrigin() == v8::True(); 1724 origin->ResourceIsSharedCrossOrigin() == v8::True(v8_isolate);
1711 } 1725 }
1712 } 1726 }
1713 EXCEPTION_PREAMBLE(isolate); 1727 EXCEPTION_PREAMBLE(isolate);
1714 i::ScriptDataImpl* pre_data_impl = 1728 i::ScriptDataImpl* pre_data_impl =
1715 static_cast<i::ScriptDataImpl*>(pre_data); 1729 static_cast<i::ScriptDataImpl*>(pre_data);
1716 // We assert that the pre-data is sane, even though we can actually 1730 // We assert that the pre-data is sane, even though we can actually
1717 // handle it if it turns out not to be in release mode. 1731 // handle it if it turns out not to be in release mode.
1718 ASSERT(pre_data_impl == NULL || pre_data_impl->SanityCheck()); 1732 ASSERT(pre_data_impl == NULL || pre_data_impl->SanityCheck());
1719 // If the pre-data isn't sane we simply ignore it 1733 // If the pre-data isn't sane we simply ignore it
1720 if (pre_data_impl != NULL && !pre_data_impl->SanityCheck()) { 1734 if (pre_data_impl != NULL && !pre_data_impl->SanityCheck()) {
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
1908 rethrow_(false), 1922 rethrow_(false),
1909 has_terminated_(false) { 1923 has_terminated_(false) {
1910 Reset(); 1924 Reset();
1911 isolate_->RegisterTryCatchHandler(this); 1925 isolate_->RegisterTryCatchHandler(this);
1912 } 1926 }
1913 1927
1914 1928
1915 v8::TryCatch::~TryCatch() { 1929 v8::TryCatch::~TryCatch() {
1916 ASSERT(isolate_ == i::Isolate::Current()); 1930 ASSERT(isolate_ == i::Isolate::Current());
1917 if (rethrow_) { 1931 if (rethrow_) {
1918 v8::HandleScope scope(reinterpret_cast<Isolate*>(isolate_)); 1932 v8::Isolate* isolate = reinterpret_cast<Isolate*>(isolate_);
1919 v8::Local<v8::Value> exc = v8::Local<v8::Value>::New(Exception()); 1933 v8::HandleScope scope(isolate);
1934 v8::Local<v8::Value> exc = v8::Local<v8::Value>::New(isolate, Exception());
1920 if (HasCaught() && capture_message_) { 1935 if (HasCaught() && capture_message_) {
1921 // If an exception was caught and rethrow_ is indicated, the saved 1936 // If an exception was caught and rethrow_ is indicated, the saved
1922 // message, script, and location need to be restored to Isolate TLS 1937 // message, script, and location need to be restored to Isolate TLS
1923 // for reuse. capture_message_ needs to be disabled so that DoThrow() 1938 // for reuse. capture_message_ needs to be disabled so that DoThrow()
1924 // does not create a new message. 1939 // does not create a new message.
1925 isolate_->thread_local_top()->rethrowing_message_ = true; 1940 isolate_->thread_local_top()->rethrowing_message_ = true;
1926 isolate_->RestorePendingMessageFromTryCatch(this); 1941 isolate_->RestorePendingMessageFromTryCatch(this);
1927 } 1942 }
1928 isolate_->UnregisterTryCatchHandler(this); 1943 isolate_->UnregisterTryCatchHandler(this);
1929 v8::ThrowException(exc); 1944 reinterpret_cast<Isolate*>(isolate_)->ThrowException(exc);
1930 ASSERT(!isolate_->thread_local_top()->rethrowing_message_); 1945 ASSERT(!isolate_->thread_local_top()->rethrowing_message_);
1931 } else { 1946 } else {
1932 isolate_->UnregisterTryCatchHandler(this); 1947 isolate_->UnregisterTryCatchHandler(this);
1933 } 1948 }
1934 } 1949 }
1935 1950
1936 1951
1937 bool v8::TryCatch::HasCaught() const { 1952 bool v8::TryCatch::HasCaught() const {
1938 return !reinterpret_cast<i::Object*>(exception_)->IsTheHole(); 1953 return !reinterpret_cast<i::Object*>(exception_)->IsTheHole();
1939 } 1954 }
1940 1955
1941 1956
1942 bool v8::TryCatch::CanContinue() const { 1957 bool v8::TryCatch::CanContinue() const {
1943 return can_continue_; 1958 return can_continue_;
1944 } 1959 }
1945 1960
1946 1961
1947 bool v8::TryCatch::HasTerminated() const { 1962 bool v8::TryCatch::HasTerminated() const {
1948 return has_terminated_; 1963 return has_terminated_;
1949 } 1964 }
1950 1965
1951 1966
1952 v8::Handle<v8::Value> v8::TryCatch::ReThrow() { 1967 v8::Handle<v8::Value> v8::TryCatch::ReThrow() {
1953 if (!HasCaught()) return v8::Local<v8::Value>(); 1968 if (!HasCaught()) return v8::Local<v8::Value>();
1954 rethrow_ = true; 1969 rethrow_ = true;
1955 return v8::Undefined(); 1970 return v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate_));
1956 } 1971 }
1957 1972
1958 1973
1959 v8::Local<Value> v8::TryCatch::Exception() const { 1974 v8::Local<Value> v8::TryCatch::Exception() const {
1960 ASSERT(isolate_ == i::Isolate::Current()); 1975 ASSERT(isolate_ == i::Isolate::Current());
1961 if (HasCaught()) { 1976 if (HasCaught()) {
1962 // Check for out of memory exception. 1977 // Check for out of memory exception.
1963 i::Object* exception = reinterpret_cast<i::Object*>(exception_); 1978 i::Object* exception = reinterpret_cast<i::Object*>(exception_);
1964 return v8::Utils::ToLocal(i::Handle<i::Object>(exception, isolate_)); 1979 return v8::Utils::ToLocal(i::Handle<i::Object>(exception, isolate_));
1965 } else { 1980 } else {
(...skipping 1082 matching lines...) Expand 10 before | Expand all | Expand 10 after
3048 return other->IsString() && 3063 return other->IsString() &&
3049 i::String::cast(*obj)->Equals(i::String::cast(*other)); 3064 i::String::cast(*obj)->Equals(i::String::cast(*other));
3050 } else if (obj->IsUndefined() || obj->IsUndetectableObject()) { 3065 } else if (obj->IsUndefined() || obj->IsUndetectableObject()) {
3051 return other->IsUndefined() || other->IsUndetectableObject(); 3066 return other->IsUndefined() || other->IsUndetectableObject();
3052 } else { 3067 } else {
3053 return false; 3068 return false;
3054 } 3069 }
3055 } 3070 }
3056 3071
3057 3072
3073 bool Value::SameValue(Handle<Value> that) const {
3074 i::Isolate* isolate = i::Isolate::Current();
3075 if (EmptyCheck("v8::Value::SameValue()", this) ||
3076 EmptyCheck("v8::Value::SameValue()", that)) {
3077 return false;
3078 }
3079 LOG_API(isolate, "SameValue");
3080 i::Handle<i::Object> obj = Utils::OpenHandle(this);
3081 i::Handle<i::Object> other = Utils::OpenHandle(*that);
3082 return obj->SameValue(*other);
3083 }
3084
3085
3058 uint32_t Value::Uint32Value() const { 3086 uint32_t Value::Uint32Value() const {
3059 i::Handle<i::Object> obj = Utils::OpenHandle(this); 3087 i::Handle<i::Object> obj = Utils::OpenHandle(this);
3060 if (obj->IsSmi()) { 3088 if (obj->IsSmi()) {
3061 return i::Smi::cast(*obj)->value(); 3089 return i::Smi::cast(*obj)->value();
3062 } else { 3090 } else {
3063 i::Isolate* isolate = i::Isolate::Current(); 3091 i::Isolate* isolate = i::Isolate::Current();
3064 LOG_API(isolate, "Uint32Value"); 3092 LOG_API(isolate, "Uint32Value");
3065 ENTER_V8(isolate); 3093 ENTER_V8(isolate);
3066 EXCEPTION_PREAMBLE(isolate); 3094 EXCEPTION_PREAMBLE(isolate);
3067 i::Handle<i::Object> num = 3095 i::Handle<i::Object> num =
(...skipping 1034 matching lines...) Expand 10 before | Expand all | Expand 10 after
4102 if (func->shared()->script()->IsScript()) { 4130 if (func->shared()->script()->IsScript()) {
4103 i::Handle<i::Script> script(i::Script::cast(func->shared()->script())); 4131 i::Handle<i::Script> script(i::Script::cast(func->shared()->script()));
4104 return i::GetScriptColumnNumber(script, func->shared()->start_position()); 4132 return i::GetScriptColumnNumber(script, func->shared()->start_position());
4105 } 4133 }
4106 return kLineOffsetNotFound; 4134 return kLineOffsetNotFound;
4107 } 4135 }
4108 4136
4109 4137
4110 Handle<Value> Function::GetScriptId() const { 4138 Handle<Value> Function::GetScriptId() const {
4111 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); 4139 i::Handle<i::JSFunction> func = Utils::OpenHandle(this);
4112 if (!func->shared()->script()->IsScript()) 4140 i::Isolate* isolate = func->GetIsolate();
4113 return v8::Undefined(); 4141 if (!func->shared()->script()->IsScript()) {
4142 return v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate));
4143 }
4114 i::Handle<i::Script> script(i::Script::cast(func->shared()->script())); 4144 i::Handle<i::Script> script(i::Script::cast(func->shared()->script()));
4115 return Utils::ToLocal(i::Handle<i::Object>(script->id(), func->GetIsolate())); 4145 return Utils::ToLocal(i::Handle<i::Object>(script->id(), isolate));
4116 } 4146 }
4117 4147
4118 4148
4119 int Function::ScriptId() const { 4149 int Function::ScriptId() const {
4120 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); 4150 i::Handle<i::JSFunction> func = Utils::OpenHandle(this);
4121 if (!func->shared()->script()->IsScript()) return v8::Script::kNoScriptId; 4151 if (!func->shared()->script()->IsScript()) return v8::Script::kNoScriptId;
4122 i::Handle<i::Script> script(i::Script::cast(func->shared()->script())); 4152 i::Handle<i::Script> script(i::Script::cast(func->shared()->script()));
4123 return script->id()->value(); 4153 return script->id()->value();
4124 } 4154 }
4125 4155
(...skipping 2215 matching lines...) Expand 10 before | Expand all | Expand 10 after
6341 6371
6342 v8::Local<v8::Context> Isolate::GetEnteredContext() { 6372 v8::Local<v8::Context> Isolate::GetEnteredContext() {
6343 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); 6373 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
6344 i::Handle<i::Object> last = 6374 i::Handle<i::Object> last =
6345 isolate->handle_scope_implementer()->LastEnteredContext(); 6375 isolate->handle_scope_implementer()->LastEnteredContext();
6346 if (last.is_null()) return Local<Context>(); 6376 if (last.is_null()) return Local<Context>();
6347 return Utils::ToLocal(i::Handle<i::Context>::cast(last)); 6377 return Utils::ToLocal(i::Handle<i::Context>::cast(last));
6348 } 6378 }
6349 6379
6350 6380
6381 v8::Local<Value> Isolate::ThrowException(v8::Local<v8::Value> value) {
6382 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
6383 ENTER_V8(isolate);
6384 // If we're passed an empty handle, we throw an undefined exception
6385 // to deal more gracefully with out of memory situations.
6386 if (value.IsEmpty()) {
6387 isolate->ScheduleThrow(isolate->heap()->undefined_value());
6388 } else {
6389 isolate->ScheduleThrow(*Utils::OpenHandle(*value));
6390 }
6391 return v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate));
6392 }
6393
6394
6351 void Isolate::SetObjectGroupId(const Persistent<Value>& object, 6395 void Isolate::SetObjectGroupId(const Persistent<Value>& object,
6352 UniqueId id) { 6396 UniqueId id) {
6353 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(this); 6397 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(this);
6354 internal_isolate->global_handles()->SetObjectGroupId( 6398 internal_isolate->global_handles()->SetObjectGroupId(
6355 Utils::OpenPersistent(object).location(), 6399 Utils::OpenPersistent(object).location(),
6356 id); 6400 id);
6357 } 6401 }
6358 6402
6359 6403
6360 void Isolate::SetReferenceFromGroup(UniqueId id, 6404 void Isolate::SetReferenceFromGroup(UniqueId id,
(...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after
7088 case i::HeapGraphEdge::kShortcut: 7132 case i::HeapGraphEdge::kShortcut:
7089 return ToApiHandle<String>( 7133 return ToApiHandle<String>(
7090 isolate->factory()->InternalizeUtf8String(edge->name())); 7134 isolate->factory()->InternalizeUtf8String(edge->name()));
7091 case i::HeapGraphEdge::kElement: 7135 case i::HeapGraphEdge::kElement:
7092 case i::HeapGraphEdge::kHidden: 7136 case i::HeapGraphEdge::kHidden:
7093 case i::HeapGraphEdge::kWeak: 7137 case i::HeapGraphEdge::kWeak:
7094 return ToApiHandle<Number>( 7138 return ToApiHandle<Number>(
7095 isolate->factory()->NewNumberFromInt(edge->index())); 7139 isolate->factory()->NewNumberFromInt(edge->index()));
7096 default: UNREACHABLE(); 7140 default: UNREACHABLE();
7097 } 7141 }
7098 return v8::Undefined(); 7142 return v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate));
7099 } 7143 }
7100 7144
7101 7145
7102 const HeapGraphNode* HeapGraphEdge::GetFromNode() const { 7146 const HeapGraphNode* HeapGraphEdge::GetFromNode() const {
7103 const i::HeapEntry* from = ToInternal(this)->from(); 7147 const i::HeapEntry* from = ToInternal(this)->from();
7104 return reinterpret_cast<const HeapGraphNode*>(from); 7148 return reinterpret_cast<const HeapGraphNode*>(from);
7105 } 7149 }
7106 7150
7107 7151
7108 const HeapGraphNode* HeapGraphEdge::GetToNode() const { 7152 const HeapGraphNode* HeapGraphEdge::GetToNode() const {
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
7531 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 7575 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
7532 Address callback_address = 7576 Address callback_address =
7533 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 7577 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
7534 VMState<EXTERNAL> state(isolate); 7578 VMState<EXTERNAL> state(isolate);
7535 ExternalCallbackScope call_scope(isolate, callback_address); 7579 ExternalCallbackScope call_scope(isolate, callback_address);
7536 callback(info); 7580 callback(info);
7537 } 7581 }
7538 7582
7539 7583
7540 } } // namespace v8::internal 7584 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/accessors.cc ('k') | src/arguments.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698