| OLD | NEW | 
|     1 // Copyright 2011 the V8 project authors. All rights reserved. |     1 // Copyright 2011 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 2156 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  2167  |  2167  | 
|  2168  |  2168  | 
|  2169 bool Value::IsDate() const { |  2169 bool Value::IsDate() const { | 
|  2170   i::Isolate* isolate = i::Isolate::Current(); |  2170   i::Isolate* isolate = i::Isolate::Current(); | 
|  2171   if (IsDeadCheck(isolate, "v8::Value::IsDate()")) return false; |  2171   if (IsDeadCheck(isolate, "v8::Value::IsDate()")) return false; | 
|  2172   i::Handle<i::Object> obj = Utils::OpenHandle(this); |  2172   i::Handle<i::Object> obj = Utils::OpenHandle(this); | 
|  2173   return obj->HasSpecificClassOf(isolate->heap()->Date_symbol()); |  2173   return obj->HasSpecificClassOf(isolate->heap()->Date_symbol()); | 
|  2174 } |  2174 } | 
|  2175  |  2175  | 
|  2176  |  2176  | 
 |  2177 bool Value::IsStringObject() const { | 
 |  2178   i::Isolate* isolate = i::Isolate::Current(); | 
 |  2179   if (IsDeadCheck(isolate, "v8::Value::IsStringObject()")) return false; | 
 |  2180   i::Handle<i::Object> obj = Utils::OpenHandle(this); | 
 |  2181   return obj->HasSpecificClassOf(isolate->heap()->String_symbol()); | 
 |  2182 } | 
 |  2183  | 
 |  2184  | 
 |  2185 bool Value::IsNumberObject() const { | 
 |  2186   i::Isolate* isolate = i::Isolate::Current(); | 
 |  2187   if (IsDeadCheck(isolate, "v8::Value::IsNumberObject()")) return false; | 
 |  2188   i::Handle<i::Object> obj = Utils::OpenHandle(this); | 
 |  2189   return obj->HasSpecificClassOf(isolate->heap()->Number_symbol()); | 
 |  2190 } | 
 |  2191  | 
 |  2192  | 
 |  2193 static i::Object* LookupBuiltin(i::Isolate* isolate, | 
 |  2194                                 const char* builtin_name) { | 
 |  2195   i::Handle<i::String> symbol = | 
 |  2196       isolate->factory()->LookupAsciiSymbol(builtin_name); | 
 |  2197   i::Handle<i::JSBuiltinsObject> builtins = isolate->js_builtins_object(); | 
 |  2198   return builtins->GetPropertyNoExceptionThrown(*symbol); | 
 |  2199 } | 
 |  2200  | 
 |  2201  | 
 |  2202 static bool CheckConstructor(i::Isolate* isolate, | 
 |  2203                              i::Handle<i::JSObject> obj, | 
 |  2204                              const char* class_name) { | 
 |  2205   return obj->map()->constructor() == LookupBuiltin(isolate, class_name); | 
 |  2206 } | 
 |  2207  | 
 |  2208  | 
 |  2209 bool Value::IsNativeError() const { | 
 |  2210   i::Isolate* isolate = i::Isolate::Current(); | 
 |  2211   if (IsDeadCheck(isolate, "v8::Value::IsNativeError()")) return false; | 
 |  2212   i::Handle<i::Object> obj = Utils::OpenHandle(this); | 
 |  2213   if (obj->IsJSObject()) { | 
 |  2214     i::Handle<i::JSObject> js_obj(i::JSObject::cast(*obj)); | 
 |  2215     return CheckConstructor(isolate, js_obj, "$Error") || | 
 |  2216         CheckConstructor(isolate, js_obj, "$EvalError") || | 
 |  2217         CheckConstructor(isolate, js_obj, "$RangeError") || | 
 |  2218         CheckConstructor(isolate, js_obj, "$ReferenceError") || | 
 |  2219         CheckConstructor(isolate, js_obj, "$SyntaxError") || | 
 |  2220         CheckConstructor(isolate, js_obj, "$TypeError") || | 
 |  2221         CheckConstructor(isolate, js_obj, "$URIError"); | 
 |  2222   } else { | 
 |  2223     return false; | 
 |  2224   } | 
 |  2225 } | 
 |  2226  | 
 |  2227  | 
 |  2228 bool Value::IsBooleanObject() const { | 
 |  2229   i::Isolate* isolate = i::Isolate::Current(); | 
 |  2230   if (IsDeadCheck(isolate, "v8::Value::IsBooleanObject()")) return false; | 
 |  2231   i::Handle<i::Object> obj = Utils::OpenHandle(this); | 
 |  2232   return obj->HasSpecificClassOf(isolate->heap()->Boolean_symbol()); | 
 |  2233 } | 
 |  2234  | 
 |  2235  | 
