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

Side by Side Diff: src/api.cc

Issue 982123003: convert more things to maybe (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 9 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
« include/v8.h ('K') | « include/v8.h ('k') | no next file » | 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 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/api.h" 5 #include "src/api.h"
6 6
7 #include <string.h> // For memcpy, strlen. 7 #include <string.h> // For memcpy, strlen.
8 #ifdef V8_USE_ADDRESS_SANITIZER 8 #ifdef V8_USE_ADDRESS_SANITIZER
9 #include <sanitizer/asan_interface.h> 9 #include <sanitizer/asan_interface.h>
10 #endif // V8_USE_ADDRESS_SANITIZER 10 #endif // V8_USE_ADDRESS_SANITIZER
(...skipping 1490 matching lines...) Expand 10 before | Expand all | Expand 10 after
1501 obj->GetIsolate()->factory()->NewFunctionFromSharedFunctionInfo( 1501 obj->GetIsolate()->factory()->NewFunctionFromSharedFunctionInfo(
1502 function_info, obj->GetIsolate()->native_context()); 1502 function_info, obj->GetIsolate()->native_context());
1503 return ToApiHandle<Script>(function); 1503 return ToApiHandle<Script>(function);
1504 } 1504 }
1505 1505
1506 1506
1507 int UnboundScript::GetId() { 1507 int UnboundScript::GetId() {
1508 i::Handle<i::HeapObject> obj = 1508 i::Handle<i::HeapObject> obj =
1509 i::Handle<i::HeapObject>::cast(Utils::OpenHandle(this)); 1509 i::Handle<i::HeapObject>::cast(Utils::OpenHandle(this));
1510 i::Isolate* isolate = obj->GetIsolate(); 1510 i::Isolate* isolate = obj->GetIsolate();
1511 ON_BAILOUT(isolate, "v8::UnboundScript::GetId()", return -1);
1512 LOG_API(isolate, "v8::UnboundScript::GetId"); 1511 LOG_API(isolate, "v8::UnboundScript::GetId");
1513 { 1512 i::HandleScope scope(isolate);
1514 i::HandleScope scope(isolate); 1513 i::Handle<i::SharedFunctionInfo> function_info(
1515 i::Handle<i::SharedFunctionInfo> function_info( 1514 i::SharedFunctionInfo::cast(*obj));
1516 i::SharedFunctionInfo::cast(*obj)); 1515 i::Handle<i::Script> script(i::Script::cast(function_info->script()));
1517 i::Handle<i::Script> script(i::Script::cast(function_info->script())); 1516 return script->id()->value();
1518 return script->id()->value();
1519 }
1520 } 1517 }
1521 1518
1522 1519
1523 int UnboundScript::GetLineNumber(int code_pos) { 1520 int UnboundScript::GetLineNumber(int code_pos) {
1524 i::Handle<i::SharedFunctionInfo> obj = 1521 i::Handle<i::SharedFunctionInfo> obj =
1525 i::Handle<i::SharedFunctionInfo>::cast(Utils::OpenHandle(this)); 1522 i::Handle<i::SharedFunctionInfo>::cast(Utils::OpenHandle(this));
1526 i::Isolate* isolate = obj->GetIsolate(); 1523 i::Isolate* isolate = obj->GetIsolate();
1527 ON_BAILOUT(isolate, "v8::UnboundScript::GetLineNumber()", return -1);
1528 LOG_API(isolate, "UnboundScript::GetLineNumber"); 1524 LOG_API(isolate, "UnboundScript::GetLineNumber");
1529 if (obj->script()->IsScript()) { 1525 if (obj->script()->IsScript()) {
1530 i::Handle<i::Script> script(i::Script::cast(obj->script())); 1526 i::Handle<i::Script> script(i::Script::cast(obj->script()));
1531 return i::Script::GetLineNumber(script, code_pos); 1527 return i::Script::GetLineNumber(script, code_pos);
1532 } else { 1528 } else {
1533 return -1; 1529 return -1;
1534 } 1530 }
1535 } 1531 }
1536 1532
1537 1533
1538 Handle<Value> UnboundScript::GetScriptName() { 1534 Handle<Value> UnboundScript::GetScriptName() {
1539 i::Handle<i::SharedFunctionInfo> obj = 1535 i::Handle<i::SharedFunctionInfo> obj =
1540 i::Handle<i::SharedFunctionInfo>::cast(Utils::OpenHandle(this)); 1536 i::Handle<i::SharedFunctionInfo>::cast(Utils::OpenHandle(this));
1541 i::Isolate* isolate = obj->GetIsolate(); 1537 i::Isolate* isolate = obj->GetIsolate();
1542 ON_BAILOUT(isolate, "v8::UnboundScript::GetName()",
1543 return Handle<String>());
1544 LOG_API(isolate, "UnboundScript::GetName"); 1538 LOG_API(isolate, "UnboundScript::GetName");
1545 if (obj->script()->IsScript()) { 1539 if (obj->script()->IsScript()) {
1546 i::Object* name = i::Script::cast(obj->script())->name(); 1540 i::Object* name = i::Script::cast(obj->script())->name();
1547 return Utils::ToLocal(i::Handle<i::Object>(name, isolate)); 1541 return Utils::ToLocal(i::Handle<i::Object>(name, isolate));
1548 } else { 1542 } else {
1549 return Handle<String>(); 1543 return Handle<String>();
1550 } 1544 }
1551 } 1545 }
1552 1546
1553 1547
1554 Handle<Value> UnboundScript::GetSourceURL() { 1548 Handle<Value> UnboundScript::GetSourceURL() {
1555 i::Handle<i::SharedFunctionInfo> obj = 1549 i::Handle<i::SharedFunctionInfo> obj =
1556 i::Handle<i::SharedFunctionInfo>::cast(Utils::OpenHandle(this)); 1550 i::Handle<i::SharedFunctionInfo>::cast(Utils::OpenHandle(this));
1557 i::Isolate* isolate = obj->GetIsolate(); 1551 i::Isolate* isolate = obj->GetIsolate();
1558 ON_BAILOUT(isolate, "v8::UnboundScript::GetSourceURL()",
1559 return Handle<String>());
1560 LOG_API(isolate, "UnboundScript::GetSourceURL"); 1552 LOG_API(isolate, "UnboundScript::GetSourceURL");
1561 if (obj->script()->IsScript()) { 1553 if (obj->script()->IsScript()) {
1562 i::Object* url = i::Script::cast(obj->script())->source_url(); 1554 i::Object* url = i::Script::cast(obj->script())->source_url();
1563 return Utils::ToLocal(i::Handle<i::Object>(url, isolate)); 1555 return Utils::ToLocal(i::Handle<i::Object>(url, isolate));
1564 } else { 1556 } else {
1565 return Handle<String>(); 1557 return Handle<String>();
1566 } 1558 }
1567 } 1559 }
1568 1560
1569 1561
1570 Handle<Value> UnboundScript::GetSourceMappingURL() { 1562 Handle<Value> UnboundScript::GetSourceMappingURL() {
1571 i::Handle<i::SharedFunctionInfo> obj = 1563 i::Handle<i::SharedFunctionInfo> obj =
1572 i::Handle<i::SharedFunctionInfo>::cast(Utils::OpenHandle(this)); 1564 i::Handle<i::SharedFunctionInfo>::cast(Utils::OpenHandle(this));
1573 i::Isolate* isolate = obj->GetIsolate(); 1565 i::Isolate* isolate = obj->GetIsolate();
1574 ON_BAILOUT(isolate, "v8::UnboundScript::GetSourceMappingURL()",
1575 return Handle<String>());
1576 LOG_API(isolate, "UnboundScript::GetSourceMappingURL"); 1566 LOG_API(isolate, "UnboundScript::GetSourceMappingURL");
1577 if (obj->script()->IsScript()) { 1567 if (obj->script()->IsScript()) {
1578 i::Object* url = i::Script::cast(obj->script())->source_mapping_url(); 1568 i::Object* url = i::Script::cast(obj->script())->source_mapping_url();
1579 return Utils::ToLocal(i::Handle<i::Object>(url, isolate)); 1569 return Utils::ToLocal(i::Handle<i::Object>(url, isolate));
1580 } else { 1570 } else {
1581 return Handle<String>(); 1571 return Handle<String>();
1582 } 1572 }
1583 } 1573 }
1584 1574
1585 1575
1576 MaybeLocal<Value> Script::Run(Local<Context> context) {
1577 PREPARE_FOR_EXECUTION_WITH_CALLBACK(context, "v8::Script::Run()", Value)
1578 i::AggregatingHistogramTimerScope timer(isolate->counters()->compile_lazy());
1579 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate);
1580 auto fun = i::Handle<i::JSFunction>::cast(Utils::OpenHandle(this));
1581 i::Handle<i::Object> receiver(isolate->global_proxy(), isolate);
1582 Local<Value> result;
1583 has_pending_exception =
1584 !ToLocal<Value>(i::Execution::Call(isolate, fun, receiver, 0, NULL),
1585 &result);
1586 RETURN_ON_FAILED_EXECUTION(Value);
1587 RETURN_ESCAPED(result);
1588 }
1589
1590
1586 Local<Value> Script::Run() { 1591 Local<Value> Script::Run() {
1587 i::Handle<i::Object> obj = Utils::OpenHandle(this, true); 1592 auto self = Utils::OpenHandle(this, true);
1588 // If execution is terminating, Compile(..)->Run() requires this 1593 // If execution is terminating, Compile(..)->Run() requires this
1589 // check. 1594 // check.
1590 if (obj.is_null()) return Local<Value>(); 1595 if (self.is_null()) return Local<Value>();
1591 i::Isolate* isolate = i::Handle<i::HeapObject>::cast(obj)->GetIsolate(); 1596 auto context = ContextFromHeapObject(self);
1592 ON_BAILOUT(isolate, "v8::Script::Run()", return Local<Value>()); 1597 RETURN_TO_LOCAL_UNCHECKED(Run(context), Value);
1593 LOG_API(isolate, "Script::Run");
1594 ENTER_V8(isolate);
1595 i::AggregatingHistogramTimerScope timer(isolate->counters()->compile_lazy());
1596 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate);
1597 i::HandleScope scope(isolate);
1598 i::Handle<i::JSFunction> fun = i::Handle<i::JSFunction>::cast(obj);
1599 EXCEPTION_PREAMBLE(isolate);
1600 i::Handle<i::Object> receiver(isolate->global_proxy(), isolate);
1601 i::Handle<i::Object> result;
1602 has_pending_exception = !i::Execution::Call(
1603 isolate, fun, receiver, 0, NULL).ToHandle(&result);
1604 EXCEPTION_BAILOUT_CHECK_DO_CALLBACK(isolate, Local<Value>());
1605 return Utils::ToLocal(scope.CloseAndEscape(result));
1606 } 1598 }
1607 1599
1608 1600
1609 Local<UnboundScript> Script::GetUnboundScript() { 1601 Local<UnboundScript> Script::GetUnboundScript() {
1610 i::Handle<i::Object> obj = Utils::OpenHandle(this); 1602 i::Handle<i::Object> obj = Utils::OpenHandle(this);
1611 return ToApiHandle<UnboundScript>( 1603 return ToApiHandle<UnboundScript>(
1612 i::Handle<i::SharedFunctionInfo>(i::JSFunction::cast(*obj)->shared())); 1604 i::Handle<i::SharedFunctionInfo>(i::JSFunction::cast(*obj)->shared()));
1613 } 1605 }
1614 1606
1615 1607
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after
2169 void v8::TryCatch::SetCaptureMessage(bool value) { 2161 void v8::TryCatch::SetCaptureMessage(bool value) {
2170 capture_message_ = value; 2162 capture_message_ = value;
2171 } 2163 }
2172 2164
2173 2165
2174 // --- M e s s a g e --- 2166 // --- M e s s a g e ---
2175 2167
2176 2168
2177 Local<String> Message::Get() const { 2169 Local<String> Message::Get() const {
2178 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 2170 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2179 ON_BAILOUT(isolate, "v8::Message::Get()", return Local<String>());
2180 ENTER_V8(isolate); 2171 ENTER_V8(isolate);
2181 EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate)); 2172 EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate));
2182 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2173 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2183 i::Handle<i::String> raw_result = i::MessageHandler::GetMessage(isolate, obj); 2174 i::Handle<i::String> raw_result = i::MessageHandler::GetMessage(isolate, obj);
2184 Local<String> result = Utils::ToLocal(raw_result); 2175 Local<String> result = Utils::ToLocal(raw_result);
2185 return scope.Escape(result); 2176 return scope.Escape(result);
2186 } 2177 }
2187 2178
2188 2179
2189 ScriptOrigin Message::GetScriptOrigin() const { 2180 ScriptOrigin Message::GetScriptOrigin() const {
2190 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 2181 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2191 i::Handle<i::JSMessageObject> message = 2182 auto message = i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this));
2192 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this)); 2183 auto script_wraper = i::Handle<i::Object>(message->script(), isolate);
2193 i::Handle<i::Object> script_wraper = 2184 auto script_value = i::Handle<i::JSValue>::cast(script_wraper);
2194 i::Handle<i::Object>(message->script(), isolate);
2195 i::Handle<i::JSValue> script_value =
2196 i::Handle<i::JSValue>::cast(script_wraper);
2197 i::Handle<i::Script> script(i::Script::cast(script_value->value())); 2185 i::Handle<i::Script> script(i::Script::cast(script_value->value()));
2198 return GetScriptOriginForScript(isolate, script); 2186 return GetScriptOriginForScript(isolate, script);
2199 } 2187 }
2200 2188
2201 2189
2202 v8::Handle<Value> Message::GetScriptResourceName() const { 2190 v8::Handle<Value> Message::GetScriptResourceName() const {
2203 return GetScriptOrigin().ResourceName(); 2191 return GetScriptOrigin().ResourceName();
2204 } 2192 }
2205 2193
2206 2194
2207 v8::Handle<v8::StackTrace> Message::GetStackTrace() const { 2195 v8::Handle<v8::StackTrace> Message::GetStackTrace() const {
2208 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 2196 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2209 ENTER_V8(isolate); 2197 ENTER_V8(isolate);
2210 EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate)); 2198 EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate));
2211 i::Handle<i::JSMessageObject> message = 2199 auto message = i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this));
2212 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this));
2213 i::Handle<i::Object> stackFramesObj(message->stack_frames(), isolate); 2200 i::Handle<i::Object> stackFramesObj(message->stack_frames(), isolate);
2214 if (!stackFramesObj->IsJSArray()) return v8::Handle<v8::StackTrace>(); 2201 if (!stackFramesObj->IsJSArray()) return v8::Handle<v8::StackTrace>();
2215 i::Handle<i::JSArray> stackTrace = 2202 auto stackTrace = i::Handle<i::JSArray>::cast(stackFramesObj);
2216 i::Handle<i::JSArray>::cast(stackFramesObj);
2217 return scope.Escape(Utils::StackTraceToLocal(stackTrace)); 2203 return scope.Escape(Utils::StackTraceToLocal(stackTrace));
2218 } 2204 }
2219 2205
2220 2206
2221 MUST_USE_RESULT static i::MaybeHandle<i::Object> CallV8HeapFunction( 2207 MUST_USE_RESULT static i::MaybeHandle<i::Object> CallV8HeapFunction(
2222 i::Isolate* isolate, const char* name, i::Handle<i::Object> recv, int argc, 2208 i::Isolate* isolate, const char* name, i::Handle<i::Object> recv, int argc,
2223 i::Handle<i::Object> argv[]) { 2209 i::Handle<i::Object> argv[]) {
2224 i::Handle<i::Object> object_fun = 2210 i::Handle<i::Object> object_fun =
2225 i::Object::GetProperty( 2211 i::Object::GetProperty(
2226 isolate, isolate->js_builtins_object(), name).ToHandleChecked(); 2212 isolate, isolate->js_builtins_object(), name).ToHandleChecked();
2227 i::Handle<i::JSFunction> fun = i::Handle<i::JSFunction>::cast(object_fun); 2213 i::Handle<i::JSFunction> fun = i::Handle<i::JSFunction>::cast(object_fun);
2228 return i::Execution::Call(isolate, fun, recv, argc, argv); 2214 return i::Execution::Call(isolate, fun, recv, argc, argv);
2229 } 2215 }
2230 2216
2231 2217
2232 MUST_USE_RESULT static i::MaybeHandle<i::Object> CallV8HeapFunction( 2218 MUST_USE_RESULT static i::MaybeHandle<i::Object> CallV8HeapFunction(
2233 i::Isolate* isolate, const char* name, i::Handle<i::Object> data) { 2219 i::Isolate* isolate, const char* name, i::Handle<i::Object> data) {
2234 i::Handle<i::Object> argv[] = { data }; 2220 i::Handle<i::Object> argv[] = { data };
2235 return CallV8HeapFunction(isolate, name, isolate->js_builtins_object(), 2221 return CallV8HeapFunction(isolate, name, isolate->js_builtins_object(),
2236 arraysize(argv), argv); 2222 arraysize(argv), argv);
2237 } 2223 }
2238 2224
2239 2225
2226 Maybe<int> Message::GetLineNumber(Local<Context> context) const {
2227 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Message::GetLineNumber()", int);
2228 i::Handle<i::Object> result;
2229 has_pending_exception =
2230 !CallV8HeapFunction(isolate, "GetLineNumber", Utils::OpenHandle(this))
2231 .ToHandle(&result);
2232 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(int);
2233 return Just(static_cast<int>(result->Number()));
2234 }
2235
2236
2240 int Message::GetLineNumber() const { 2237 int Message::GetLineNumber() const {
2241 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 2238 auto context = ContextFromHeapObject(Utils::OpenHandle(this));
2242 ON_BAILOUT(isolate, "v8::Message::GetLineNumber()", return kNoLineNumberInfo); 2239 return GetLineNumber(context).FromMaybe(0);
2243 ENTER_V8(isolate);
2244 i::HandleScope scope(isolate);
2245
2246 EXCEPTION_PREAMBLE(isolate);
2247 i::Handle<i::Object> result;
2248 has_pending_exception =
2249 !CallV8HeapFunction(isolate, "GetLineNumber", Utils::OpenHandle(this))
2250 .ToHandle(&result);
2251 EXCEPTION_BAILOUT_CHECK(isolate, 0);
2252 return static_cast<int>(result->Number());
2253 } 2240 }
2254 2241
2255 2242
2256 int Message::GetStartPosition() const { 2243 int Message::GetStartPosition() const {
2257 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 2244 auto self = Utils::OpenHandle(this);
2258 ENTER_V8(isolate); 2245 return self->start_position();
2259 i::HandleScope scope(isolate);
2260 i::Handle<i::JSMessageObject> message =
2261 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this));
2262 return message->start_position();
2263 } 2246 }
2264 2247
2265 2248
2266 int Message::GetEndPosition() const { 2249 int Message::GetEndPosition() const {
2267 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 2250 auto self = Utils::OpenHandle(this);
2268 ENTER_V8(isolate); 2251 return self->end_position();
2269 i::HandleScope scope(isolate); 2252 }
2270 i::Handle<i::JSMessageObject> message = 2253
2271 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this)); 2254
2272 return message->end_position(); 2255 Maybe<int> Message::GetStartColumn(Local<Context> context) const {
2256 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Message::GetStartColumn()",
2257 int);
2258 auto self = Utils::OpenHandle(this);
2259 i::Handle<i::Object> start_col_obj;
2260 has_pending_exception = !CallV8HeapFunction(isolate, "GetPositionInLine",
2261 self).ToHandle(&start_col_obj);
2262 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(int);
2263 return Just(static_cast<int>(start_col_obj->Number()));
2273 } 2264 }
2274 2265
2275 2266
2276 int Message::GetStartColumn() const { 2267 int Message::GetStartColumn() const {
2277 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 2268 auto context = ContextFromHeapObject(Utils::OpenHandle(this));
2278 ON_BAILOUT(isolate, "v8::Message::GetStartColumn()", return kNoColumnInfo); 2269 const int default_value = kNoColumnInfo;
2279 ENTER_V8(isolate); 2270 return GetStartColumn(context).FromMaybe(default_value);
2280 i::HandleScope scope(isolate); 2271 }
2281 i::Handle<i::JSObject> data_obj = Utils::OpenHandle(this); 2272
2282 EXCEPTION_PREAMBLE(isolate); 2273
2274 Maybe<int> Message::GetEndColumn(Local<Context> context) const {
2275 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Message::GetEndColumn()", int);
2276 auto self = Utils::OpenHandle(this);
2283 i::Handle<i::Object> start_col_obj; 2277 i::Handle<i::Object> start_col_obj;
2284 has_pending_exception = 2278 has_pending_exception = !CallV8HeapFunction(isolate, "GetPositionInLine",
2285 !CallV8HeapFunction(isolate, "GetPositionInLine", data_obj) 2279 self).ToHandle(&start_col_obj);
2286 .ToHandle(&start_col_obj); 2280 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(int);
2287 EXCEPTION_BAILOUT_CHECK(isolate, 0); 2281 int start = self->start_position();
2288 return static_cast<int>(start_col_obj->Number()); 2282 int end = self->end_position();
2283 return Just(static_cast<int>(start_col_obj->Number()) + (end - start));
2289 } 2284 }
2290 2285
2291 2286
2292 int Message::GetEndColumn() const { 2287 int Message::GetEndColumn() const {
2293 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 2288 auto context = ContextFromHeapObject(Utils::OpenHandle(this));
2294 ON_BAILOUT(isolate, "v8::Message::GetEndColumn()", return kNoColumnInfo); 2289 const int default_value = kNoColumnInfo;
2295 ENTER_V8(isolate); 2290 return GetEndColumn(context).FromMaybe(default_value);
2296 i::HandleScope scope(isolate);
2297 i::Handle<i::JSObject> data_obj = Utils::OpenHandle(this);
2298 EXCEPTION_PREAMBLE(isolate);
2299 i::Handle<i::Object> start_col_obj;
2300 has_pending_exception =
2301 !CallV8HeapFunction(isolate, "GetPositionInLine", data_obj)
2302 .ToHandle(&start_col_obj);
2303 EXCEPTION_BAILOUT_CHECK(isolate, 0);
2304 i::Handle<i::JSMessageObject> message =
2305 i::Handle<i::JSMessageObject>::cast(data_obj);
2306 int start = message->start_position();
2307 int end = message->end_position();
2308 return static_cast<int>(start_col_obj->Number()) + (end - start);
2309 } 2291 }
2310 2292
2311 2293
2312 bool Message::IsSharedCrossOrigin() const { 2294 bool Message::IsSharedCrossOrigin() const {
2313 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 2295 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2314 ENTER_V8(isolate); 2296 ENTER_V8(isolate);
2315 i::HandleScope scope(isolate); 2297 auto self = Utils::OpenHandle(this);
2316 i::Handle<i::JSMessageObject> message = 2298 auto script = i::Handle<i::JSValue>::cast(
2317 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this)); 2299 i::Handle<i::Object>(self->script(), isolate));
2318 i::Handle<i::JSValue> script =
2319 i::Handle<i::JSValue>::cast(i::Handle<i::Object>(message->script(),
2320 isolate));
2321 return i::Script::cast(script->value())->is_shared_cross_origin(); 2300 return i::Script::cast(script->value())->is_shared_cross_origin();
2322 } 2301 }
2323 2302
2324 2303
2325 Local<String> Message::GetSourceLine() const { 2304 MaybeLocal<String> Message::GetSourceLine(Local<Context> context) const {
2326 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 2305 PREPARE_FOR_EXECUTION(context, "v8::Message::GetSourceLine()", String);
2327 ON_BAILOUT(isolate, "v8::Message::GetSourceLine()", return Local<String>());
2328 ENTER_V8(isolate);
2329 EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate));
2330 EXCEPTION_PREAMBLE(isolate);
2331 i::Handle<i::Object> result; 2306 i::Handle<i::Object> result;
2332 has_pending_exception = 2307 has_pending_exception =
2333 !CallV8HeapFunction(isolate, "GetSourceLine", Utils::OpenHandle(this)) 2308 !CallV8HeapFunction(isolate, "GetSourceLine", Utils::OpenHandle(this))
2334 .ToHandle(&result); 2309 .ToHandle(&result);
2335 EXCEPTION_BAILOUT_CHECK(isolate, Local<v8::String>()); 2310 RETURN_ON_FAILED_EXECUTION(String);
2311 Local<String> str;
2336 if (result->IsString()) { 2312 if (result->IsString()) {
2337 return scope.Escape(Utils::ToLocal(i::Handle<i::String>::cast(result))); 2313 str = Utils::ToLocal(i::Handle<i::String>::cast(result));
2338 } else {
2339 return Local<String>();
2340 } 2314 }
2315 RETURN_ESCAPED(str);
2341 } 2316 }
2342 2317
2343 2318
2319 Local<String> Message::GetSourceLine() const {
2320 auto context = ContextFromHeapObject(Utils::OpenHandle(this));
2321 RETURN_TO_LOCAL_UNCHECKED(GetSourceLine(context), String)
2322 }
2323
2324
2344 void Message::PrintCurrentStackTrace(Isolate* isolate, FILE* out) { 2325 void Message::PrintCurrentStackTrace(Isolate* isolate, FILE* out) {
2345 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 2326 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
2346 ENTER_V8(i_isolate); 2327 ENTER_V8(i_isolate);
2347 i_isolate->PrintCurrentStackTrace(out); 2328 i_isolate->PrintCurrentStackTrace(out);
2348 } 2329 }
2349 2330
2350 2331
2351 // --- S t a c k T r a c e --- 2332 // --- S t a c k T r a c e ---
2352 2333
2353 Local<StackFrame> StackTrace::GetFrame(uint32_t index) const { 2334 Local<StackFrame> StackTrace::GetFrame(uint32_t index) const {
2354 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 2335 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2355 ENTER_V8(isolate); 2336 ENTER_V8(isolate);
2356 EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate)); 2337 EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate));
2357 i::Handle<i::JSArray> self = Utils::OpenHandle(this); 2338 auto self = Utils::OpenHandle(this);
2358 i::Handle<i::Object> obj = 2339 auto obj = i::Object::GetElement(isolate, self, index).ToHandleChecked();
2359 i::Object::GetElement(isolate, self, index).ToHandleChecked(); 2340 auto jsobj = i::Handle<i::JSObject>::cast(obj);
2360 i::Handle<i::JSObject> jsobj = i::Handle<i::JSObject>::cast(obj);
2361 return scope.Escape(Utils::StackFrameToLocal(jsobj)); 2341 return scope.Escape(Utils::StackFrameToLocal(jsobj));
2362 } 2342 }
2363 2343
2364 2344
2365 int StackTrace::GetFrameCount() const { 2345 int StackTrace::GetFrameCount() const {
2366 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2367 ENTER_V8(isolate);
2368 return i::Smi::cast(Utils::OpenHandle(this)->length())->value(); 2346 return i::Smi::cast(Utils::OpenHandle(this)->length())->value();
2369 } 2347 }
2370 2348
2371 2349
2372 Local<Array> StackTrace::AsArray() { 2350 Local<Array> StackTrace::AsArray() {
2373 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2374 ENTER_V8(isolate);
2375 return Utils::ToLocal(Utils::OpenHandle(this)); 2351 return Utils::ToLocal(Utils::OpenHandle(this));
2376 } 2352 }
2377 2353
2378 2354
2379 Local<StackTrace> StackTrace::CurrentStackTrace( 2355 Local<StackTrace> StackTrace::CurrentStackTrace(
2380 Isolate* isolate, 2356 Isolate* isolate,
2381 int frame_limit, 2357 int frame_limit,
2382 StackTraceOptions options) { 2358 StackTraceOptions options) {
2383 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 2359 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
2384 ENTER_V8(i_isolate); 2360 ENTER_V8(i_isolate);
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
2557 if (!table->IsKey(*key)) { 2533 if (!table->IsKey(*key)) {
2558 DCHECK(false); 2534 DCHECK(false);
2559 return false; 2535 return false;
2560 } 2536 }
2561 return i::Runtime::WeakCollectionDelete(weak_collection, key); 2537 return i::Runtime::WeakCollectionDelete(weak_collection, key);
2562 } 2538 }
2563 2539
2564 2540
2565 // --- J S O N --- 2541 // --- J S O N ---
2566 2542
2567 Local<Value> JSON::Parse(Local<String> json_string) { 2543 MaybeLocal<Value> JSON::Parse(Isolate* v8_isolate, Local<String> json_string) {
2544 auto isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
2545 PREPARE_FOR_EXECUTION_WITH_ISOLATE(isolate, "JSON::Parse", Value);
2568 i::Handle<i::String> string = Utils::OpenHandle(*json_string); 2546 i::Handle<i::String> string = Utils::OpenHandle(*json_string);
2569 i::Isolate* isolate = string->GetIsolate();
2570 ENTER_V8(isolate);
2571 i::HandleScope scope(isolate);
2572 i::Handle<i::String> source = i::String::Flatten(string); 2547 i::Handle<i::String> source = i::String::Flatten(string);
2573 EXCEPTION_PREAMBLE(isolate); 2548 auto maybe = source->IsSeqOneByteString()
2574 i::MaybeHandle<i::Object> maybe_result = 2549 ? i::JsonParser<true>::Parse(source)
2575 source->IsSeqOneByteString() ? i::JsonParser<true>::Parse(source) 2550 : i::JsonParser<false>::Parse(source);
2576 : i::JsonParser<false>::Parse(source); 2551 Local<Value> result;
2577 i::Handle<i::Object> result; 2552 has_pending_exception = !ToLocal<Value>(maybe, &result);
2578 has_pending_exception = !maybe_result.ToHandle(&result); 2553 RETURN_ON_FAILED_EXECUTION(Value);
2579 EXCEPTION_BAILOUT_CHECK(isolate, Local<Object>()); 2554 RETURN_ESCAPED(result);
2580 return Utils::ToLocal(
2581 i::Handle<i::Object>::cast(scope.CloseAndEscape(result)));
2582 } 2555 }
2583 2556
2584 2557
2558 Local<Value> JSON::Parse(Local<String> json_string) {
2559 auto isolate = reinterpret_cast<v8::Isolate*>(
2560 Utils::OpenHandle(*json_string)->GetIsolate());
2561 RETURN_TO_LOCAL_UNCHECKED(Parse(isolate, json_string), Value);
2562 }
2563
2564
2585 // --- D a t a --- 2565 // --- D a t a ---
2586 2566
2587 bool Value::FullIsUndefined() const { 2567 bool Value::FullIsUndefined() const {
2588 bool result = Utils::OpenHandle(this)->IsUndefined(); 2568 bool result = Utils::OpenHandle(this)->IsUndefined();
2589 DCHECK_EQ(result, QuickIsUndefined()); 2569 DCHECK_EQ(result, QuickIsUndefined());
2590 return result; 2570 return result;
2591 } 2571 }
2592 2572
2593 2573
2594 bool Value::FullIsNull() const { 2574 bool Value::FullIsNull() const {
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after
3221 } 3201 }
3222 3202
3223 3203
3224 uint32_t Value::Uint32Value() const { 3204 uint32_t Value::Uint32Value() const {
3225 auto obj = Utils::OpenHandle(this); 3205 auto obj = Utils::OpenHandle(this);
3226 if (obj->IsNumber()) return NumberToUint32(*obj); 3206 if (obj->IsNumber()) return NumberToUint32(*obj);
3227 return Uint32Value(ContextFromHeapObject(obj)).FromMaybe(0); 3207 return Uint32Value(ContextFromHeapObject(obj)).FromMaybe(0);
3228 } 3208 }
3229 3209
3230 3210
3231 Local<Uint32> Value::ToArrayIndex() const { 3211 MaybeLocal<Uint32> Value::ToArrayIndex(Local<Context> context) const {
3232 i::Handle<i::Object> obj = Utils::OpenHandle(this); 3212 auto self = Utils::OpenHandle(this);
3233 if (obj->IsSmi()) { 3213 if (self->IsSmi()) {
3234 if (i::Smi::cast(*obj)->value() >= 0) return Utils::Uint32ToLocal(obj); 3214 if (i::Smi::cast(*self)->value() >= 0) return Utils::Uint32ToLocal(self);
3235 return Local<Uint32>(); 3215 return Local<Uint32>();
3236 } 3216 }
3237 i::Isolate* isolate = i::HeapObject::cast(*obj)->GetIsolate(); 3217 PREPARE_FOR_EXECUTION(context, "ToArrayIndex", Uint32);
3238 LOG_API(isolate, "ToArrayIndex");
3239 ENTER_V8(isolate);
3240 EXCEPTION_PREAMBLE(isolate);
3241 i::Handle<i::Object> string_obj; 3218 i::Handle<i::Object> string_obj;
3242 has_pending_exception = !i::Execution::ToString( 3219 has_pending_exception =
3243 isolate, obj).ToHandle(&string_obj); 3220 !i::Execution::ToString(isolate, self).ToHandle(&string_obj);
3244 EXCEPTION_BAILOUT_CHECK(isolate, Local<Uint32>()); 3221 RETURN_ON_FAILED_EXECUTION(Uint32);
3245 i::Handle<i::String> str = i::Handle<i::String>::cast(string_obj); 3222 i::Handle<i::String> str = i::Handle<i::String>::cast(string_obj);
3246 uint32_t index; 3223 uint32_t index;
3247 if (str->AsArrayIndex(&index)) { 3224 if (str->AsArrayIndex(&index)) {
3248 i::Handle<i::Object> value; 3225 i::Handle<i::Object> value;
3249 if (index <= static_cast<uint32_t>(i::Smi::kMaxValue)) { 3226 if (index <= static_cast<uint32_t>(i::Smi::kMaxValue)) {
3250 value = i::Handle<i::Object>(i::Smi::FromInt(index), isolate); 3227 value = i::Handle<i::Object>(i::Smi::FromInt(index), isolate);
3251 } else { 3228 } else {
3252 value = isolate->factory()->NewNumber(index); 3229 value = isolate->factory()->NewNumber(index);
3253 } 3230 }
3254 return Utils::Uint32ToLocal(value); 3231 RETURN_ESCAPED(Utils::Uint32ToLocal(value));
3255 } 3232 }
3256 return Local<Uint32>(); 3233 return Local<Uint32>();
3257 } 3234 }
3258 3235
3259 3236
3260 bool Value::Equals(Handle<Value> that) const { 3237 Local<Uint32> Value::ToArrayIndex() const {
3261 i::Handle<i::Object> obj = Utils::OpenHandle(this, true); 3238 auto self = Utils::OpenHandle(this);
3262 i::Handle<i::Object> other = Utils::OpenHandle(*that); 3239 if (self->IsSmi()) {
3263 if (obj->IsSmi() && other->IsSmi()) { 3240 if (i::Smi::cast(*self)->value() >= 0) return Utils::Uint32ToLocal(self);
3264 return obj->Number() == other->Number(); 3241 return Local<Uint32>();
3265 } 3242 }
3266 i::Object* ho = obj->IsSmi() ? *other : *obj; 3243 auto context = ContextFromHeapObject(self);
3267 i::Isolate* isolate = i::HeapObject::cast(ho)->GetIsolate(); 3244 RETURN_TO_LOCAL_UNCHECKED(ToArrayIndex(context), Uint32);
3268 if (!Utils::ApiCheck(!obj.is_null() && !that.IsEmpty(), 3245 }
3269 "v8::Value::Equals()", 3246
3270 "Reading from empty handle")) { 3247
3271 return false; 3248 Maybe<bool> Value::Equals(Local<Context> context, Handle<Value> that) const {
3249 auto self = Utils::OpenHandle(this);
3250 auto other = Utils::OpenHandle(*that);
3251 if (self->IsSmi() && other->IsSmi()) {
3252 return Just(self->Number() == other->Number());
3272 } 3253 }
3273 LOG_API(isolate, "Equals"); 3254 if (self->IsJSObject() && other->IsJSObject()) {
3274 ENTER_V8(isolate); 3255 return Just(*self == *other);
3275 // If both obj and other are JSObjects, we'd better compare by identity
3276 // immediately when going into JS builtin. The reason is Invoke
3277 // would overwrite global object receiver with global proxy.
3278 if (obj->IsJSObject() && other->IsJSObject()) {
3279 return *obj == *other;
3280 } 3256 }
3257 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Value::Equals()", bool);
3281 i::Handle<i::Object> args[] = { other }; 3258 i::Handle<i::Object> args[] = { other };
3282 EXCEPTION_PREAMBLE(isolate);
3283 i::Handle<i::Object> result; 3259 i::Handle<i::Object> result;
3284 has_pending_exception = 3260 has_pending_exception =
3285 !CallV8HeapFunction(isolate, "EQUALS", obj, arraysize(args), args) 3261 !CallV8HeapFunction(isolate, "EQUALS", self, arraysize(args), args)
3286 .ToHandle(&result); 3262 .ToHandle(&result);
3287 EXCEPTION_BAILOUT_CHECK(isolate, false); 3263 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool);
3288 return *result == i::Smi::FromInt(i::EQUAL); 3264 return Just(*result == i::Smi::FromInt(i::EQUAL));
3265 }
3266
3267
3268 bool Value::Equals(Handle<Value> that) const {
3269 auto self = Utils::OpenHandle(this);
3270 auto other = Utils::OpenHandle(*that);
3271 if (self->IsSmi() && other->IsSmi()) {
3272 return self->Number() == other->Number();
3273 }
3274 if (self->IsJSObject() && other->IsJSObject()) {
3275 return *self == *other;
3276 }
3277 auto heap_object = self->IsSmi() ? other : self;
3278 auto context = ContextFromHeapObject(heap_object);
3279 return Equals(context, that).FromMaybe(false);
3289 } 3280 }
3290 3281
3291 3282
3292 bool Value::StrictEquals(Handle<Value> that) const { 3283 bool Value::StrictEquals(Handle<Value> that) const {
3293 i::Handle<i::Object> obj = Utils::OpenHandle(this, true); 3284 i::Handle<i::Object> obj = Utils::OpenHandle(this);
3294 i::Handle<i::Object> other = Utils::OpenHandle(*that); 3285 i::Handle<i::Object> other = Utils::OpenHandle(*that);
3295 if (obj->IsSmi()) { 3286 if (obj->IsSmi()) {
3296 return other->IsNumber() && obj->Number() == other->Number(); 3287 return other->IsNumber() && obj->Number() == other->Number();
3297 } 3288 }
3298 i::Isolate* isolate = i::HeapObject::cast(*obj)->GetIsolate(); 3289 i::Isolate* isolate = i::HeapObject::cast(*obj)->GetIsolate();
3299 if (!Utils::ApiCheck(!obj.is_null() && !that.IsEmpty(),
3300 "v8::Value::StrictEquals()",
3301 "Reading from empty handle")) {
3302 return false;
3303 }
3304 LOG_API(isolate, "StrictEquals"); 3290 LOG_API(isolate, "StrictEquals");
3305 // Must check HeapNumber first, since NaN !== NaN. 3291 // Must check HeapNumber first, since NaN !== NaN.
3306 if (obj->IsHeapNumber()) { 3292 if (obj->IsHeapNumber()) {
3307 if (!other->IsNumber()) return false; 3293 if (!other->IsNumber()) return false;
3308 double x = obj->Number(); 3294 double x = obj->Number();
3309 double y = other->Number(); 3295 double y = other->Number();
3310 // Must check explicitly for NaN:s on Windows, but -0 works fine. 3296 // Must check explicitly for NaN:s on Windows, but -0 works fine.
3311 return x == y && !std::isnan(x) && !std::isnan(y); 3297 return x == y && !std::isnan(x) && !std::isnan(y);
3312 } else if (*obj == *other) { // Also covers Booleans. 3298 } else if (*obj == *other) { // Also covers Booleans.
3313 return true; 3299 return true;
3314 } else if (obj->IsSmi()) { 3300 } else if (obj->IsSmi()) {
3315 return other->IsNumber() && obj->Number() == other->Number(); 3301 return other->IsNumber() && obj->Number() == other->Number();
3316 } else if (obj->IsString()) { 3302 } else if (obj->IsString()) {
3317 return other->IsString() && 3303 return other->IsString() &&
3318 i::String::Equals(i::Handle<i::String>::cast(obj), 3304 i::String::Equals(i::Handle<i::String>::cast(obj),
3319 i::Handle<i::String>::cast(other)); 3305 i::Handle<i::String>::cast(other));
3320 } else if (obj->IsUndefined() || obj->IsUndetectableObject()) { 3306 } else if (obj->IsUndefined() || obj->IsUndetectableObject()) {
3321 return other->IsUndefined() || other->IsUndetectableObject(); 3307 return other->IsUndefined() || other->IsUndetectableObject();
3322 } else { 3308 } else {
3323 return false; 3309 return false;
3324 } 3310 }
3325 } 3311 }
3326 3312
3327 3313
3328 bool Value::SameValue(Handle<Value> that) const { 3314 bool Value::SameValue(Handle<Value> that) const {
3329 i::Handle<i::Object> obj = Utils::OpenHandle(this, true); 3315 auto self = Utils::OpenHandle(this);
3330 if (!Utils::ApiCheck(!obj.is_null() && !that.IsEmpty(), 3316 auto other = Utils::OpenHandle(*that);
3331 "v8::Value::SameValue()", 3317 return self->SameValue(*other);
3332 "Reading from empty handle")) {
3333 return false;
3334 }
3335 i::Handle<i::Object> other = Utils::OpenHandle(*that);
3336 return obj->SameValue(*other);
3337 } 3318 }
3338 3319
3339 3320
3340 Maybe<bool> v8::Object::Set(v8::Local<v8::Context> context, 3321 Maybe<bool> v8::Object::Set(v8::Local<v8::Context> context,
3341 v8::Local<Value> key, v8::Local<Value> value) { 3322 v8::Local<Value> key, v8::Local<Value> value) {
3342 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::Set()", bool); 3323 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::Set()", bool);
3343 auto self = Utils::OpenHandle(this); 3324 auto self = Utils::OpenHandle(this);
3344 auto key_obj = Utils::OpenHandle(*key); 3325 auto key_obj = Utils::OpenHandle(*key);
3345 auto value_obj = Utils::OpenHandle(*value); 3326 auto value_obj = Utils::OpenHandle(*value);
3346 has_pending_exception = 3327 has_pending_exception =
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after
3852 3833
3853 3834
3854 void Object::SetAccessorProperty(Local<Name> name, 3835 void Object::SetAccessorProperty(Local<Name> name,
3855 Local<Function> getter, 3836 Local<Function> getter,
3856 Handle<Function> setter, 3837 Handle<Function> setter,
3857 PropertyAttribute attribute, 3838 PropertyAttribute attribute,
3858 AccessControl settings) { 3839 AccessControl settings) {
3859 // TODO(verwaest): Remove |settings|. 3840 // TODO(verwaest): Remove |settings|.
3860 DCHECK_EQ(v8::DEFAULT, settings); 3841 DCHECK_EQ(v8::DEFAULT, settings);
3861 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 3842 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3862 ON_BAILOUT(isolate, "v8::Object::SetAccessorProperty()", return);
3863 ENTER_V8(isolate); 3843 ENTER_V8(isolate);
3864 i::HandleScope scope(isolate); 3844 i::HandleScope scope(isolate);
3865 i::Handle<i::Object> getter_i = v8::Utils::OpenHandle(*getter); 3845 i::Handle<i::Object> getter_i = v8::Utils::OpenHandle(*getter);
3866 i::Handle<i::Object> setter_i = v8::Utils::OpenHandle(*setter, true); 3846 i::Handle<i::Object> setter_i = v8::Utils::OpenHandle(*setter, true);
3867 if (setter_i.is_null()) setter_i = isolate->factory()->null_value(); 3847 if (setter_i.is_null()) setter_i = isolate->factory()->null_value();
3868 i::JSObject::DefineAccessor(v8::Utils::OpenHandle(this), 3848 i::JSObject::DefineAccessor(v8::Utils::OpenHandle(this),
3869 v8::Utils::OpenHandle(*name), 3849 v8::Utils::OpenHandle(*name),
3870 getter_i, 3850 getter_i,
3871 setter_i, 3851 setter_i,
3872 static_cast<PropertyAttributes>(attribute)); 3852 static_cast<PropertyAttributes>(attribute));
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after
4546 i::Handle<i::FixedArray> bound_args = i::Handle<i::FixedArray>( 4526 i::Handle<i::FixedArray> bound_args = i::Handle<i::FixedArray>(
4547 i::FixedArray::cast(func->function_bindings())); 4527 i::FixedArray::cast(func->function_bindings()));
4548 i::Handle<i::Object> original( 4528 i::Handle<i::Object> original(
4549 bound_args->get(i::JSFunction::kBoundFunctionIndex), 4529 bound_args->get(i::JSFunction::kBoundFunctionIndex),
4550 func->GetIsolate()); 4530 func->GetIsolate());
4551 return Utils::ToLocal(i::Handle<i::JSFunction>::cast(original)); 4531 return Utils::ToLocal(i::Handle<i::JSFunction>::cast(original));
4552 } 4532 }
4553 4533
4554 4534
4555 int Name::GetIdentityHash() { 4535 int Name::GetIdentityHash() {
4556 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 4536 auto self = Utils::OpenHandle(this);
4557 ON_BAILOUT(isolate, "v8::Name::GetIdentityHash()", return 0);
4558 ENTER_V8(isolate);
4559 i::HandleScope scope(isolate);
4560 i::Handle<i::Name> self = Utils::OpenHandle(this);
4561 return static_cast<int>(self->Hash()); 4537 return static_cast<int>(self->Hash());
4562 } 4538 }
4563 4539
4564 4540
4565 int String::Length() const { 4541 int String::Length() const {
4566 i::Handle<i::String> str = Utils::OpenHandle(this); 4542 i::Handle<i::String> str = Utils::OpenHandle(this);
4567 return str->length(); 4543 return str->length();
4568 } 4544 }
4569 4545
4570 4546
(...skipping 944 matching lines...) Expand 10 before | Expand all | Expand 10 after
5515 if (extensions == NULL) extensions = &no_extensions; 5491 if (extensions == NULL) extensions = &no_extensions;
5516 i::Handle<i::Context> env = 5492 i::Handle<i::Context> env =
5517 CreateEnvironment(isolate, extensions, global_template, global_object); 5493 CreateEnvironment(isolate, extensions, global_template, global_object);
5518 if (env.is_null()) return Local<Context>(); 5494 if (env.is_null()) return Local<Context>();
5519 return Utils::ToLocal(scope.CloseAndEscape(env)); 5495 return Utils::ToLocal(scope.CloseAndEscape(env));
5520 } 5496 }
5521 5497
5522 5498
5523 void v8::Context::SetSecurityToken(Handle<Value> token) { 5499 void v8::Context::SetSecurityToken(Handle<Value> token) {
5524 i::Handle<i::Context> env = Utils::OpenHandle(this); 5500 i::Handle<i::Context> env = Utils::OpenHandle(this);
5525 i::Isolate* isolate = env->GetIsolate();
5526 ENTER_V8(isolate);
5527 i::Handle<i::Object> token_handle = Utils::OpenHandle(*token); 5501 i::Handle<i::Object> token_handle = Utils::OpenHandle(*token);
5528 env->set_security_token(*token_handle); 5502 env->set_security_token(*token_handle);
5529 } 5503 }
5530 5504
5531 5505
5532 void v8::Context::UseDefaultSecurityToken() { 5506 void v8::Context::UseDefaultSecurityToken() {
5533 i::Handle<i::Context> env = Utils::OpenHandle(this); 5507 i::Handle<i::Context> env = Utils::OpenHandle(this);
5534 i::Isolate* isolate = env->GetIsolate();
5535 ENTER_V8(isolate);
5536 env->set_security_token(env->global_object()); 5508 env->set_security_token(env->global_object());
5537 } 5509 }
5538 5510
5539 5511
5540 Handle<Value> v8::Context::GetSecurityToken() { 5512 Handle<Value> v8::Context::GetSecurityToken() {
5541 i::Handle<i::Context> env = Utils::OpenHandle(this); 5513 i::Handle<i::Context> env = Utils::OpenHandle(this);
5542 i::Isolate* isolate = env->GetIsolate(); 5514 i::Isolate* isolate = env->GetIsolate();
5543 i::Object* security_token = env->security_token(); 5515 i::Object* security_token = env->security_token();
5544 i::Handle<i::Object> token_handle(security_token, isolate); 5516 i::Handle<i::Object> token_handle(security_token, isolate);
5545 return Utils::ToLocal(token_handle); 5517 return Utils::ToLocal(token_handle);
(...skipping 2480 matching lines...) Expand 10 before | Expand all | Expand 10 after
8026 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 7998 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
8027 Address callback_address = 7999 Address callback_address =
8028 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 8000 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
8029 VMState<EXTERNAL> state(isolate); 8001 VMState<EXTERNAL> state(isolate);
8030 ExternalCallbackScope call_scope(isolate, callback_address); 8002 ExternalCallbackScope call_scope(isolate, callback_address);
8031 callback(info); 8003 callback(info);
8032 } 8004 }
8033 8005
8034 8006
8035 } } // namespace v8::internal 8007 } } // namespace v8::internal
OLDNEW
« include/v8.h ('K') | « include/v8.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698