OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/arguments.h" | 7 #include "src/arguments.h" |
8 #include "src/bootstrapper.h" | 8 #include "src/bootstrapper.h" |
9 #include "src/debug.h" | 9 #include "src/debug.h" |
10 #include "src/runtime/runtime.h" | 10 #include "src/runtime/runtime.h" |
(...skipping 1179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1190 case JS_FUNCTION_PROXY_TYPE: | 1190 case JS_FUNCTION_PROXY_TYPE: |
1191 return isolate->heap()->function_string(); | 1191 return isolate->heap()->function_string(); |
1192 default: | 1192 default: |
1193 // For any kind of object not handled above, the spec rule for | 1193 // For any kind of object not handled above, the spec rule for |
1194 // host objects gives that it is okay to return "object" | 1194 // host objects gives that it is okay to return "object" |
1195 return isolate->heap()->object_string(); | 1195 return isolate->heap()->object_string(); |
1196 } | 1196 } |
1197 } | 1197 } |
1198 | 1198 |
1199 | 1199 |
1200 RUNTIME_FUNCTION(Runtime_Booleanize) { | |
1201 SealHandleScope shs(isolate); | |
1202 DCHECK(args.length() == 2); | |
1203 CONVERT_ARG_CHECKED(Object, value_raw, 0); | |
1204 CONVERT_SMI_ARG_CHECKED(token_raw, 1); | |
1205 intptr_t value = reinterpret_cast<intptr_t>(value_raw); | |
1206 Token::Value token = static_cast<Token::Value>(token_raw); | |
1207 switch (token) { | |
1208 case Token::EQ: | |
1209 case Token::EQ_STRICT: | |
1210 return isolate->heap()->ToBoolean(value == 0); | |
1211 case Token::NE: | |
1212 case Token::NE_STRICT: | |
1213 return isolate->heap()->ToBoolean(value != 0); | |
1214 case Token::LT: | |
1215 return isolate->heap()->ToBoolean(value < 0); | |
1216 case Token::GT: | |
1217 return isolate->heap()->ToBoolean(value > 0); | |
1218 case Token::LTE: | |
1219 return isolate->heap()->ToBoolean(value <= 0); | |
1220 case Token::GTE: | |
1221 return isolate->heap()->ToBoolean(value >= 0); | |
1222 default: | |
1223 // This should only happen during natives fuzzing. | |
1224 return isolate->heap()->undefined_value(); | |
1225 } | |
1226 } | |
1227 | |
1228 | |
1229 RUNTIME_FUNCTION(Runtime_NewStringWrapper) { | 1200 RUNTIME_FUNCTION(Runtime_NewStringWrapper) { |
1230 HandleScope scope(isolate); | 1201 HandleScope scope(isolate); |
1231 DCHECK(args.length() == 1); | 1202 DCHECK(args.length() == 1); |
1232 CONVERT_ARG_HANDLE_CHECKED(String, value, 0); | 1203 CONVERT_ARG_HANDLE_CHECKED(String, value, 0); |
1233 return *Object::ToObject(isolate, value).ToHandleChecked(); | 1204 return *Object::ToObject(isolate, value).ToHandleChecked(); |
1234 } | 1205 } |
1235 | 1206 |
1236 | 1207 |
1237 RUNTIME_FUNCTION(Runtime_AllocateHeapNumber) { | 1208 RUNTIME_FUNCTION(Runtime_AllocateHeapNumber) { |
1238 HandleScope scope(isolate); | 1209 HandleScope scope(isolate); |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1611 CONVERT_PROPERTY_ATTRIBUTES_CHECKED(attrs, 3); | 1582 CONVERT_PROPERTY_ATTRIBUTES_CHECKED(attrs, 3); |
1612 | 1583 |
1613 RETURN_FAILURE_ON_EXCEPTION( | 1584 RETURN_FAILURE_ON_EXCEPTION( |
1614 isolate, | 1585 isolate, |
1615 JSObject::DefineAccessor(object, name, isolate->factory()->null_value(), | 1586 JSObject::DefineAccessor(object, name, isolate->factory()->null_value(), |
1616 setter, attrs)); | 1587 setter, attrs)); |
1617 return isolate->heap()->undefined_value(); | 1588 return isolate->heap()->undefined_value(); |
1618 } | 1589 } |
1619 } | 1590 } |
1620 } // namespace v8::internal | 1591 } // namespace v8::internal |
OLD | NEW |