|  2177 bool Value::IsRegExp() const { |  2236 bool Value::IsRegExp() const { | 
|  2178   if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsRegExp()")) return false; |  2237   if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsRegExp()")) return false; | 
|  2179   i::Handle<i::Object> obj = Utils::OpenHandle(this); |  2238   i::Handle<i::Object> obj = Utils::OpenHandle(this); | 
|  2180   return obj->IsJSRegExp(); |  2239   return obj->IsJSRegExp(); | 
|  2181 } |  2240 } | 
|  2182  |  2241  | 
|  2183  |  2242  | 
|  2184 Local<String> Value::ToString() const { |  2243 Local<String> Value::ToString() const { | 
|  2185   i::Handle<i::Object> obj = Utils::OpenHandle(this); |  2244   i::Handle<i::Object> obj = Utils::OpenHandle(this); | 
|  2186   i::Handle<i::Object> str; |  2245   i::Handle<i::Object> str; | 
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  2362 void v8::Date::CheckCast(v8::Value* that) { |  2421 void v8::Date::CheckCast(v8::Value* that) { | 
|  2363   i::Isolate* isolate = i::Isolate::Current(); |  2422   i::Isolate* isolate = i::Isolate::Current(); | 
|  2364   if (IsDeadCheck(isolate, "v8::Date::Cast()")) return; |  2423   if (IsDeadCheck(isolate, "v8::Date::Cast()")) return; | 
|  2365   i::Handle<i::Object> obj = Utils::OpenHandle(that); |  2424   i::Handle<i::Object> obj = Utils::OpenHandle(that); | 
|  2366   ApiCheck(obj->HasSpecificClassOf(isolate->heap()->Date_symbol()), |  2425   ApiCheck(obj->HasSpecificClassOf(isolate->heap()->Date_symbol()), | 
|  2367            "v8::Date::Cast()", |  2426            "v8::Date::Cast()", | 
|  2368            "Could not convert to date"); |  2427            "Could not convert to date"); | 
|  2369 } |  2428 } | 
|  2370  |  2429  | 
|  2371  |  2430  | 
 |  2431 void v8::StringObject::CheckCast(v8::Value* that) { | 
 |  2432   i::Isolate* isolate = i::Isolate::Current(); | 
 |  2433   if (IsDeadCheck(isolate, "v8::StringObject::Cast()")) return; | 
 |  2434   i::Handle<i::Object> obj = Utils::OpenHandle(that); | 
 |  2435   ApiCheck(obj->HasSpecificClassOf(isolate->heap()->String_symbol()), | 
 |  2436            "v8::StringObject::Cast()", | 
 |  2437            "Could not convert to StringObject"); | 
 |  2438 } | 
 |  2439  | 
 |  2440  | 
 |  2441 void v8::NumberObject::CheckCast(v8::Value* that) { | 
 |  2442   i::Isolate* isolate = i::Isolate::Current(); | 
 |  2443   if (IsDeadCheck(isolate, "v8::NumberObject::Cast()")) return; | 
 |  2444   i::Handle<i::Object> obj = Utils::OpenHandle(that); | 
 |  2445   ApiCheck(obj->HasSpecificClassOf(isolate->heap()->Number_symbol()), | 
 |  2446            "v8::NumberObject::Cast()", | 
 |  2447            "Could not convert to NumberObject"); | 
 |  2448 } | 
 |  2449  | 
 |  2450  | 
 |  2451 void v8::BooleanObject::CheckCast(v8::Value* that) { | 
 |  2452   i::Isolate* isolate = i::Isolate::Current(); | 
 |  2453   if (IsDeadCheck(isolate, "v8::BooleanObject::Cast()")) return; | 
 |  2454   i::Handle<i::Object> obj = Utils::OpenHandle(that); | 
 |  2455   ApiCheck(obj->HasSpecificClassOf(isolate->heap()->Boolean_symbol()), | 
 |  2456            "v8::BooleanObject::Cast()", | 
 |  2457            "Could not convert to BooleanObject"); | 
 |  2458 } | 
 |  2459  | 
 |  2460  | 
|  2372 void v8::RegExp::CheckCast(v8::Value* that) { |  2461 void v8::RegExp::CheckCast(v8::Value* that) { | 
|  2373   if (IsDeadCheck(i::Isolate::Current(), "v8::RegExp::Cast()")) return; |  2462   if (IsDeadCheck(i::Isolate::Current(), "v8::RegExp::Cast()")) return; | 
|  2374   i::Handle<i::Object> obj = Utils::OpenHandle(that); |  2463   i::Handle<i::Object> obj = Utils::OpenHandle(that); | 
|  2375   ApiCheck(obj->IsJSRegExp(), |  2464   ApiCheck(obj->IsJSRegExp(), | 
|  2376            "v8::RegExp::Cast()", |  2465            "v8::RegExp::Cast()", | 
|  2377            "Could not convert to regular expression"); |  2466            "Could not convert to regular expression"); | 
|  2378 } |  2467 } | 
|  2379  |  2468  | 
|  2380  |  2469  | 
|  2381 bool Value::BooleanValue() const { |  2470 bool Value::BooleanValue() const { | 
| (...skipping 2013 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  4395   i::Isolate* isolate = i::Isolate::Current(); |  4484   i::Isolate* isolate = i::Isolate::Current(); | 
|  4396   EnsureInitializedForIsolate(isolate, "v8::Object::New()"); |  4485   EnsureInitializedForIsolate(isolate, "v8::Object::New()"); | 
|  4397   LOG_API(isolate, "Object::New"); |  4486   LOG_API(isolate, "Object::New"); | 
|  4398   ENTER_V8(isolate); |  4487   ENTER_V8(isolate); | 
|  4399   i::Handle<i::JSObject> obj = |  4488   i::Handle<i::JSObject> obj = | 
|  4400       isolate->factory()->NewJSObject(isolate->object_function()); |  4489       isolate->factory()->NewJSObject(isolate->object_function()); | 
|  4401   return Utils::ToLocal(obj); |  4490   return Utils::ToLocal(obj); | 
|  4402 } |  4491 } | 
|  4403  |  4492  | 
|  4404  |  4493  | 
 |  4494 Local<v8::Value> v8::NumberObject::New(double value) { | 
 |  4495   i::Isolate* isolate = i::Isolate::Current(); | 
 |  4496   EnsureInitializedForIsolate(isolate, "v8::NumberObject::New()"); | 
 |  4497   LOG_API(isolate, "NumberObject::New"); | 
 |  4498   ENTER_V8(isolate); | 
 |  4499   i::Handle<i::Object> number = isolate->factory()->NewNumber(value); | 
 |  4500   i::Handle<i::Object> obj = isolate->factory()->ToObject(number); | 
 |  4501   return Utils::ToLocal(obj); | 
 |  4502 } | 
 |  4503  | 
 |  4504  | 
 |  4505 double v8::NumberObject::NumberValue() const { | 
 |  4506   i::Isolate* isolate = i::Isolate::Current(); | 
 |  4507   if (IsDeadCheck(isolate, "v8::NumberObject::NumberValue()")) return 0; | 
 |  4508   LOG_API(isolate, "NumberObject::NumberValue"); | 
 |  4509   i::Handle<i::Object> obj = Utils::OpenHandle(this); | 
 |  4510   i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); | 
 |  4511   return jsvalue->value()->Number(); | 
 |  4512 } | 
 |  4513  | 
 |  4514  | 
 |  4515 Local<v8::Value> v8::BooleanObject::New(bool value) { | 
 |  4516   i::Isolate* isolate = i::Isolate::Current(); | 
 |  4517   EnsureInitializedForIsolate(isolate, "v8::BooleanObject::New()"); | 
 |  4518   LOG_API(isolate, "BooleanObject::New"); | 
 |  4519   ENTER_V8(isolate); | 
 |  4520   i::Handle<i::Object> boolean(value ? isolate->heap()->true_value() | 
 |  4521                                      : isolate->heap()->false_value()); | 
 |  4522   i::Handle<i::Object> obj = isolate->factory()->ToObject(boolean); | 
 |  4523   return Utils::ToLocal(obj); | 
 |  4524 } | 
 |  4525  | 
 |  4526  | 
 |  4527 bool v8::BooleanObject::BooleanValue() const { | 
 |  4528   i::Isolate* isolate = i::Isolate::Current(); | 
 |  4529   if (IsDeadCheck(isolate, "v8::BooleanObject::BooleanValue()")) return 0; | 
 |  4530   LOG_API(isolate, "BooleanObject::BooleanValue"); | 
 |  4531   i::Handle<i::Object> obj = Utils::OpenHandle(this); | 
 |  4532   i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); | 
 |  4533   return jsvalue->value()->IsTrue(); | 
 |  4534 } | 
 |  4535  | 
 |  4536  | 
 |  4537 Local<v8::Value> v8::StringObject::New(Handle<String> value) { | 
 |  4538   i::Isolate* isolate = i::Isolate::Current(); | 
 |  4539   EnsureInitializedForIsolate(isolate, "v8::StringObject::New()"); | 
 |  4540   LOG_API(isolate, "StringObject::New"); | 
 |  4541   ENTER_V8(isolate); | 
 |  4542   i::Handle<i::Object> obj = | 
 |  4543       isolate->factory()->ToObject(Utils::OpenHandle(*value)); | 
 |  4544   return Utils::ToLocal(obj); | 
 |  4545 } | 
 |  4546  | 
 |  4547  | 
 |  4548 Local<v8::String> v8::StringObject::StringValue() const { | 
 |  4549   i::Isolate* isolate = i::Isolate::Current(); | 
 |  4550   if (IsDeadCheck(isolate, "v8::StringObject::StringValue()")) { | 
 |  4551     return Local<v8::String>(); | 
 |  4552   } | 
 |  4553   LOG_API(isolate, "StringObject::StringValue"); | 
 |  4554   i::Handle<i::Object> obj = Utils::OpenHandle(this); | 
 |  4555   i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); | 
 |  4556   return Utils::ToLocal( | 
 |  4557       i::Handle<i::String>(i::String::cast(jsvalue->value()))); | 
 |  4558 } | 
 |  4559  | 
 |  4560  | 
