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

Side by Side Diff: src/api.cc

Issue 662413002: Move some Runtime:: functions and remove runtime.h as include when unnecessary. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 2 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 | « no previous file | src/runtime/runtime.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // 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 3155 matching lines...) Expand 10 before | Expand all | Expand 10 after
3166 return true; 3166 return true;
3167 } 3167 }
3168 3168
3169 3169
3170 bool v8::Object::SetPrivate(v8::Handle<Private> key, v8::Handle<Value> value) { 3170 bool v8::Object::SetPrivate(v8::Handle<Private> key, v8::Handle<Value> value) {
3171 return ForceSet(v8::Handle<Value>(reinterpret_cast<Value*>(*key)), 3171 return ForceSet(v8::Handle<Value>(reinterpret_cast<Value*>(*key)),
3172 value, DontEnum); 3172 value, DontEnum);
3173 } 3173 }
3174 3174
3175 3175
3176 i::MaybeHandle<i::Object> DeleteObjectProperty(
3177 i::Isolate* isolate, i::Handle<i::JSReceiver> receiver,
3178 i::Handle<i::Object> key, i::JSReceiver::DeleteMode mode) {
3179 // Check if the given key is an array index.
3180 uint32_t index;
3181 if (key->ToArrayIndex(&index)) {
3182 // In Firefox/SpiderMonkey, Safari and Opera you can access the
3183 // characters of a string using [] notation. In the case of a
3184 // String object we just need to redirect the deletion to the
3185 // underlying string if the index is in range. Since the
3186 // underlying string does nothing with the deletion, we can ignore
3187 // such deletions.
3188 if (receiver->IsStringObjectWithCharacterAt(index)) {
3189 return isolate->factory()->true_value();
3190 }
3191
3192 return i::JSReceiver::DeleteElement(receiver, index, mode);
3193 }
3194
3195 i::Handle<i::Name> name;
3196 if (key->IsName()) {
3197 name = i::Handle<i::Name>::cast(key);
3198 } else {
3199 // Call-back into JavaScript to convert the key to a string.
3200 i::Handle<i::Object> converted;
3201 if (!i::Execution::ToString(isolate, key).ToHandle(&converted)) {
3202 return i::MaybeHandle<i::Object>();
3203 }
3204 name = i::Handle<i::String>::cast(converted);
3205 }
3206
3207 if (name->IsString()) {
3208 name = i::String::Flatten(i::Handle<i::String>::cast(name));
3209 }
3210 return i::JSReceiver::DeleteProperty(receiver, name, mode);
3211 }
3212
3213
3176 bool v8::Object::ForceDelete(v8::Handle<Value> key) { 3214 bool v8::Object::ForceDelete(v8::Handle<Value> key) {
3177 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 3215 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3178 ON_BAILOUT(isolate, "v8::Object::ForceDelete()", return false); 3216 ON_BAILOUT(isolate, "v8::Object::ForceDelete()", return false);
3179 ENTER_V8(isolate); 3217 ENTER_V8(isolate);
3180 i::HandleScope scope(isolate); 3218 i::HandleScope scope(isolate);
3181 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 3219 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
3182 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); 3220 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key);
3183 3221
3184 // When deleting a property on the global object using ForceDelete 3222 // When deleting a property on the global object using ForceDelete
3185 // deoptimize all functions as optimized code does not check for the hole 3223 // deoptimize all functions as optimized code does not check for the hole
3186 // value with DontDelete properties. We have to deoptimize all contexts 3224 // value with DontDelete properties. We have to deoptimize all contexts
3187 // because of possible cross-context inlined functions. 3225 // because of possible cross-context inlined functions.
3188 if (self->IsJSGlobalProxy() || self->IsGlobalObject()) { 3226 if (self->IsJSGlobalProxy() || self->IsGlobalObject()) {
3189 i::Deoptimizer::DeoptimizeAll(isolate); 3227 i::Deoptimizer::DeoptimizeAll(isolate);
3190 } 3228 }
3191 3229
3192 EXCEPTION_PREAMBLE(isolate); 3230 EXCEPTION_PREAMBLE(isolate);
3193 i::Handle<i::Object> obj; 3231 i::Handle<i::Object> obj;
3194 has_pending_exception = !i::Runtime::DeleteObjectProperty( 3232 has_pending_exception =
3195 isolate, self, key_obj, i::JSReceiver::FORCE_DELETION).ToHandle(&obj); 3233 !DeleteObjectProperty(isolate, self, key_obj,
3234 i::JSReceiver::FORCE_DELETION).ToHandle(&obj);
3196 EXCEPTION_BAILOUT_CHECK(isolate, false); 3235 EXCEPTION_BAILOUT_CHECK(isolate, false);
3197 return obj->IsTrue(); 3236 return obj->IsTrue();
3198 } 3237 }
3199 3238
3200 3239
3201 Local<Value> v8::Object::Get(v8::Handle<Value> key) { 3240 Local<Value> v8::Object::Get(v8::Handle<Value> key) {
3202 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 3241 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3203 ON_BAILOUT(isolate, "v8::Object::Get()", return Local<v8::Value>()); 3242 ON_BAILOUT(isolate, "v8::Object::Get()", return Local<v8::Value>());
3204 ENTER_V8(isolate); 3243 ENTER_V8(isolate);
3205 i::Handle<i::Object> self = Utils::OpenHandle(this); 3244 i::Handle<i::Object> self = Utils::OpenHandle(this);
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
3438 3477
3439 bool v8::Object::Delete(v8::Handle<Value> key) { 3478 bool v8::Object::Delete(v8::Handle<Value> key) {
3440 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 3479 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3441 ON_BAILOUT(isolate, "v8::Object::Delete()", return false); 3480 ON_BAILOUT(isolate, "v8::Object::Delete()", return false);
3442 ENTER_V8(isolate); 3481 ENTER_V8(isolate);
3443 i::HandleScope scope(isolate); 3482 i::HandleScope scope(isolate);
3444 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 3483 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
3445 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); 3484 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key);
3446 EXCEPTION_PREAMBLE(isolate); 3485 EXCEPTION_PREAMBLE(isolate);
3447 i::Handle<i::Object> obj; 3486 i::Handle<i::Object> obj;
3448 has_pending_exception = !i::Runtime::DeleteObjectProperty( 3487 has_pending_exception =
3449 isolate, self, key_obj, i::JSReceiver::NORMAL_DELETION).ToHandle(&obj); 3488 !DeleteObjectProperty(isolate, self, key_obj,
3489 i::JSReceiver::NORMAL_DELETION).ToHandle(&obj);
3450 EXCEPTION_BAILOUT_CHECK(isolate, false); 3490 EXCEPTION_BAILOUT_CHECK(isolate, false);
3451 return obj->IsTrue(); 3491 return obj->IsTrue();
3452 } 3492 }
3453 3493
3454 3494
3455 bool v8::Object::DeletePrivate(v8::Handle<Private> key) { 3495 bool v8::Object::DeletePrivate(v8::Handle<Private> key) {
3456 return Delete(v8::Handle<Value>(reinterpret_cast<Value*>(*key))); 3496 return Delete(v8::Handle<Value>(reinterpret_cast<Value*>(*key)));
3457 } 3497 }
3458 3498
3459 3499
3460 bool v8::Object::Has(v8::Handle<Value> key) { 3500 bool v8::Object::Has(v8::Handle<Value> key) {
3461 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 3501 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3462 ON_BAILOUT(isolate, "v8::Object::Has()", return false); 3502 ON_BAILOUT(isolate, "v8::Object::Has()", return false);
3463 ENTER_V8(isolate); 3503 ENTER_V8(isolate);
3464 i::Handle<i::JSReceiver> self = Utils::OpenHandle(this); 3504 i::Handle<i::JSReceiver> self = Utils::OpenHandle(this);
3465 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); 3505 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key);
3466 EXCEPTION_PREAMBLE(isolate); 3506 EXCEPTION_PREAMBLE(isolate);
3467 i::Handle<i::Object> obj; 3507 Maybe<bool> maybe;
3468 has_pending_exception = !i::Runtime::HasObjectProperty( 3508 // Check if the given key is an array index.
3469 isolate, self, key_obj).ToHandle(&obj); 3509 uint32_t index;
3510 if (key_obj->ToArrayIndex(&index)) {
3511 maybe = i::JSReceiver::HasElement(self, index);
3512 } else {
3513 // Convert the key to a name - possibly by calling back into JavaScript.
3514 i::Handle<i::Name> name;
3515 if (i::Runtime::ToName(isolate, key_obj).ToHandle(&name)) {
3516 maybe = i::JSReceiver::HasProperty(self, name);
3517 }
3518 }
3519 if (!maybe.has_value) has_pending_exception = true;
3470 EXCEPTION_BAILOUT_CHECK(isolate, false); 3520 EXCEPTION_BAILOUT_CHECK(isolate, false);
3471 return obj->IsTrue(); 3521 DCHECK(maybe.has_value);
3522 return maybe.value;
3472 } 3523 }
3473 3524
3474 3525
3475 bool v8::Object::HasPrivate(v8::Handle<Private> key) { 3526 bool v8::Object::HasPrivate(v8::Handle<Private> key) {
3476 // TODO(rossberg): this should use HasOwnProperty, but we'd need to 3527 // TODO(rossberg): this should use HasOwnProperty, but we'd need to
3477 // generalise that to a (noy yet existant) Name argument first. 3528 // generalise that to a (noy yet existant) Name argument first.
3478 return Has(v8::Handle<Value>(reinterpret_cast<Value*>(*key))); 3529 return Has(v8::Handle<Value>(reinterpret_cast<Value*>(*key)));
3479 } 3530 }
3480 3531
3481 3532
(...skipping 4179 matching lines...) Expand 10 before | Expand all | Expand 10 after
7661 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 7712 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
7662 Address callback_address = 7713 Address callback_address =
7663 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 7714 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
7664 VMState<EXTERNAL> state(isolate); 7715 VMState<EXTERNAL> state(isolate);
7665 ExternalCallbackScope call_scope(isolate, callback_address); 7716 ExternalCallbackScope call_scope(isolate, callback_address);
7666 callback(info); 7717 callback(info);
7667 } 7718 }
7668 7719
7669 7720
7670 } } // namespace v8::internal 7721 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/runtime/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698