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

Side by Side Diff: src/api.cc

Issue 151603004: A64: Synchronize with r16587. (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/apinatives.js » ('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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 #include "heap-profiler.h" 46 #include "heap-profiler.h"
47 #include "heap-snapshot-generator-inl.h" 47 #include "heap-snapshot-generator-inl.h"
48 #include "icu_util.h" 48 #include "icu_util.h"
49 #include "json-parser.h" 49 #include "json-parser.h"
50 #include "messages.h" 50 #include "messages.h"
51 #ifdef COMPRESS_STARTUP_DATA_BZ2 51 #ifdef COMPRESS_STARTUP_DATA_BZ2
52 #include "natives.h" 52 #include "natives.h"
53 #endif 53 #endif
54 #include "parser.h" 54 #include "parser.h"
55 #include "platform.h" 55 #include "platform.h"
56 #include "platform/time.h"
56 #include "profile-generator-inl.h" 57 #include "profile-generator-inl.h"
57 #include "property-details.h" 58 #include "property-details.h"
58 #include "property.h" 59 #include "property.h"
59 #include "runtime.h" 60 #include "runtime.h"
60 #include "runtime-profiler.h" 61 #include "runtime-profiler.h"
61 #include "scanner-character-streams.h" 62 #include "scanner-character-streams.h"
62 #include "snapshot.h" 63 #include "snapshot.h"
63 #include "unicode-inl.h" 64 #include "unicode-inl.h"
64 #include "v8threads.h" 65 #include "v8threads.h"
65 #include "version.h" 66 #include "version.h"
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 int os_error; 214 int os_error;
214 heap_stats.os_error = &os_error; 215 heap_stats.os_error = &os_error;
215 int end_marker; 216 int end_marker;
216 heap_stats.end_marker = &end_marker; 217 heap_stats.end_marker = &end_marker;
217 i::Isolate* isolate = i::Isolate::Current(); 218 i::Isolate* isolate = i::Isolate::Current();
218 if (isolate->heap()->HasBeenSetUp()) { 219 if (isolate->heap()->HasBeenSetUp()) {
219 // BUG(1718): Don't use the take_snapshot since we don't support 220 // BUG(1718): Don't use the take_snapshot since we don't support
220 // HeapIterator here without doing a special GC. 221 // HeapIterator here without doing a special GC.
221 isolate->heap()->RecordStats(&heap_stats, false); 222 isolate->heap()->RecordStats(&heap_stats, false);
222 } 223 }
223 i::V8::SetFatalError(); 224 isolate->SignalFatalError();
224 FatalErrorCallback callback = GetFatalErrorHandler(); 225 FatalErrorCallback callback = GetFatalErrorHandler();
225 const char* message = "Allocation failed - process out of memory"; 226 const char* message = "Allocation failed - process out of memory";
226 callback(location, message); 227 callback(location, message);
227 // If the callback returns, we stop execution. 228 // If the callback returns, we stop execution.
228 UNREACHABLE(); 229 FATAL("API fatal error handler returned after process out of memory");
229 } 230 }
230 231
231 232
232 bool Utils::ReportApiFailure(const char* location, const char* message) { 233 bool Utils::ReportApiFailure(const char* location, const char* message) {
233 FatalErrorCallback callback = GetFatalErrorHandler(); 234 FatalErrorCallback callback = GetFatalErrorHandler();
234 callback(location, message); 235 callback(location, message);
235 i::V8::SetFatalError(); 236 i::Isolate* isolate = i::Isolate::Current();
237 isolate->SignalFatalError();
236 return false; 238 return false;
237 } 239 }
238 240
239 241
240 bool V8::IsDead() { 242 bool V8::IsDead() {
241 return i::V8::IsDead(); 243 i::Isolate* isolate = i::Isolate::Current();
244 return isolate->IsDead();
242 } 245 }
243 246
244 247
245 static inline bool ApiCheck(bool condition, 248 static inline bool ApiCheck(bool condition,
246 const char* location, 249 const char* location,
247 const char* message) { 250 const char* message) {
248 return condition ? true : Utils::ReportApiFailure(location, message); 251 return condition ? true : Utils::ReportApiFailure(location, message);
249 } 252 }
250 253
251 254
(...skipping 18 matching lines...) Expand all
270 * which you sometimes can't avoid calling after the vm has crashed. Functions 273 * which you sometimes can't avoid calling after the vm has crashed. Functions
271 * that call EnsureInitialized or ON_BAILOUT don't have to also call 274 * that call EnsureInitialized or ON_BAILOUT don't have to also call
272 * IsDeadCheck. ON_BAILOUT has the advantage over EnsureInitialized that you 275 * IsDeadCheck. ON_BAILOUT has the advantage over EnsureInitialized that you
273 * can arrange to return if the VM is dead. This is needed to ensure that no VM 276 * can arrange to return if the VM is dead. This is needed to ensure that no VM
274 * heap allocations are attempted on a dead VM. EnsureInitialized has the 277 * heap allocations are attempted on a dead VM. EnsureInitialized has the
275 * advantage over ON_BAILOUT that it actually initializes the VM if this has not 278 * advantage over ON_BAILOUT that it actually initializes the VM if this has not
276 * yet been done. 279 * yet been done.
277 */ 280 */
278 static inline bool IsDeadCheck(i::Isolate* isolate, const char* location) { 281 static inline bool IsDeadCheck(i::Isolate* isolate, const char* location) {
279 return !isolate->IsInitialized() 282 return !isolate->IsInitialized()
280 && i::V8::IsDead() ? ReportV8Dead(location) : false; 283 && isolate->IsDead() ? ReportV8Dead(location) : false;
281 } 284 }
282 285
283 286
284 static inline bool IsExecutionTerminatingCheck(i::Isolate* isolate) { 287 static inline bool IsExecutionTerminatingCheck(i::Isolate* isolate) {
285 if (!isolate->IsInitialized()) return false; 288 if (!isolate->IsInitialized()) return false;
286 if (isolate->has_scheduled_exception()) { 289 if (isolate->has_scheduled_exception()) {
287 return isolate->scheduled_exception() == 290 return isolate->scheduled_exception() ==
288 isolate->heap()->termination_exception(); 291 isolate->heap()->termination_exception();
289 } 292 }
290 return false; 293 return false;
(...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after
1042 1045
1043 1046
1044 void FunctionTemplate::Inherit(v8::Handle<FunctionTemplate> value) { 1047 void FunctionTemplate::Inherit(v8::Handle<FunctionTemplate> value) {
1045 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 1048 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1046 if (IsDeadCheck(isolate, "v8::FunctionTemplate::Inherit()")) return; 1049 if (IsDeadCheck(isolate, "v8::FunctionTemplate::Inherit()")) return;
1047 ENTER_V8(isolate); 1050 ENTER_V8(isolate);
1048 Utils::OpenHandle(this)->set_parent_template(*Utils::OpenHandle(*value)); 1051 Utils::OpenHandle(this)->set_parent_template(*Utils::OpenHandle(*value));
1049 } 1052 }
1050 1053
1051 1054
1052 Local<FunctionTemplate> FunctionTemplate::New( 1055 static Local<FunctionTemplate> FunctionTemplateNew(
1056 i::Isolate* isolate,
1053 FunctionCallback callback, 1057 FunctionCallback callback,
1054 v8::Handle<Value> data, 1058 v8::Handle<Value> data,
1055 v8::Handle<Signature> signature, 1059 v8::Handle<Signature> signature,
1056 int length) { 1060 int length,
1057 i::Isolate* isolate = i::Isolate::Current(); 1061 bool do_not_cache) {
1058 EnsureInitializedForIsolate(isolate, "v8::FunctionTemplate::New()");
1059 LOG_API(isolate, "FunctionTemplate::New");
1060 ENTER_V8(isolate);
1061 i::Handle<i::Struct> struct_obj = 1062 i::Handle<i::Struct> struct_obj =
1062 isolate->factory()->NewStruct(i::FUNCTION_TEMPLATE_INFO_TYPE); 1063 isolate->factory()->NewStruct(i::FUNCTION_TEMPLATE_INFO_TYPE);
1063 i::Handle<i::FunctionTemplateInfo> obj = 1064 i::Handle<i::FunctionTemplateInfo> obj =
1064 i::Handle<i::FunctionTemplateInfo>::cast(struct_obj); 1065 i::Handle<i::FunctionTemplateInfo>::cast(struct_obj);
1065 InitializeFunctionTemplate(obj); 1066 InitializeFunctionTemplate(obj);
1066 int next_serial_number = isolate->next_serial_number(); 1067 obj->set_do_not_cache(do_not_cache);
1067 isolate->set_next_serial_number(next_serial_number + 1); 1068 int next_serial_number = 0;
1069 if (!do_not_cache) {
1070 next_serial_number = isolate->next_serial_number() + 1;
1071 isolate->set_next_serial_number(next_serial_number);
1072 }
1068 obj->set_serial_number(i::Smi::FromInt(next_serial_number)); 1073 obj->set_serial_number(i::Smi::FromInt(next_serial_number));
1069 if (callback != 0) { 1074 if (callback != 0) {
1070 if (data.IsEmpty()) data = v8::Undefined(); 1075 if (data.IsEmpty()) data = v8::Undefined();
1071 Utils::ToLocal(obj)->SetCallHandler(callback, data); 1076 Utils::ToLocal(obj)->SetCallHandler(callback, data);
1072 } 1077 }
1073 obj->set_length(length); 1078 obj->set_length(length);
1074 obj->set_undetectable(false); 1079 obj->set_undetectable(false);
1075 obj->set_needs_access_check(false); 1080 obj->set_needs_access_check(false);
1076
1077 if (!signature.IsEmpty()) 1081 if (!signature.IsEmpty())
1078 obj->set_signature(*Utils::OpenHandle(*signature)); 1082 obj->set_signature(*Utils::OpenHandle(*signature));
1079 return Utils::ToLocal(obj); 1083 return Utils::ToLocal(obj);
1080 } 1084 }
1081 1085
1086 Local<FunctionTemplate> FunctionTemplate::New(
1087 FunctionCallback callback,
1088 v8::Handle<Value> data,
1089 v8::Handle<Signature> signature,
1090 int length) {
1091 i::Isolate* isolate = i::Isolate::Current();
1092 EnsureInitializedForIsolate(isolate, "v8::FunctionTemplate::New()");
1093 LOG_API(isolate, "FunctionTemplate::New");
1094 ENTER_V8(isolate);
1095 return FunctionTemplateNew(
1096 isolate, callback, data, signature, length, false);
1097 }
1098
1082 1099
1083 Local<Signature> Signature::New(Handle<FunctionTemplate> receiver, 1100 Local<Signature> Signature::New(Handle<FunctionTemplate> receiver,
1084 int argc, Handle<FunctionTemplate> argv[]) { 1101 int argc, Handle<FunctionTemplate> argv[]) {
1085 i::Isolate* isolate = i::Isolate::Current(); 1102 i::Isolate* isolate = i::Isolate::Current();
1086 EnsureInitializedForIsolate(isolate, "v8::Signature::New()"); 1103 EnsureInitializedForIsolate(isolate, "v8::Signature::New()");
1087 LOG_API(isolate, "Signature::New"); 1104 LOG_API(isolate, "Signature::New");
1088 ENTER_V8(isolate); 1105 ENTER_V8(isolate);
1089 i::Handle<i::Struct> struct_obj = 1106 i::Handle<i::Struct> struct_obj =
1090 isolate->factory()->NewStruct(i::SIGNATURE_INFO_TYPE); 1107 isolate->factory()->NewStruct(i::SIGNATURE_INFO_TYPE);
1091 i::Handle<i::SignatureInfo> obj = 1108 i::Handle<i::SignatureInfo> obj =
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
1429 InitializeTemplate(obj, Consts::OBJECT_TEMPLATE); 1446 InitializeTemplate(obj, Consts::OBJECT_TEMPLATE);
1430 if (!constructor.IsEmpty()) 1447 if (!constructor.IsEmpty())
1431 obj->set_constructor(*Utils::OpenHandle(*constructor)); 1448 obj->set_constructor(*Utils::OpenHandle(*constructor));
1432 obj->set_internal_field_count(i::Smi::FromInt(0)); 1449 obj->set_internal_field_count(i::Smi::FromInt(0));
1433 return Utils::ToLocal(obj); 1450 return Utils::ToLocal(obj);
1434 } 1451 }
1435 1452
1436 1453
1437 // Ensure that the object template has a constructor. If no 1454 // Ensure that the object template has a constructor. If no
1438 // constructor is available we create one. 1455 // constructor is available we create one.
1439 static void EnsureConstructor(ObjectTemplate* object_template) { 1456 static i::Handle<i::FunctionTemplateInfo> EnsureConstructor(
1440 if (Utils::OpenHandle(object_template)->constructor()->IsUndefined()) { 1457 ObjectTemplate* object_template) {
1441 Local<FunctionTemplate> templ = FunctionTemplate::New(); 1458 i::Object* obj = Utils::OpenHandle(object_template)->constructor();
1442 i::Handle<i::FunctionTemplateInfo> constructor = Utils::OpenHandle(*templ); 1459 if (!obj ->IsUndefined()) {
1443 constructor->set_instance_template(*Utils::OpenHandle(object_template)); 1460 i::FunctionTemplateInfo* info = i::FunctionTemplateInfo::cast(obj);
1444 Utils::OpenHandle(object_template)->set_constructor(*constructor); 1461 return i::Handle<i::FunctionTemplateInfo>(info, info->GetIsolate());
1445 } 1462 }
1463 Local<FunctionTemplate> templ = FunctionTemplate::New();
1464 i::Handle<i::FunctionTemplateInfo> constructor = Utils::OpenHandle(*templ);
1465 constructor->set_instance_template(*Utils::OpenHandle(object_template));
1466 Utils::OpenHandle(object_template)->set_constructor(*constructor);
1467 return constructor;
1446 } 1468 }
1447 1469
1448 1470
1449 static inline void AddPropertyToFunctionTemplate( 1471 static inline void AddPropertyToTemplate(
1450 i::Handle<i::FunctionTemplateInfo> cons, 1472 i::Handle<i::TemplateInfo> info,
1451 i::Handle<i::AccessorInfo> obj) { 1473 i::Handle<i::AccessorInfo> obj) {
1452 i::Handle<i::Object> list(cons->property_accessors(), cons->GetIsolate()); 1474 i::Handle<i::Object> list(info->property_accessors(), info->GetIsolate());
1453 if (list->IsUndefined()) { 1475 if (list->IsUndefined()) {
1454 list = NeanderArray().value(); 1476 list = NeanderArray().value();
1455 cons->set_property_accessors(*list); 1477 info->set_property_accessors(*list);
1456 } 1478 }
1457 NeanderArray array(list); 1479 NeanderArray array(list);
1458 array.add(obj); 1480 array.add(obj);
1459 } 1481 }
1460 1482
1461 1483
1462 template<typename Setter, typename Getter, typename Data> 1484 static inline i::Handle<i::TemplateInfo> GetTemplateInfo(
1463 static bool ObjectTemplateSetAccessor( 1485 Template* template_obj) {
1464 ObjectTemplate* object_template, 1486 return Utils::OpenHandle(template_obj);
1465 v8::Handle<String> name, 1487 }
1488
1489
1490 // TODO(dcarney): remove this with ObjectTemplate::SetAccessor
1491 static inline i::Handle<i::TemplateInfo> GetTemplateInfo(
1492 ObjectTemplate* object_template) {
1493 EnsureConstructor(object_template);
1494 return Utils::OpenHandle(object_template);
1495 }
1496
1497
1498 template<typename Setter, typename Getter, typename Data, typename Template>
1499 static bool TemplateSetAccessor(
1500 Template* template_obj,
1501 v8::Local<String> name,
1466 Getter getter, 1502 Getter getter,
1467 Setter setter, 1503 Setter setter,
1468 Data data, 1504 Data data,
1469 AccessControl settings, 1505 AccessControl settings,
1470 PropertyAttribute attribute, 1506 PropertyAttribute attribute,
1471 v8::Handle<AccessorSignature> signature) { 1507 v8::Local<AccessorSignature> signature) {
1472 i::Isolate* isolate = Utils::OpenHandle(object_template)->GetIsolate(); 1508 i::Isolate* isolate = Utils::OpenHandle(template_obj)->GetIsolate();
1473 if (IsDeadCheck(isolate, "v8::ObjectTemplate::SetAccessor()")) return false; 1509 if (IsDeadCheck(isolate, "v8::ObjectTemplate::SetAccessor()")) return false;
1474 ENTER_V8(isolate); 1510 ENTER_V8(isolate);
1475 i::HandleScope scope(isolate); 1511 i::HandleScope scope(isolate);
1476 EnsureConstructor(object_template);
1477 i::FunctionTemplateInfo* constructor = i::FunctionTemplateInfo::cast(
1478 Utils::OpenHandle(object_template)->constructor());
1479 i::Handle<i::FunctionTemplateInfo> cons(constructor);
1480 i::Handle<i::AccessorInfo> obj = MakeAccessorInfo( 1512 i::Handle<i::AccessorInfo> obj = MakeAccessorInfo(
1481 name, getter, setter, data, settings, attribute, signature); 1513 name, getter, setter, data, settings, attribute, signature);
1482 if (obj.is_null()) return false; 1514 if (obj.is_null()) return false;
1483 AddPropertyToFunctionTemplate(cons, obj); 1515 i::Handle<i::TemplateInfo> info = GetTemplateInfo(template_obj);
1516 AddPropertyToTemplate(info, obj);
1484 return true; 1517 return true;
1485 } 1518 }
1486 1519
1487 1520
1521 bool Template::SetDeclaredAccessor(
1522 Local<String> name,
1523 Local<DeclaredAccessorDescriptor> descriptor,
1524 PropertyAttribute attribute,
1525 Local<AccessorSignature> signature,
1526 AccessControl settings) {
1527 void* null = NULL;
1528 return TemplateSetAccessor(
1529 this, name, descriptor, null, null, settings, attribute, signature);
1530 }
1531
1532
1533 void Template::SetNativeDataProperty(v8::Local<String> name,
1534 AccessorGetterCallback getter,
1535 AccessorSetterCallback setter,
1536 v8::Handle<Value> data,
1537 PropertyAttribute attribute,
1538 v8::Local<AccessorSignature> signature,
1539 AccessControl settings) {
1540 TemplateSetAccessor(
1541 this, name, getter, setter, data, settings, attribute, signature);
1542 }
1543
1544
1488 void ObjectTemplate::SetAccessor(v8::Handle<String> name, 1545 void ObjectTemplate::SetAccessor(v8::Handle<String> name,
1489 AccessorGetterCallback getter, 1546 AccessorGetterCallback getter,
1490 AccessorSetterCallback setter, 1547 AccessorSetterCallback setter,
1491 v8::Handle<Value> data, 1548 v8::Handle<Value> data,
1492 AccessControl settings, 1549 AccessControl settings,
1493 PropertyAttribute attribute, 1550 PropertyAttribute attribute,
1494 v8::Handle<AccessorSignature> signature) { 1551 v8::Handle<AccessorSignature> signature) {
1495 ObjectTemplateSetAccessor( 1552 TemplateSetAccessor(
1496 this, name, getter, setter, data, settings, attribute, signature); 1553 this, name, getter, setter, data, settings, attribute, signature);
1497 } 1554 }
1498 1555
1499 1556
1500 bool ObjectTemplate::SetAccessor(Handle<String> name,
1501 Handle<DeclaredAccessorDescriptor> descriptor,
1502 AccessControl settings,
1503 PropertyAttribute attribute,
1504 Handle<AccessorSignature> signature) {
1505 void* null = NULL;
1506 return ObjectTemplateSetAccessor(
1507 this, name, descriptor, null, null, settings, attribute, signature);
1508 }
1509
1510
1511 void ObjectTemplate::SetNamedPropertyHandler( 1557 void ObjectTemplate::SetNamedPropertyHandler(
1512 NamedPropertyGetterCallback getter, 1558 NamedPropertyGetterCallback getter,
1513 NamedPropertySetterCallback setter, 1559 NamedPropertySetterCallback setter,
1514 NamedPropertyQueryCallback query, 1560 NamedPropertyQueryCallback query,
1515 NamedPropertyDeleterCallback remover, 1561 NamedPropertyDeleterCallback remover,
1516 NamedPropertyEnumeratorCallback enumerator, 1562 NamedPropertyEnumeratorCallback enumerator,
1517 Handle<Value> data) { 1563 Handle<Value> data) {
1518 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 1564 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1519 if (IsDeadCheck(isolate, "v8::ObjectTemplate::SetNamedPropertyHandler()")) { 1565 if (IsDeadCheck(isolate, "v8::ObjectTemplate::SetNamedPropertyHandler()")) {
1520 return; 1566 return;
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
1674 Utils::OpenHandle(this)->set_internal_field_count(i::Smi::FromInt(value)); 1720 Utils::OpenHandle(this)->set_internal_field_count(i::Smi::FromInt(value));
1675 } 1721 }
1676 1722
1677 1723
1678 // --- S c r i p t D a t a --- 1724 // --- S c r i p t D a t a ---
1679 1725
1680 1726
1681 ScriptData* ScriptData::PreCompile(const char* input, int length) { 1727 ScriptData* ScriptData::PreCompile(const char* input, int length) {
1682 i::Utf8ToUtf16CharacterStream stream( 1728 i::Utf8ToUtf16CharacterStream stream(
1683 reinterpret_cast<const unsigned char*>(input), length); 1729 reinterpret_cast<const unsigned char*>(input), length);
1684 return i::PreParserApi::PreParse(&stream); 1730 return i::PreParserApi::PreParse(i::Isolate::Current(), &stream);
1685 } 1731 }
1686 1732
1687 1733
1688 ScriptData* ScriptData::PreCompile(v8::Handle<String> source) { 1734 ScriptData* ScriptData::PreCompile(v8::Handle<String> source) {
1689 i::Handle<i::String> str = Utils::OpenHandle(*source); 1735 i::Handle<i::String> str = Utils::OpenHandle(*source);
1736 i::Isolate* isolate = str->GetIsolate();
1690 if (str->IsExternalTwoByteString()) { 1737 if (str->IsExternalTwoByteString()) {
1691 i::ExternalTwoByteStringUtf16CharacterStream stream( 1738 i::ExternalTwoByteStringUtf16CharacterStream stream(
1692 i::Handle<i::ExternalTwoByteString>::cast(str), 0, str->length()); 1739 i::Handle<i::ExternalTwoByteString>::cast(str), 0, str->length());
1693 return i::PreParserApi::PreParse(&stream); 1740 return i::PreParserApi::PreParse(isolate, &stream);
1694 } else { 1741 } else {
1695 i::GenericStringUtf16CharacterStream stream(str, 0, str->length()); 1742 i::GenericStringUtf16CharacterStream stream(str, 0, str->length());
1696 return i::PreParserApi::PreParse(&stream); 1743 return i::PreParserApi::PreParse(isolate, &stream);
1697 } 1744 }
1698 } 1745 }
1699 1746
1700 1747
1701 ScriptData* ScriptData::New(const char* data, int length) { 1748 ScriptData* ScriptData::New(const char* data, int length) {
1702 // Return an empty ScriptData if the length is obviously invalid. 1749 // Return an empty ScriptData if the length is obviously invalid.
1703 if (length % sizeof(unsigned) != 0) { 1750 if (length % sizeof(unsigned) != 0) {
1704 return new i::ScriptDataImpl(); 1751 return new i::ScriptDataImpl();
1705 } 1752 }
1706 1753
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
1837 i::Handle<i::SharedFunctionInfo> 1884 i::Handle<i::SharedFunctionInfo>
1838 function_info(i::SharedFunctionInfo::cast(*obj), isolate); 1885 function_info(i::SharedFunctionInfo::cast(*obj), isolate);
1839 fun = isolate->factory()->NewFunctionFromSharedFunctionInfo( 1886 fun = isolate->factory()->NewFunctionFromSharedFunctionInfo(
1840 function_info, isolate->global_context()); 1887 function_info, isolate->global_context());
1841 } else { 1888 } else {
1842 fun = i::Handle<i::JSFunction>(i::JSFunction::cast(*obj), isolate); 1889 fun = i::Handle<i::JSFunction>(i::JSFunction::cast(*obj), isolate);
1843 } 1890 }
1844 EXCEPTION_PREAMBLE(isolate); 1891 EXCEPTION_PREAMBLE(isolate);
1845 i::Handle<i::Object> receiver( 1892 i::Handle<i::Object> receiver(
1846 isolate->context()->global_proxy(), isolate); 1893 isolate->context()->global_proxy(), isolate);
1847 i::Handle<i::Object> result = 1894 i::Handle<i::Object> result = i::Execution::Call(
1848 i::Execution::Call(fun, receiver, 0, NULL, &has_pending_exception); 1895 isolate, fun, receiver, 0, NULL, &has_pending_exception);
1849 EXCEPTION_BAILOUT_CHECK_DO_CALLBACK(isolate, Local<Value>()); 1896 EXCEPTION_BAILOUT_CHECK_DO_CALLBACK(isolate, Local<Value>());
1850 raw_result = *result; 1897 raw_result = *result;
1851 } 1898 }
1852 i::Handle<i::Object> result(raw_result, isolate); 1899 i::Handle<i::Object> result(raw_result, isolate);
1853 return Utils::ToLocal(result); 1900 return Utils::ToLocal(result);
1854 } 1901 }
1855 1902
1856 1903
1857 static i::Handle<i::SharedFunctionInfo> OpenScript(Script* script) { 1904 static i::Handle<i::SharedFunctionInfo> OpenScript(Script* script) {
1858 i::Handle<i::Object> obj = Utils::OpenHandle(script); 1905 i::Handle<i::Object> obj = Utils::OpenHandle(script);
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
2137 int argc, 2184 int argc,
2138 i::Handle<i::Object> argv[], 2185 i::Handle<i::Object> argv[],
2139 bool* has_pending_exception) { 2186 bool* has_pending_exception) {
2140 i::Isolate* isolate = i::Isolate::Current(); 2187 i::Isolate* isolate = i::Isolate::Current();
2141 i::Handle<i::String> fmt_str = 2188 i::Handle<i::String> fmt_str =
2142 isolate->factory()->InternalizeUtf8String(name); 2189 isolate->factory()->InternalizeUtf8String(name);
2143 i::Object* object_fun = 2190 i::Object* object_fun =
2144 isolate->js_builtins_object()->GetPropertyNoExceptionThrown(*fmt_str); 2191 isolate->js_builtins_object()->GetPropertyNoExceptionThrown(*fmt_str);
2145 i::Handle<i::JSFunction> fun = 2192 i::Handle<i::JSFunction> fun =
2146 i::Handle<i::JSFunction>(i::JSFunction::cast(object_fun)); 2193 i::Handle<i::JSFunction>(i::JSFunction::cast(object_fun));
2147 i::Handle<i::Object> value = 2194 i::Handle<i::Object> value = i::Execution::Call(
2148 i::Execution::Call(fun, recv, argc, argv, has_pending_exception); 2195 isolate, fun, recv, argc, argv, has_pending_exception);
2149 return value; 2196 return value;
2150 } 2197 }
2151 2198
2152 2199
2153 static i::Handle<i::Object> CallV8HeapFunction(const char* name, 2200 static i::Handle<i::Object> CallV8HeapFunction(const char* name,
2154 i::Handle<i::Object> data, 2201 i::Handle<i::Object> data,
2155 bool* has_pending_exception) { 2202 bool* has_pending_exception) {
2156 i::Handle<i::Object> argv[] = { data }; 2203 i::Handle<i::Object> argv[] = { data };
2157 return CallV8HeapFunction(name, 2204 return CallV8HeapFunction(name,
2158 i::Isolate::Current()->js_builtins_object(), 2205 i::Isolate::Current()->js_builtins_object(),
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
2280 // --- S t a c k T r a c e --- 2327 // --- S t a c k T r a c e ---
2281 2328
2282 Local<StackFrame> StackTrace::GetFrame(uint32_t index) const { 2329 Local<StackFrame> StackTrace::GetFrame(uint32_t index) const {
2283 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 2330 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2284 if (IsDeadCheck(isolate, "v8::StackTrace::GetFrame()")) { 2331 if (IsDeadCheck(isolate, "v8::StackTrace::GetFrame()")) {
2285 return Local<StackFrame>(); 2332 return Local<StackFrame>();
2286 } 2333 }
2287 ENTER_V8(isolate); 2334 ENTER_V8(isolate);
2288 HandleScope scope(reinterpret_cast<Isolate*>(isolate)); 2335 HandleScope scope(reinterpret_cast<Isolate*>(isolate));
2289 i::Handle<i::JSArray> self = Utils::OpenHandle(this); 2336 i::Handle<i::JSArray> self = Utils::OpenHandle(this);
2290 i::Object* raw_object = self->GetElementNoExceptionThrown(index); 2337 i::Object* raw_object = self->GetElementNoExceptionThrown(isolate, index);
2291 i::Handle<i::JSObject> obj(i::JSObject::cast(raw_object)); 2338 i::Handle<i::JSObject> obj(i::JSObject::cast(raw_object));
2292 return scope.Close(Utils::StackFrameToLocal(obj)); 2339 return scope.Close(Utils::StackFrameToLocal(obj));
2293 } 2340 }
2294 2341
2295 2342
2296 int StackTrace::GetFrameCount() const { 2343 int StackTrace::GetFrameCount() const {
2297 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 2344 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2298 if (IsDeadCheck(isolate, "v8::StackTrace::GetFrameCount()")) return -1; 2345 if (IsDeadCheck(isolate, "v8::StackTrace::GetFrameCount()")) return -1;
2299 ENTER_V8(isolate); 2346 ENTER_V8(isolate);
2300 return i::Smi::cast(Utils::OpenHandle(this)->length())->value(); 2347 return i::Smi::cast(Utils::OpenHandle(this)->length())->value();
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
2731 if (obj->IsString()) { 2778 if (obj->IsString()) {
2732 str = obj; 2779 str = obj;
2733 } else { 2780 } else {
2734 i::Isolate* isolate = i::Isolate::Current(); 2781 i::Isolate* isolate = i::Isolate::Current();
2735 if (IsDeadCheck(isolate, "v8::Value::ToString()")) { 2782 if (IsDeadCheck(isolate, "v8::Value::ToString()")) {
2736 return Local<String>(); 2783 return Local<String>();
2737 } 2784 }
2738 LOG_API(isolate, "ToString"); 2785 LOG_API(isolate, "ToString");
2739 ENTER_V8(isolate); 2786 ENTER_V8(isolate);
2740 EXCEPTION_PREAMBLE(isolate); 2787 EXCEPTION_PREAMBLE(isolate);
2741 str = i::Execution::ToString(obj, &has_pending_exception); 2788 str = i::Execution::ToString(isolate, obj, &has_pending_exception);
2742 EXCEPTION_BAILOUT_CHECK(isolate, Local<String>()); 2789 EXCEPTION_BAILOUT_CHECK(isolate, Local<String>());
2743 } 2790 }
2744 return ToApiHandle<String>(str); 2791 return ToApiHandle<String>(str);
2745 } 2792 }
2746 2793
2747 2794
2748 Local<String> Value::ToDetailString() const { 2795 Local<String> Value::ToDetailString() const {
2749 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2796 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2750 i::Handle<i::Object> str; 2797 i::Handle<i::Object> str;
2751 if (obj->IsString()) { 2798 if (obj->IsString()) {
2752 str = obj; 2799 str = obj;
2753 } else { 2800 } else {
2754 i::Isolate* isolate = i::Isolate::Current(); 2801 i::Isolate* isolate = i::Isolate::Current();
2755 if (IsDeadCheck(isolate, "v8::Value::ToDetailString()")) { 2802 if (IsDeadCheck(isolate, "v8::Value::ToDetailString()")) {
2756 return Local<String>(); 2803 return Local<String>();
2757 } 2804 }
2758 LOG_API(isolate, "ToDetailString"); 2805 LOG_API(isolate, "ToDetailString");
2759 ENTER_V8(isolate); 2806 ENTER_V8(isolate);
2760 EXCEPTION_PREAMBLE(isolate); 2807 EXCEPTION_PREAMBLE(isolate);
2761 str = i::Execution::ToDetailString(obj, &has_pending_exception); 2808 str = i::Execution::ToDetailString(isolate, obj, &has_pending_exception);
2762 EXCEPTION_BAILOUT_CHECK(isolate, Local<String>()); 2809 EXCEPTION_BAILOUT_CHECK(isolate, Local<String>());
2763 } 2810 }
2764 return ToApiHandle<String>(str); 2811 return ToApiHandle<String>(str);
2765 } 2812 }
2766 2813
2767 2814
2768 Local<v8::Object> Value::ToObject() const { 2815 Local<v8::Object> Value::ToObject() const {
2769 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2816 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2770 i::Handle<i::Object> val; 2817 i::Handle<i::Object> val;
2771 if (obj->IsJSObject()) { 2818 if (obj->IsJSObject()) {
2772 val = obj; 2819 val = obj;
2773 } else { 2820 } else {
2774 i::Isolate* isolate = i::Isolate::Current(); 2821 i::Isolate* isolate = i::Isolate::Current();
2775 if (IsDeadCheck(isolate, "v8::Value::ToObject()")) { 2822 if (IsDeadCheck(isolate, "v8::Value::ToObject()")) {
2776 return Local<v8::Object>(); 2823 return Local<v8::Object>();
2777 } 2824 }
2778 LOG_API(isolate, "ToObject"); 2825 LOG_API(isolate, "ToObject");
2779 ENTER_V8(isolate); 2826 ENTER_V8(isolate);
2780 EXCEPTION_PREAMBLE(isolate); 2827 EXCEPTION_PREAMBLE(isolate);
2781 val = i::Execution::ToObject(obj, &has_pending_exception); 2828 val = i::Execution::ToObject(isolate, obj, &has_pending_exception);
2782 EXCEPTION_BAILOUT_CHECK(isolate, Local<v8::Object>()); 2829 EXCEPTION_BAILOUT_CHECK(isolate, Local<v8::Object>());
2783 } 2830 }
2784 return ToApiHandle<Object>(val); 2831 return ToApiHandle<Object>(val);
2785 } 2832 }
2786 2833
2787 2834
2788 Local<Boolean> Value::ToBoolean() const { 2835 Local<Boolean> Value::ToBoolean() const {
2789 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2836 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2790 if (obj->IsBoolean()) { 2837 if (obj->IsBoolean()) {
2791 return ToApiHandle<Boolean>(obj); 2838 return ToApiHandle<Boolean>(obj);
(...skipping 17 matching lines...) Expand all
2809 if (obj->IsNumber()) { 2856 if (obj->IsNumber()) {
2810 num = obj; 2857 num = obj;
2811 } else { 2858 } else {
2812 i::Isolate* isolate = i::Isolate::Current(); 2859 i::Isolate* isolate = i::Isolate::Current();
2813 if (IsDeadCheck(isolate, "v8::Value::ToNumber()")) { 2860 if (IsDeadCheck(isolate, "v8::Value::ToNumber()")) {
2814 return Local<Number>(); 2861 return Local<Number>();
2815 } 2862 }
2816 LOG_API(isolate, "ToNumber"); 2863 LOG_API(isolate, "ToNumber");
2817 ENTER_V8(isolate); 2864 ENTER_V8(isolate);
2818 EXCEPTION_PREAMBLE(isolate); 2865 EXCEPTION_PREAMBLE(isolate);
2819 num = i::Execution::ToNumber(obj, &has_pending_exception); 2866 num = i::Execution::ToNumber(isolate, obj, &has_pending_exception);
2820 EXCEPTION_BAILOUT_CHECK(isolate, Local<Number>()); 2867 EXCEPTION_BAILOUT_CHECK(isolate, Local<Number>());
2821 } 2868 }
2822 return ToApiHandle<Number>(num); 2869 return ToApiHandle<Number>(num);
2823 } 2870 }
2824 2871
2825 2872
2826 Local<Integer> Value::ToInteger() const { 2873 Local<Integer> Value::ToInteger() const {
2827 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2874 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2828 i::Handle<i::Object> num; 2875 i::Handle<i::Object> num;
2829 if (obj->IsSmi()) { 2876 if (obj->IsSmi()) {
2830 num = obj; 2877 num = obj;
2831 } else { 2878 } else {
2832 i::Isolate* isolate = i::Isolate::Current(); 2879 i::Isolate* isolate = i::Isolate::Current();
2833 if (IsDeadCheck(isolate, "v8::Value::ToInteger()")) return Local<Integer>(); 2880 if (IsDeadCheck(isolate, "v8::Value::ToInteger()")) return Local<Integer>();
2834 LOG_API(isolate, "ToInteger"); 2881 LOG_API(isolate, "ToInteger");
2835 ENTER_V8(isolate); 2882 ENTER_V8(isolate);
2836 EXCEPTION_PREAMBLE(isolate); 2883 EXCEPTION_PREAMBLE(isolate);
2837 num = i::Execution::ToInteger(obj, &has_pending_exception); 2884 num = i::Execution::ToInteger(isolate, obj, &has_pending_exception);
2838 EXCEPTION_BAILOUT_CHECK(isolate, Local<Integer>()); 2885 EXCEPTION_BAILOUT_CHECK(isolate, Local<Integer>());
2839 } 2886 }
2840 return ToApiHandle<Integer>(num); 2887 return ToApiHandle<Integer>(num);
2841 } 2888 }
2842 2889
2843 2890
2844 void i::Internals::CheckInitializedImpl(v8::Isolate* external_isolate) { 2891 void i::Internals::CheckInitializedImpl(v8::Isolate* external_isolate) {
2845 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(external_isolate); 2892 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(external_isolate);
2846 ApiCheck(isolate != NULL && isolate->IsInitialized() && !i::V8::IsDead(), 2893 ApiCheck(isolate != NULL && isolate->IsInitialized() && !isolate->IsDead(),
2847 "v8::internal::Internals::CheckInitialized()", 2894 "v8::internal::Internals::CheckInitialized()",
2848 "Isolate is not initialized or V8 has died"); 2895 "Isolate is not initialized or V8 has died");
2849 } 2896 }
2850 2897
2851 2898
2852 void External::CheckCast(v8::Value* that) { 2899 void External::CheckCast(v8::Value* that) {
2853 if (IsDeadCheck(i::Isolate::Current(), "v8::External::Cast()")) return; 2900 if (IsDeadCheck(i::Isolate::Current(), "v8::External::Cast()")) return;
2854 ApiCheck(Utils::OpenHandle(that)->IsExternal(), 2901 ApiCheck(Utils::OpenHandle(that)->IsExternal(),
2855 "v8::External::Cast()", 2902 "v8::External::Cast()",
2856 "Could not convert to external"); 2903 "Could not convert to external");
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
3047 if (obj->IsNumber()) { 3094 if (obj->IsNumber()) {
3048 num = obj; 3095 num = obj;
3049 } else { 3096 } else {
3050 i::Isolate* isolate = i::Isolate::Current(); 3097 i::Isolate* isolate = i::Isolate::Current();
3051 if (IsDeadCheck(isolate, "v8::Value::NumberValue()")) { 3098 if (IsDeadCheck(isolate, "v8::Value::NumberValue()")) {
3052 return i::OS::nan_value(); 3099 return i::OS::nan_value();
3053 } 3100 }
3054 LOG_API(isolate, "NumberValue"); 3101 LOG_API(isolate, "NumberValue");
3055 ENTER_V8(isolate); 3102 ENTER_V8(isolate);
3056 EXCEPTION_PREAMBLE(isolate); 3103 EXCEPTION_PREAMBLE(isolate);
3057 num = i::Execution::ToNumber(obj, &has_pending_exception); 3104 num = i::Execution::ToNumber(isolate, obj, &has_pending_exception);
3058 EXCEPTION_BAILOUT_CHECK(isolate, i::OS::nan_value()); 3105 EXCEPTION_BAILOUT_CHECK(isolate, i::OS::nan_value());
3059 } 3106 }
3060 return num->Number(); 3107 return num->Number();
3061 } 3108 }
3062 3109
3063 3110
3064 int64_t Value::IntegerValue() const { 3111 int64_t Value::IntegerValue() const {
3065 i::Handle<i::Object> obj = Utils::OpenHandle(this); 3112 i::Handle<i::Object> obj = Utils::OpenHandle(this);
3066 i::Handle<i::Object> num; 3113 i::Handle<i::Object> num;
3067 if (obj->IsNumber()) { 3114 if (obj->IsNumber()) {
3068 num = obj; 3115 num = obj;
3069 } else { 3116 } else {
3070 i::Isolate* isolate = i::Isolate::Current(); 3117 i::Isolate* isolate = i::Isolate::Current();
3071 if (IsDeadCheck(isolate, "v8::Value::IntegerValue()")) return 0; 3118 if (IsDeadCheck(isolate, "v8::Value::IntegerValue()")) return 0;
3072 LOG_API(isolate, "IntegerValue"); 3119 LOG_API(isolate, "IntegerValue");
3073 ENTER_V8(isolate); 3120 ENTER_V8(isolate);
3074 EXCEPTION_PREAMBLE(isolate); 3121 EXCEPTION_PREAMBLE(isolate);
3075 num = i::Execution::ToInteger(obj, &has_pending_exception); 3122 num = i::Execution::ToInteger(isolate, obj, &has_pending_exception);
3076 EXCEPTION_BAILOUT_CHECK(isolate, 0); 3123 EXCEPTION_BAILOUT_CHECK(isolate, 0);
3077 } 3124 }
3078 if (num->IsSmi()) { 3125 if (num->IsSmi()) {
3079 return i::Smi::cast(*num)->value(); 3126 return i::Smi::cast(*num)->value();
3080 } else { 3127 } else {
3081 return static_cast<int64_t>(num->Number()); 3128 return static_cast<int64_t>(num->Number());
3082 } 3129 }
3083 } 3130 }
3084 3131
3085 3132
3086 Local<Int32> Value::ToInt32() const { 3133 Local<Int32> Value::ToInt32() const {
3087 i::Handle<i::Object> obj = Utils::OpenHandle(this); 3134 i::Handle<i::Object> obj = Utils::OpenHandle(this);
3088 i::Handle<i::Object> num; 3135 i::Handle<i::Object> num;
3089 if (obj->IsSmi()) { 3136 if (obj->IsSmi()) {
3090 num = obj; 3137 num = obj;
3091 } else { 3138 } else {
3092 i::Isolate* isolate = i::Isolate::Current(); 3139 i::Isolate* isolate = i::Isolate::Current();
3093 if (IsDeadCheck(isolate, "v8::Value::ToInt32()")) return Local<Int32>(); 3140 if (IsDeadCheck(isolate, "v8::Value::ToInt32()")) return Local<Int32>();
3094 LOG_API(isolate, "ToInt32"); 3141 LOG_API(isolate, "ToInt32");
3095 ENTER_V8(isolate); 3142 ENTER_V8(isolate);
3096 EXCEPTION_PREAMBLE(isolate); 3143 EXCEPTION_PREAMBLE(isolate);
3097 num = i::Execution::ToInt32(obj, &has_pending_exception); 3144 num = i::Execution::ToInt32(isolate, obj, &has_pending_exception);
3098 EXCEPTION_BAILOUT_CHECK(isolate, Local<Int32>()); 3145 EXCEPTION_BAILOUT_CHECK(isolate, Local<Int32>());
3099 } 3146 }
3100 return ToApiHandle<Int32>(num); 3147 return ToApiHandle<Int32>(num);
3101 } 3148 }
3102 3149
3103 3150
3104 Local<Uint32> Value::ToUint32() const { 3151 Local<Uint32> Value::ToUint32() const {
3105 i::Handle<i::Object> obj = Utils::OpenHandle(this); 3152 i::Handle<i::Object> obj = Utils::OpenHandle(this);
3106 i::Handle<i::Object> num; 3153 i::Handle<i::Object> num;
3107 if (obj->IsSmi()) { 3154 if (obj->IsSmi()) {
3108 num = obj; 3155 num = obj;
3109 } else { 3156 } else {
3110 i::Isolate* isolate = i::Isolate::Current(); 3157 i::Isolate* isolate = i::Isolate::Current();
3111 if (IsDeadCheck(isolate, "v8::Value::ToUint32()")) return Local<Uint32>(); 3158 if (IsDeadCheck(isolate, "v8::Value::ToUint32()")) return Local<Uint32>();
3112 LOG_API(isolate, "ToUInt32"); 3159 LOG_API(isolate, "ToUInt32");
3113 ENTER_V8(isolate); 3160 ENTER_V8(isolate);
3114 EXCEPTION_PREAMBLE(isolate); 3161 EXCEPTION_PREAMBLE(isolate);
3115 num = i::Execution::ToUint32(obj, &has_pending_exception); 3162 num = i::Execution::ToUint32(isolate, obj, &has_pending_exception);
3116 EXCEPTION_BAILOUT_CHECK(isolate, Local<Uint32>()); 3163 EXCEPTION_BAILOUT_CHECK(isolate, Local<Uint32>());
3117 } 3164 }
3118 return ToApiHandle<Uint32>(num); 3165 return ToApiHandle<Uint32>(num);
3119 } 3166 }
3120 3167
3121 3168
3122 Local<Uint32> Value::ToArrayIndex() const { 3169 Local<Uint32> Value::ToArrayIndex() const {
3123 i::Handle<i::Object> obj = Utils::OpenHandle(this); 3170 i::Handle<i::Object> obj = Utils::OpenHandle(this);
3124 if (obj->IsSmi()) { 3171 if (obj->IsSmi()) {
3125 if (i::Smi::cast(*obj)->value() >= 0) return Utils::Uint32ToLocal(obj); 3172 if (i::Smi::cast(*obj)->value() >= 0) return Utils::Uint32ToLocal(obj);
3126 return Local<Uint32>(); 3173 return Local<Uint32>();
3127 } 3174 }
3128 i::Isolate* isolate = i::Isolate::Current(); 3175 i::Isolate* isolate = i::Isolate::Current();
3129 if (IsDeadCheck(isolate, "v8::Value::ToArrayIndex()")) return Local<Uint32>(); 3176 if (IsDeadCheck(isolate, "v8::Value::ToArrayIndex()")) return Local<Uint32>();
3130 LOG_API(isolate, "ToArrayIndex"); 3177 LOG_API(isolate, "ToArrayIndex");
3131 ENTER_V8(isolate); 3178 ENTER_V8(isolate);
3132 EXCEPTION_PREAMBLE(isolate); 3179 EXCEPTION_PREAMBLE(isolate);
3133 i::Handle<i::Object> string_obj = 3180 i::Handle<i::Object> string_obj =
3134 i::Execution::ToString(obj, &has_pending_exception); 3181 i::Execution::ToString(isolate, obj, &has_pending_exception);
3135 EXCEPTION_BAILOUT_CHECK(isolate, Local<Uint32>()); 3182 EXCEPTION_BAILOUT_CHECK(isolate, Local<Uint32>());
3136 i::Handle<i::String> str = i::Handle<i::String>::cast(string_obj); 3183 i::Handle<i::String> str = i::Handle<i::String>::cast(string_obj);
3137 uint32_t index; 3184 uint32_t index;
3138 if (str->AsArrayIndex(&index)) { 3185 if (str->AsArrayIndex(&index)) {
3139 i::Handle<i::Object> value; 3186 i::Handle<i::Object> value;
3140 if (index <= static_cast<uint32_t>(i::Smi::kMaxValue)) { 3187 if (index <= static_cast<uint32_t>(i::Smi::kMaxValue)) {
3141 value = i::Handle<i::Object>(i::Smi::FromInt(index), isolate); 3188 value = i::Handle<i::Object>(i::Smi::FromInt(index), isolate);
3142 } else { 3189 } else {
3143 value = isolate->factory()->NewNumber(index); 3190 value = isolate->factory()->NewNumber(index);
3144 } 3191 }
3145 return Utils::Uint32ToLocal(value); 3192 return Utils::Uint32ToLocal(value);
3146 } 3193 }
3147 return Local<Uint32>(); 3194 return Local<Uint32>();
3148 } 3195 }
3149 3196
3150 3197
3151 int32_t Value::Int32Value() const { 3198 int32_t Value::Int32Value() const {
3152 i::Handle<i::Object> obj = Utils::OpenHandle(this); 3199 i::Handle<i::Object> obj = Utils::OpenHandle(this);
3153 if (obj->IsSmi()) { 3200 if (obj->IsSmi()) {
3154 return i::Smi::cast(*obj)->value(); 3201 return i::Smi::cast(*obj)->value();
3155 } else { 3202 } else {
3156 i::Isolate* isolate = i::Isolate::Current(); 3203 i::Isolate* isolate = i::Isolate::Current();
3157 if (IsDeadCheck(isolate, "v8::Value::Int32Value()")) return 0; 3204 if (IsDeadCheck(isolate, "v8::Value::Int32Value()")) return 0;
3158 LOG_API(isolate, "Int32Value (slow)"); 3205 LOG_API(isolate, "Int32Value (slow)");
3159 ENTER_V8(isolate); 3206 ENTER_V8(isolate);
3160 EXCEPTION_PREAMBLE(isolate); 3207 EXCEPTION_PREAMBLE(isolate);
3161 i::Handle<i::Object> num = 3208 i::Handle<i::Object> num =
3162 i::Execution::ToInt32(obj, &has_pending_exception); 3209 i::Execution::ToInt32(isolate, obj, &has_pending_exception);
3163 EXCEPTION_BAILOUT_CHECK(isolate, 0); 3210 EXCEPTION_BAILOUT_CHECK(isolate, 0);
3164 if (num->IsSmi()) { 3211 if (num->IsSmi()) {
3165 return i::Smi::cast(*num)->value(); 3212 return i::Smi::cast(*num)->value();
3166 } else { 3213 } else {
3167 return static_cast<int32_t>(num->Number()); 3214 return static_cast<int32_t>(num->Number());
3168 } 3215 }
3169 } 3216 }
3170 } 3217 }
3171 3218
3172 3219
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
3233 i::Handle<i::Object> obj = Utils::OpenHandle(this); 3280 i::Handle<i::Object> obj = Utils::OpenHandle(this);
3234 if (obj->IsSmi()) { 3281 if (obj->IsSmi()) {
3235 return i::Smi::cast(*obj)->value(); 3282 return i::Smi::cast(*obj)->value();
3236 } else { 3283 } else {
3237 i::Isolate* isolate = i::Isolate::Current(); 3284 i::Isolate* isolate = i::Isolate::Current();
3238 if (IsDeadCheck(isolate, "v8::Value::Uint32Value()")) return 0; 3285 if (IsDeadCheck(isolate, "v8::Value::Uint32Value()")) return 0;
3239 LOG_API(isolate, "Uint32Value"); 3286 LOG_API(isolate, "Uint32Value");
3240 ENTER_V8(isolate); 3287 ENTER_V8(isolate);
3241 EXCEPTION_PREAMBLE(isolate); 3288 EXCEPTION_PREAMBLE(isolate);
3242 i::Handle<i::Object> num = 3289 i::Handle<i::Object> num =
3243 i::Execution::ToUint32(obj, &has_pending_exception); 3290 i::Execution::ToUint32(isolate, obj, &has_pending_exception);
3244 EXCEPTION_BAILOUT_CHECK(isolate, 0); 3291 EXCEPTION_BAILOUT_CHECK(isolate, 0);
3245 if (num->IsSmi()) { 3292 if (num->IsSmi()) {
3246 return i::Smi::cast(*num)->value(); 3293 return i::Smi::cast(*num)->value();
3247 } else { 3294 } else {
3248 return static_cast<uint32_t>(num->Number()); 3295 return static_cast<uint32_t>(num->Number());
3249 } 3296 }
3250 } 3297 }
3251 } 3298 }
3252 3299
3253 3300
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
3353 return Utils::ToLocal(result); 3400 return Utils::ToLocal(result);
3354 } 3401 }
3355 3402
3356 3403
3357 Local<Value> v8::Object::Get(uint32_t index) { 3404 Local<Value> v8::Object::Get(uint32_t index) {
3358 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 3405 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3359 ON_BAILOUT(isolate, "v8::Object::Get()", return Local<v8::Value>()); 3406 ON_BAILOUT(isolate, "v8::Object::Get()", return Local<v8::Value>());
3360 ENTER_V8(isolate); 3407 ENTER_V8(isolate);
3361 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 3408 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
3362 EXCEPTION_PREAMBLE(isolate); 3409 EXCEPTION_PREAMBLE(isolate);
3363 i::Handle<i::Object> result = i::Object::GetElement(self, index); 3410 i::Handle<i::Object> result = i::Object::GetElement(isolate, self, index);
3364 has_pending_exception = result.is_null(); 3411 has_pending_exception = result.is_null();
3365 EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>()); 3412 EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>());
3366 return Utils::ToLocal(result); 3413 return Utils::ToLocal(result);
3367 } 3414 }
3368 3415
3369 3416
3370 PropertyAttribute v8::Object::GetPropertyAttributes(v8::Handle<Value> key) { 3417 PropertyAttribute v8::Object::GetPropertyAttributes(v8::Handle<Value> key) {
3371 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 3418 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3372 ON_BAILOUT(isolate, "v8::Object::GetPropertyAttribute()", 3419 ON_BAILOUT(isolate, "v8::Object::GetPropertyAttribute()",
3373 return static_cast<PropertyAttribute>(NONE)); 3420 return static_cast<PropertyAttribute>(NONE));
3374 ENTER_V8(isolate); 3421 ENTER_V8(isolate);
3375 i::HandleScope scope(isolate); 3422 i::HandleScope scope(isolate);
3376 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 3423 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
3377 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); 3424 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key);
3378 if (!key_obj->IsName()) { 3425 if (!key_obj->IsName()) {
3379 EXCEPTION_PREAMBLE(isolate); 3426 EXCEPTION_PREAMBLE(isolate);
3380 key_obj = i::Execution::ToString(key_obj, &has_pending_exception); 3427 key_obj = i::Execution::ToString(isolate, key_obj, &has_pending_exception);
3381 EXCEPTION_BAILOUT_CHECK(isolate, static_cast<PropertyAttribute>(NONE)); 3428 EXCEPTION_BAILOUT_CHECK(isolate, static_cast<PropertyAttribute>(NONE));
3382 } 3429 }
3383 i::Handle<i::Name> key_name = i::Handle<i::Name>::cast(key_obj); 3430 i::Handle<i::Name> key_name = i::Handle<i::Name>::cast(key_obj);
3384 PropertyAttributes result = self->GetPropertyAttribute(*key_name); 3431 PropertyAttributes result = self->GetPropertyAttribute(*key_name);
3385 if (result == ABSENT) return static_cast<PropertyAttribute>(NONE); 3432 if (result == ABSENT) return static_cast<PropertyAttribute>(NONE);
3386 return static_cast<PropertyAttribute>(result); 3433 return static_cast<PropertyAttribute>(result);
3387 } 3434 }
3388 3435
3389 3436
3390 Local<Value> v8::Object::GetPrototype() { 3437 Local<Value> v8::Object::GetPrototype() {
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
3628 AccessorGetterCallback getter, 3675 AccessorGetterCallback getter,
3629 AccessorSetterCallback setter, 3676 AccessorSetterCallback setter,
3630 v8::Handle<Value> data, 3677 v8::Handle<Value> data,
3631 AccessControl settings, 3678 AccessControl settings,
3632 PropertyAttribute attributes) { 3679 PropertyAttribute attributes) {
3633 return ObjectSetAccessor( 3680 return ObjectSetAccessor(
3634 this, name, getter, setter, data, settings, attributes); 3681 this, name, getter, setter, data, settings, attributes);
3635 } 3682 }
3636 3683
3637 3684
3638 bool Object::SetAccessor(Handle<String> name, 3685 bool Object::SetDeclaredAccessor(Local<String> name,
3639 Handle<DeclaredAccessorDescriptor> descriptor, 3686 Local<DeclaredAccessorDescriptor> descriptor,
3640 AccessControl settings, 3687 PropertyAttribute attributes,
3641 PropertyAttribute attributes) { 3688 AccessControl settings) {
3642 void* null = NULL; 3689 void* null = NULL;
3643 return ObjectSetAccessor( 3690 return ObjectSetAccessor(
3644 this, name, descriptor, null, null, settings, attributes); 3691 this, name, descriptor, null, null, settings, attributes);
3645 } 3692 }
3646 3693
3647 3694
3648 bool v8::Object::HasOwnProperty(Handle<String> key) { 3695 bool v8::Object::HasOwnProperty(Handle<String> key) {
3649 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 3696 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3650 ON_BAILOUT(isolate, "v8::Object::HasOwnProperty()", 3697 ON_BAILOUT(isolate, "v8::Object::HasOwnProperty()",
3651 return false); 3698 return false);
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
4072 } 4119 }
4073 4120
4074 4121
4075 bool v8::Object::IsCallable() { 4122 bool v8::Object::IsCallable() {
4076 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 4123 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
4077 ON_BAILOUT(isolate, "v8::Object::IsCallable()", return false); 4124 ON_BAILOUT(isolate, "v8::Object::IsCallable()", return false);
4078 ENTER_V8(isolate); 4125 ENTER_V8(isolate);
4079 i::HandleScope scope(isolate); 4126 i::HandleScope scope(isolate);
4080 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); 4127 i::Handle<i::JSObject> obj = Utils::OpenHandle(this);
4081 if (obj->IsJSFunction()) return true; 4128 if (obj->IsJSFunction()) return true;
4082 return i::Execution::GetFunctionDelegate(obj)->IsJSFunction(); 4129 return i::Execution::GetFunctionDelegate(isolate, obj)->IsJSFunction();
4083 } 4130 }
4084 4131
4085 4132
4086 Local<v8::Value> Object::CallAsFunction(v8::Handle<v8::Object> recv, 4133 Local<v8::Value> Object::CallAsFunction(v8::Handle<v8::Object> recv,
4087 int argc, 4134 int argc,
4088 v8::Handle<v8::Value> argv[]) { 4135 v8::Handle<v8::Value> argv[]) {
4089 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 4136 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
4090 ON_BAILOUT(isolate, "v8::Object::CallAsFunction()", 4137 ON_BAILOUT(isolate, "v8::Object::CallAsFunction()",
4091 return Local<v8::Value>()); 4138 return Local<v8::Value>());
4092 LOG_API(isolate, "Object::CallAsFunction"); 4139 LOG_API(isolate, "Object::CallAsFunction");
4093 ENTER_V8(isolate); 4140 ENTER_V8(isolate);
4094 i::Logger::TimerEventScope timer_scope( 4141 i::Logger::TimerEventScope timer_scope(
4095 isolate, i::Logger::TimerEventScope::v8_execute); 4142 isolate, i::Logger::TimerEventScope::v8_execute);
4096 i::HandleScope scope(isolate); 4143 i::HandleScope scope(isolate);
4097 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); 4144 i::Handle<i::JSObject> obj = Utils::OpenHandle(this);
4098 i::Handle<i::Object> recv_obj = Utils::OpenHandle(*recv); 4145 i::Handle<i::Object> recv_obj = Utils::OpenHandle(*recv);
4099 STATIC_ASSERT(sizeof(v8::Handle<v8::Value>) == sizeof(i::Object**)); 4146 STATIC_ASSERT(sizeof(v8::Handle<v8::Value>) == sizeof(i::Object**));
4100 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); 4147 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv);
4101 i::Handle<i::JSFunction> fun = i::Handle<i::JSFunction>(); 4148 i::Handle<i::JSFunction> fun = i::Handle<i::JSFunction>();
4102 if (obj->IsJSFunction()) { 4149 if (obj->IsJSFunction()) {
4103 fun = i::Handle<i::JSFunction>::cast(obj); 4150 fun = i::Handle<i::JSFunction>::cast(obj);
4104 } else { 4151 } else {
4105 EXCEPTION_PREAMBLE(isolate); 4152 EXCEPTION_PREAMBLE(isolate);
4106 i::Handle<i::Object> delegate = 4153 i::Handle<i::Object> delegate = i::Execution::TryGetFunctionDelegate(
4107 i::Execution::TryGetFunctionDelegate(obj, &has_pending_exception); 4154 isolate, obj, &has_pending_exception);
4108 EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>()); 4155 EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>());
4109 fun = i::Handle<i::JSFunction>::cast(delegate); 4156 fun = i::Handle<i::JSFunction>::cast(delegate);
4110 recv_obj = obj; 4157 recv_obj = obj;
4111 } 4158 }
4112 EXCEPTION_PREAMBLE(isolate); 4159 EXCEPTION_PREAMBLE(isolate);
4113 i::Handle<i::Object> returned = 4160 i::Handle<i::Object> returned = i::Execution::Call(
4114 i::Execution::Call(fun, recv_obj, argc, args, &has_pending_exception); 4161 isolate, fun, recv_obj, argc, args, &has_pending_exception);
4115 EXCEPTION_BAILOUT_CHECK_DO_CALLBACK(isolate, Local<Value>()); 4162 EXCEPTION_BAILOUT_CHECK_DO_CALLBACK(isolate, Local<Value>());
4116 return Utils::ToLocal(scope.CloseAndEscape(returned)); 4163 return Utils::ToLocal(scope.CloseAndEscape(returned));
4117 } 4164 }
4118 4165
4119 4166
4120 Local<v8::Value> Object::CallAsConstructor(int argc, 4167 Local<v8::Value> Object::CallAsConstructor(int argc,
4121 v8::Handle<v8::Value> argv[]) { 4168 v8::Handle<v8::Value> argv[]) {
4122 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 4169 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
4123 ON_BAILOUT(isolate, "v8::Object::CallAsConstructor()", 4170 ON_BAILOUT(isolate, "v8::Object::CallAsConstructor()",
4124 return Local<v8::Object>()); 4171 return Local<v8::Object>());
4125 LOG_API(isolate, "Object::CallAsConstructor"); 4172 LOG_API(isolate, "Object::CallAsConstructor");
4126 ENTER_V8(isolate); 4173 ENTER_V8(isolate);
4127 i::Logger::TimerEventScope timer_scope( 4174 i::Logger::TimerEventScope timer_scope(
4128 isolate, i::Logger::TimerEventScope::v8_execute); 4175 isolate, i::Logger::TimerEventScope::v8_execute);
4129 i::HandleScope scope(isolate); 4176 i::HandleScope scope(isolate);
4130 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); 4177 i::Handle<i::JSObject> obj = Utils::OpenHandle(this);
4131 STATIC_ASSERT(sizeof(v8::Handle<v8::Value>) == sizeof(i::Object**)); 4178 STATIC_ASSERT(sizeof(v8::Handle<v8::Value>) == sizeof(i::Object**));
4132 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); 4179 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv);
4133 if (obj->IsJSFunction()) { 4180 if (obj->IsJSFunction()) {
4134 i::Handle<i::JSFunction> fun = i::Handle<i::JSFunction>::cast(obj); 4181 i::Handle<i::JSFunction> fun = i::Handle<i::JSFunction>::cast(obj);
4135 EXCEPTION_PREAMBLE(isolate); 4182 EXCEPTION_PREAMBLE(isolate);
4136 i::Handle<i::Object> returned = 4183 i::Handle<i::Object> returned =
4137 i::Execution::New(fun, argc, args, &has_pending_exception); 4184 i::Execution::New(fun, argc, args, &has_pending_exception);
4138 EXCEPTION_BAILOUT_CHECK_DO_CALLBACK(isolate, Local<v8::Object>()); 4185 EXCEPTION_BAILOUT_CHECK_DO_CALLBACK(isolate, Local<v8::Object>());
4139 return Utils::ToLocal(scope.CloseAndEscape( 4186 return Utils::ToLocal(scope.CloseAndEscape(
4140 i::Handle<i::JSObject>::cast(returned))); 4187 i::Handle<i::JSObject>::cast(returned)));
4141 } 4188 }
4142 EXCEPTION_PREAMBLE(isolate); 4189 EXCEPTION_PREAMBLE(isolate);
4143 i::Handle<i::Object> delegate = 4190 i::Handle<i::Object> delegate = i::Execution::TryGetConstructorDelegate(
4144 i::Execution::TryGetConstructorDelegate(obj, &has_pending_exception); 4191 isolate, obj, &has_pending_exception);
4145 EXCEPTION_BAILOUT_CHECK(isolate, Local<v8::Object>()); 4192 EXCEPTION_BAILOUT_CHECK(isolate, Local<v8::Object>());
4146 if (!delegate->IsUndefined()) { 4193 if (!delegate->IsUndefined()) {
4147 i::Handle<i::JSFunction> fun = i::Handle<i::JSFunction>::cast(delegate); 4194 i::Handle<i::JSFunction> fun = i::Handle<i::JSFunction>::cast(delegate);
4148 EXCEPTION_PREAMBLE(isolate); 4195 EXCEPTION_PREAMBLE(isolate);
4149 i::Handle<i::Object> returned = 4196 i::Handle<i::Object> returned = i::Execution::Call(
4150 i::Execution::Call(fun, obj, argc, args, &has_pending_exception); 4197 isolate, fun, obj, argc, args, &has_pending_exception);
4151 EXCEPTION_BAILOUT_CHECK_DO_CALLBACK(isolate, Local<v8::Object>()); 4198 EXCEPTION_BAILOUT_CHECK_DO_CALLBACK(isolate, Local<v8::Object>());
4152 ASSERT(!delegate->IsUndefined()); 4199 ASSERT(!delegate->IsUndefined());
4153 return Utils::ToLocal(scope.CloseAndEscape(returned)); 4200 return Utils::ToLocal(scope.CloseAndEscape(returned));
4154 } 4201 }
4155 return Local<v8::Object>(); 4202 return Local<v8::Object>();
4156 } 4203 }
4157 4204
4158 4205
4206 Local<Function> Function::New(Isolate* v8_isolate,
4207 FunctionCallback callback,
4208 Local<Value> data,
4209 int length) {
4210 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
4211 LOG_API(isolate, "Function::New");
4212 ENTER_V8(isolate);
4213 return FunctionTemplateNew(
4214 isolate, callback, data, Local<Signature>(), length, true)->
4215 GetFunction();
4216 }
4217
4218
4159 Local<v8::Object> Function::NewInstance() const { 4219 Local<v8::Object> Function::NewInstance() const {
4160 return NewInstance(0, NULL); 4220 return NewInstance(0, NULL);
4161 } 4221 }
4162 4222
4163 4223
4164 Local<v8::Object> Function::NewInstance(int argc, 4224 Local<v8::Object> Function::NewInstance(int argc,
4165 v8::Handle<v8::Value> argv[]) const { 4225 v8::Handle<v8::Value> argv[]) const {
4166 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 4226 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
4167 ON_BAILOUT(isolate, "v8::Function::NewInstance()", 4227 ON_BAILOUT(isolate, "v8::Function::NewInstance()",
4168 return Local<v8::Object>()); 4228 return Local<v8::Object>());
(...skipping 22 matching lines...) Expand all
4191 i::Logger::TimerEventScope timer_scope( 4251 i::Logger::TimerEventScope timer_scope(
4192 isolate, i::Logger::TimerEventScope::v8_execute); 4252 isolate, i::Logger::TimerEventScope::v8_execute);
4193 i::Object* raw_result = NULL; 4253 i::Object* raw_result = NULL;
4194 { 4254 {
4195 i::HandleScope scope(isolate); 4255 i::HandleScope scope(isolate);
4196 i::Handle<i::JSFunction> fun = Utils::OpenHandle(this); 4256 i::Handle<i::JSFunction> fun = Utils::OpenHandle(this);
4197 i::Handle<i::Object> recv_obj = Utils::OpenHandle(*recv); 4257 i::Handle<i::Object> recv_obj = Utils::OpenHandle(*recv);
4198 STATIC_ASSERT(sizeof(v8::Handle<v8::Value>) == sizeof(i::Object**)); 4258 STATIC_ASSERT(sizeof(v8::Handle<v8::Value>) == sizeof(i::Object**));
4199 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); 4259 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv);
4200 EXCEPTION_PREAMBLE(isolate); 4260 EXCEPTION_PREAMBLE(isolate);
4201 i::Handle<i::Object> returned = 4261 i::Handle<i::Object> returned = i::Execution::Call(
4202 i::Execution::Call(fun, recv_obj, argc, args, &has_pending_exception); 4262 isolate, fun, recv_obj, argc, args, &has_pending_exception);
4203 EXCEPTION_BAILOUT_CHECK_DO_CALLBACK(isolate, Local<Object>()); 4263 EXCEPTION_BAILOUT_CHECK_DO_CALLBACK(isolate, Local<Object>());
4204 raw_result = *returned; 4264 raw_result = *returned;
4205 } 4265 }
4206 i::Handle<i::Object> result(raw_result, isolate); 4266 i::Handle<i::Object> result(raw_result, isolate);
4207 return Utils::ToLocal(result); 4267 return Utils::ToLocal(result);
4208 } 4268 }
4209 4269
4210 4270
4211 void Function::SetName(v8::Handle<v8::String> name) { 4271 void Function::SetName(v8::Handle<v8::String> name) {
4212 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 4272 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
(...skipping 1063 matching lines...) Expand 10 before | Expand all | Expand 10 after
5276 isolate->global_handles()->IterateAllRootsInNewSpaceWithClassIds( 5336 isolate->global_handles()->IterateAllRootsInNewSpaceWithClassIds(
5277 &visitor_adapter); 5337 &visitor_adapter);
5278 } 5338 }
5279 5339
5280 5340
5281 bool v8::V8::IdleNotification(int hint) { 5341 bool v8::V8::IdleNotification(int hint) {
5282 // Returning true tells the caller that it need not 5342 // Returning true tells the caller that it need not
5283 // continue to call IdleNotification. 5343 // continue to call IdleNotification.
5284 i::Isolate* isolate = i::Isolate::Current(); 5344 i::Isolate* isolate = i::Isolate::Current();
5285 if (isolate == NULL || !isolate->IsInitialized()) return true; 5345 if (isolate == NULL || !isolate->IsInitialized()) return true;
5286 return i::V8::IdleNotification(hint); 5346 if (!i::FLAG_use_idle_notification) return true;
5347 return isolate->heap()->IdleNotification(hint);
5287 } 5348 }
5288 5349
5289 5350
5290 void v8::V8::LowMemoryNotification() { 5351 void v8::V8::LowMemoryNotification() {
5291 i::Isolate* isolate = i::Isolate::Current(); 5352 i::Isolate* isolate = i::Isolate::Current();
5292 if (isolate == NULL || !isolate->IsInitialized()) return; 5353 if (isolate == NULL || !isolate->IsInitialized()) return;
5293 isolate->heap()->CollectAllAvailableGarbage("low memory notification"); 5354 isolate->heap()->CollectAllAvailableGarbage("low memory notification");
5294 } 5355 }
5295 5356
5296 5357
5297 int v8::V8::ContextDisposedNotification() { 5358 int v8::V8::ContextDisposedNotification() {
5298 i::Isolate* isolate = i::Isolate::Current(); 5359 i::Isolate* isolate = i::Isolate::Current();
5299 if (!isolate->IsInitialized()) return 0; 5360 if (!isolate->IsInitialized()) return 0;
5300 return isolate->heap()->NotifyContextDisposed(); 5361 return isolate->heap()->NotifyContextDisposed();
5301 } 5362 }
5302 5363
5303 5364
5304 bool v8::V8::InitializeICU() { 5365 bool v8::V8::InitializeICU() {
5305 return i::InitializeICU(); 5366 return i::InitializeICU();
5306 } 5367 }
5307 5368
5308 5369
5309 const char* v8::V8::GetVersion() { 5370 const char* v8::V8::GetVersion() {
5310 return i::Version::GetVersion(); 5371 return i::Version::GetVersion();
5311 } 5372 }
5312 5373
5313 5374
5314 static i::Handle<i::FunctionTemplateInfo>
5315 EnsureConstructor(i::Handle<i::ObjectTemplateInfo> templ) {
5316 if (templ->constructor()->IsUndefined()) {
5317 Local<FunctionTemplate> constructor = FunctionTemplate::New();
5318 Utils::OpenHandle(*constructor)->set_instance_template(*templ);
5319 templ->set_constructor(*Utils::OpenHandle(*constructor));
5320 }
5321 return i::Handle<i::FunctionTemplateInfo>(
5322 i::FunctionTemplateInfo::cast(templ->constructor()));
5323 }
5324
5325
5326 static i::Handle<i::Context> CreateEnvironment( 5375 static i::Handle<i::Context> CreateEnvironment(
5327 i::Isolate* isolate, 5376 i::Isolate* isolate,
5328 v8::ExtensionConfiguration* extensions, 5377 v8::ExtensionConfiguration* extensions,
5329 v8::Handle<ObjectTemplate> global_template, 5378 v8::Handle<ObjectTemplate> global_template,
5330 v8::Handle<Value> global_object) { 5379 v8::Handle<Value> global_object) {
5331 i::Handle<i::Context> env; 5380 i::Handle<i::Context> env;
5332 5381
5333 // Enter V8 via an ENTER_V8 scope. 5382 // Enter V8 via an ENTER_V8 scope.
5334 { 5383 {
5335 ENTER_V8(isolate); 5384 ENTER_V8(isolate);
5336 v8::Handle<ObjectTemplate> proxy_template = global_template; 5385 v8::Handle<ObjectTemplate> proxy_template = global_template;
5337 i::Handle<i::FunctionTemplateInfo> proxy_constructor; 5386 i::Handle<i::FunctionTemplateInfo> proxy_constructor;
5338 i::Handle<i::FunctionTemplateInfo> global_constructor; 5387 i::Handle<i::FunctionTemplateInfo> global_constructor;
5339 5388
5340 if (!global_template.IsEmpty()) { 5389 if (!global_template.IsEmpty()) {
5341 // Make sure that the global_template has a constructor. 5390 // Make sure that the global_template has a constructor.
5342 global_constructor = 5391 global_constructor = EnsureConstructor(*global_template);
5343 EnsureConstructor(Utils::OpenHandle(*global_template));
5344 5392
5345 // Create a fresh template for the global proxy object. 5393 // Create a fresh template for the global proxy object.
5346 proxy_template = ObjectTemplate::New(); 5394 proxy_template = ObjectTemplate::New();
5347 proxy_constructor = 5395 proxy_constructor = EnsureConstructor(*proxy_template);
5348 EnsureConstructor(Utils::OpenHandle(*proxy_template));
5349 5396
5350 // Set the global template to be the prototype template of 5397 // Set the global template to be the prototype template of
5351 // global proxy template. 5398 // global proxy template.
5352 proxy_constructor->set_prototype_template( 5399 proxy_constructor->set_prototype_template(
5353 *Utils::OpenHandle(*global_template)); 5400 *Utils::OpenHandle(*global_template));
5354 5401
5355 // Migrate security handlers from global_template to 5402 // Migrate security handlers from global_template to
5356 // proxy_template. Temporarily removing access check 5403 // proxy_template. Temporarily removing access check
5357 // information from the global template. 5404 // information from the global template.
5358 if (!global_constructor->access_check_info()->IsUndefined()) { 5405 if (!global_constructor->access_check_info()->IsUndefined()) {
(...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after
6043 i::Isolate* isolate = i::Isolate::Current(); 6090 i::Isolate* isolate = i::Isolate::Current();
6044 EnsureInitializedForIsolate(isolate, "v8::Date::New()"); 6091 EnsureInitializedForIsolate(isolate, "v8::Date::New()");
6045 LOG_API(isolate, "Date::New"); 6092 LOG_API(isolate, "Date::New");
6046 if (std::isnan(time)) { 6093 if (std::isnan(time)) {
6047 // Introduce only canonical NaN value into the VM, to avoid signaling NaNs. 6094 // Introduce only canonical NaN value into the VM, to avoid signaling NaNs.
6048 time = i::OS::nan_value(); 6095 time = i::OS::nan_value();
6049 } 6096 }
6050 ENTER_V8(isolate); 6097 ENTER_V8(isolate);
6051 EXCEPTION_PREAMBLE(isolate); 6098 EXCEPTION_PREAMBLE(isolate);
6052 i::Handle<i::Object> obj = 6099 i::Handle<i::Object> obj =
6053 i::Execution::NewDate(time, &has_pending_exception); 6100 i::Execution::NewDate(isolate, time, &has_pending_exception);
6054 EXCEPTION_BAILOUT_CHECK(isolate, Local<v8::Value>()); 6101 EXCEPTION_BAILOUT_CHECK(isolate, Local<v8::Value>());
6055 return Utils::ToLocal(obj); 6102 return Utils::ToLocal(obj);
6056 } 6103 }
6057 6104
6058 6105
6059 double v8::Date::ValueOf() const { 6106 double v8::Date::ValueOf() const {
6060 i::Isolate* isolate = i::Isolate::Current(); 6107 i::Isolate* isolate = i::Isolate::Current();
6061 if (IsDeadCheck(isolate, "v8::Date::NumberValue()")) return 0; 6108 if (IsDeadCheck(isolate, "v8::Date::NumberValue()")) return 0;
6062 LOG_API(isolate, "Date::NumberValue"); 6109 LOG_API(isolate, "Date::NumberValue");
6063 i::Handle<i::Object> obj = Utils::OpenHandle(this); 6110 i::Handle<i::Object> obj = Utils::OpenHandle(this);
(...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after
6745 6792
6746 6793
6747 void V8::RemoveCallCompletedCallback(CallCompletedCallback callback) { 6794 void V8::RemoveCallCompletedCallback(CallCompletedCallback callback) {
6748 i::Isolate::EnsureDefaultIsolate(); 6795 i::Isolate::EnsureDefaultIsolate();
6749 i::Isolate* isolate = i::Isolate::Current(); 6796 i::Isolate* isolate = i::Isolate::Current();
6750 if (IsDeadCheck(isolate, "v8::V8::RemoveLeaveScriptCallback()")) return; 6797 if (IsDeadCheck(isolate, "v8::V8::RemoveLeaveScriptCallback()")) return;
6751 i::V8::RemoveCallCompletedCallback(callback); 6798 i::V8::RemoveCallCompletedCallback(callback);
6752 } 6799 }
6753 6800
6754 6801
6755 int V8::GetCurrentThreadId() {
6756 i::Isolate* isolate = i::Isolate::Current();
6757 EnsureInitializedForIsolate(isolate, "V8::GetCurrentThreadId()");
6758 return isolate->thread_id().ToInteger();
6759 }
6760
6761
6762 void V8::TerminateExecution(int thread_id) {
6763 i::Isolate* isolate = i::Isolate::Current();
6764 if (!isolate->IsInitialized()) return;
6765 API_ENTRY_CHECK(isolate, "V8::TerminateExecution()");
6766 // If the thread_id identifies the current thread just terminate
6767 // execution right away. Otherwise, ask the thread manager to
6768 // terminate the thread with the given id if any.
6769 i::ThreadId internal_tid = i::ThreadId::FromInteger(thread_id);
6770 if (isolate->thread_id().Equals(internal_tid)) {
6771 isolate->stack_guard()->TerminateExecution();
6772 } else {
6773 isolate->thread_manager()->TerminateExecution(internal_tid);
6774 }
6775 }
6776
6777
6778 void V8::TerminateExecution(Isolate* isolate) { 6802 void V8::TerminateExecution(Isolate* isolate) {
6779 // If no isolate is supplied, use the default isolate. 6803 // If no isolate is supplied, use the default isolate.
6780 if (isolate != NULL) { 6804 if (isolate != NULL) {
6781 reinterpret_cast<i::Isolate*>(isolate)->stack_guard()->TerminateExecution(); 6805 reinterpret_cast<i::Isolate*>(isolate)->stack_guard()->TerminateExecution();
6782 } else { 6806 } else {
6783 i::Isolate::GetDefaultIsolateStackGuard()->TerminateExecution(); 6807 i::Isolate::GetDefaultIsolateStackGuard()->TerminateExecution();
6784 } 6808 }
6785 } 6809 }
6786 6810
6787 6811
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
7163 wait_for_connection); 7187 wait_for_connection);
7164 } 7188 }
7165 7189
7166 7190
7167 void Debug::DisableAgent() { 7191 void Debug::DisableAgent() {
7168 return i::Isolate::Current()->debugger()->StopAgent(); 7192 return i::Isolate::Current()->debugger()->StopAgent();
7169 } 7193 }
7170 7194
7171 7195
7172 void Debug::ProcessDebugMessages() { 7196 void Debug::ProcessDebugMessages() {
7173 i::Execution::ProcessDebugMessages(true); 7197 i::Execution::ProcessDebugMessages(i::Isolate::Current(), true);
7174 } 7198 }
7175 7199
7176 7200
7177 Local<Context> Debug::GetDebugContext() { 7201 Local<Context> Debug::GetDebugContext() {
7178 i::Isolate* isolate = i::Isolate::Current(); 7202 i::Isolate* isolate = i::Isolate::Current();
7179 EnsureInitializedForIsolate(isolate, "v8::Debug::GetDebugContext()"); 7203 EnsureInitializedForIsolate(isolate, "v8::Debug::GetDebugContext()");
7180 ENTER_V8(isolate); 7204 ENTER_V8(isolate);
7181 return Utils::ToLocal(i::Isolate::Current()->debugger()->GetDebugContext()); 7205 return Utils::ToLocal(i::Isolate::Current()->debugger()->GetDebugContext());
7182 } 7206 }
7183 7207
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
7228 return ToApiHandle<String>(isolate->factory()->InternalizeUtf8String( 7252 return ToApiHandle<String>(isolate->factory()->InternalizeUtf8String(
7229 node->entry()->resource_name())); 7253 node->entry()->resource_name()));
7230 } 7254 }
7231 7255
7232 7256
7233 int CpuProfileNode::GetLineNumber() const { 7257 int CpuProfileNode::GetLineNumber() const {
7234 return reinterpret_cast<const i::ProfileNode*>(this)->entry()->line_number(); 7258 return reinterpret_cast<const i::ProfileNode*>(this)->entry()->line_number();
7235 } 7259 }
7236 7260
7237 7261
7262 const char* CpuProfileNode::GetBailoutReason() const {
7263 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this);
7264 return node->entry()->bailout_reason();
7265 }
7266
7267
7238 double CpuProfileNode::GetSelfSamplesCount() const { 7268 double CpuProfileNode::GetSelfSamplesCount() const {
7239 i::Isolate* isolate = i::Isolate::Current(); 7269 i::Isolate* isolate = i::Isolate::Current();
7240 IsDeadCheck(isolate, "v8::CpuProfileNode::GetSelfSamplesCount"); 7270 IsDeadCheck(isolate, "v8::CpuProfileNode::GetSelfSamplesCount");
7241 return reinterpret_cast<const i::ProfileNode*>(this)->self_ticks(); 7271 return reinterpret_cast<const i::ProfileNode*>(this)->self_ticks();
7242 } 7272 }
7243 7273
7244 7274
7245 unsigned CpuProfileNode::GetHitCount() const { 7275 unsigned CpuProfileNode::GetHitCount() const {
7246 return reinterpret_cast<const i::ProfileNode*>(this)->self_ticks(); 7276 return reinterpret_cast<const i::ProfileNode*>(this)->self_ticks();
7247 } 7277 }
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
7323 int CpuProfile::GetSamplesCount() const { 7353 int CpuProfile::GetSamplesCount() const {
7324 return reinterpret_cast<const i::CpuProfile*>(this)->samples_count(); 7354 return reinterpret_cast<const i::CpuProfile*>(this)->samples_count();
7325 } 7355 }
7326 7356
7327 7357
7328 int CpuProfiler::GetProfileCount() { 7358 int CpuProfiler::GetProfileCount() {
7329 return reinterpret_cast<i::CpuProfiler*>(this)->GetProfilesCount(); 7359 return reinterpret_cast<i::CpuProfiler*>(this)->GetProfilesCount();
7330 } 7360 }
7331 7361
7332 7362
7363 void CpuProfiler::SetSamplingInterval(int us) {
7364 ASSERT(us >= 0);
7365 return reinterpret_cast<i::CpuProfiler*>(this)->set_sampling_interval(
7366 i::TimeDelta::FromMicroseconds(us));
7367 }
7368
7369
7333 const CpuProfile* CpuProfiler::GetCpuProfile(int index) { 7370 const CpuProfile* CpuProfiler::GetCpuProfile(int index) {
7334 return reinterpret_cast<const CpuProfile*>( 7371 return reinterpret_cast<const CpuProfile*>(
7335 reinterpret_cast<i::CpuProfiler*>(this)->GetProfile(index)); 7372 reinterpret_cast<i::CpuProfiler*>(this)->GetProfile(index));
7336 } 7373 }
7337 7374
7338 7375
7339 void CpuProfiler::StartCpuProfiling(Handle<String> title, bool record_samples) { 7376 void CpuProfiler::StartCpuProfiling(Handle<String> title, bool record_samples) {
7340 reinterpret_cast<i::CpuProfiler*>(this)->StartProfiling( 7377 reinterpret_cast<i::CpuProfiler*>(this)->StartProfiling(
7341 *Utils::OpenHandle(*title), record_samples); 7378 *Utils::OpenHandle(*title), record_samples);
7342 } 7379 }
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after
7848 void InvokeAccessorGetterCallback( 7885 void InvokeAccessorGetterCallback(
7849 v8::Local<v8::String> property, 7886 v8::Local<v8::String> property,
7850 const v8::PropertyCallbackInfo<v8::Value>& info, 7887 const v8::PropertyCallbackInfo<v8::Value>& info,
7851 v8::AccessorGetterCallback getter) { 7888 v8::AccessorGetterCallback getter) {
7852 // Leaving JavaScript. 7889 // Leaving JavaScript.
7853 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 7890 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
7854 Address getter_address = reinterpret_cast<Address>(reinterpret_cast<intptr_t>( 7891 Address getter_address = reinterpret_cast<Address>(reinterpret_cast<intptr_t>(
7855 getter)); 7892 getter));
7856 VMState<EXTERNAL> state(isolate); 7893 VMState<EXTERNAL> state(isolate);
7857 ExternalCallbackScope call_scope(isolate, getter_address); 7894 ExternalCallbackScope call_scope(isolate, getter_address);
7858 return getter(property, info); 7895 getter(property, info);
7859 } 7896 }
7860 7897
7861 7898
7862 void InvokeFunctionCallback(const v8::FunctionCallbackInfo<v8::Value>& info, 7899 void InvokeFunctionCallback(const v8::FunctionCallbackInfo<v8::Value>& info,
7863 v8::FunctionCallback callback) { 7900 v8::FunctionCallback callback) {
7864 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 7901 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
7865 Address callback_address = 7902 Address callback_address =
7866 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 7903 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
7867 VMState<EXTERNAL> state(isolate); 7904 VMState<EXTERNAL> state(isolate);
7868 ExternalCallbackScope call_scope(isolate, callback_address); 7905 ExternalCallbackScope call_scope(isolate, callback_address);
7869 return callback(info); 7906 callback(info);
7870 } 7907 }
7871 7908
7872 7909
7873 } } // namespace v8::internal 7910 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/accessors.cc ('k') | src/apinatives.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698