|  4405 Local<v8::Value> v8::Date::New(double time) { |  4561 Local<v8::Value> v8::Date::New(double time) { | 
|  4406   i::Isolate* isolate = i::Isolate::Current(); |  4562   i::Isolate* isolate = i::Isolate::Current(); | 
|  4407   EnsureInitializedForIsolate(isolate, "v8::Date::New()"); |  4563   EnsureInitializedForIsolate(isolate, "v8::Date::New()"); | 
|  4408   LOG_API(isolate, "Date::New"); |  4564   LOG_API(isolate, "Date::New"); | 
|  4409   if (isnan(time)) { |  4565   if (isnan(time)) { | 
|  4410     // Introduce only canonical NaN value into the VM, to avoid signaling NaNs. |  4566     // Introduce only canonical NaN value into the VM, to avoid signaling NaNs. | 
|  4411     time = i::OS::nan_value(); |  4567     time = i::OS::nan_value(); | 
|  4412   } |  4568   } | 
|  4413   ENTER_V8(isolate); |  4569   ENTER_V8(isolate); | 
|  4414   EXCEPTION_PREAMBLE(isolate); |  4570   EXCEPTION_PREAMBLE(isolate); | 
| (...skipping 1651 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  6066  |  6222  | 
|  6067  |  6223  | 
|  6068 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { |  6224 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { | 
|  6069   HandleScopeImplementer* scope_implementer = |  6225   HandleScopeImplementer* scope_implementer = | 
|  6070       reinterpret_cast<HandleScopeImplementer*>(storage); |  6226       reinterpret_cast<HandleScopeImplementer*>(storage); | 
|  6071   scope_implementer->IterateThis(v); |  6227   scope_implementer->IterateThis(v); | 
|  6072   return storage + ArchiveSpacePerThread(); |  6228   return storage + ArchiveSpacePerThread(); | 
|  6073 } |  6229 } | 
|  6074  |  6230  | 
|  6075 } }  // namespace v8::internal |  6231 } }  // namespace v8::internal | 
| OLD | NEW |