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

Side by Side Diff: src/runtime.cc

Issue 3043060: [Isolates] Replace ISOLATE_FROM_HEAP with Heap::isolate() (Closed)
Patch Set: Created 10 years, 4 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
« no previous file with comments | « src/isolate.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 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 // Call the specified converter on the object *comand store the result in 96 // Call the specified converter on the object *comand store the result in
97 // a variable of the specified type with the given name. If the 97 // a variable of the specified type with the given name. If the
98 // object is not a Number call IllegalOperation and return. 98 // object is not a Number call IllegalOperation and return.
99 #define CONVERT_NUMBER_CHECKED(type, name, Type, obj) \ 99 #define CONVERT_NUMBER_CHECKED(type, name, Type, obj) \
100 RUNTIME_ASSERT(obj->IsNumber()); \ 100 RUNTIME_ASSERT(obj->IsNumber()); \
101 type name = NumberTo##Type(obj); 101 type name = NumberTo##Type(obj);
102 102
103 103
104 static Object* DeepCopyBoilerplate(Heap* heap, JSObject* boilerplate) { 104 static Object* DeepCopyBoilerplate(Heap* heap, JSObject* boilerplate) {
105 StackLimitCheck check; 105 StackLimitCheck check;
106 if (check.HasOverflowed()) return ISOLATE_FROM_HEAP(heap)->StackOverflow(); 106 if (check.HasOverflowed()) return heap->isolate()->StackOverflow();
107 107
108 Object* result = heap->CopyJSObject(boilerplate); 108 Object* result = heap->CopyJSObject(boilerplate);
109 if (result->IsFailure()) return result; 109 if (result->IsFailure()) return result;
110 JSObject* copy = JSObject::cast(result); 110 JSObject* copy = JSObject::cast(result);
111 111
112 // Deep copy local properties. 112 // Deep copy local properties.
113 if (copy->HasFastProperties()) { 113 if (copy->HasFastProperties()) {
114 FixedArray* properties = copy->properties(); 114 FixedArray* properties = copy->properties();
115 for (int i = 0; i < properties->length(); i++) { 115 for (int i = 0; i < properties->length(); i++) {
116 Object* value = properties->get(i); 116 Object* value = properties->get(i);
(...skipping 3813 matching lines...) Expand 10 before | Expand all | Expand 10 after
3930 Object* Runtime::GetObjectProperty(Heap* heap, 3930 Object* Runtime::GetObjectProperty(Heap* heap,
3931 Handle<Object> object, 3931 Handle<Object> object,
3932 Handle<Object> key) { 3932 Handle<Object> key) {
3933 HandleScope scope; 3933 HandleScope scope;
3934 3934
3935 if (object->IsUndefined() || object->IsNull()) { 3935 if (object->IsUndefined() || object->IsNull()) {
3936 Handle<Object> args[2] = { key, object }; 3936 Handle<Object> args[2] = { key, object };
3937 Handle<Object> error = 3937 Handle<Object> error =
3938 Factory::NewTypeError("non_object_property_load", 3938 Factory::NewTypeError("non_object_property_load",
3939 HandleVector(args, 2)); 3939 HandleVector(args, 2));
3940 return ISOLATE_FROM_HEAP(heap)->Throw(*error); 3940 return heap->isolate()->Throw(*error);
3941 } 3941 }
3942 3942
3943 // Check if the given key is an array index. 3943 // Check if the given key is an array index.
3944 uint32_t index; 3944 uint32_t index;
3945 if (key->ToArrayIndex(&index)) { 3945 if (key->ToArrayIndex(&index)) {
3946 return GetElementOrCharAt(heap, object, index); 3946 return GetElementOrCharAt(heap, object, index);
3947 } 3947 }
3948 3948
3949 // Convert the key to a string - possibly by calling back into JavaScript. 3949 // Convert the key to a string - possibly by calling back into JavaScript.
3950 Handle<String> name; 3950 Handle<String> name;
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
4140 Handle<Object> key, 4140 Handle<Object> key,
4141 Handle<Object> value, 4141 Handle<Object> value,
4142 PropertyAttributes attr) { 4142 PropertyAttributes attr) {
4143 HandleScope scope; 4143 HandleScope scope;
4144 4144
4145 if (object->IsUndefined() || object->IsNull()) { 4145 if (object->IsUndefined() || object->IsNull()) {
4146 Handle<Object> args[2] = { key, object }; 4146 Handle<Object> args[2] = { key, object };
4147 Handle<Object> error = 4147 Handle<Object> error =
4148 Factory::NewTypeError("non_object_property_store", 4148 Factory::NewTypeError("non_object_property_store",
4149 HandleVector(args, 2)); 4149 HandleVector(args, 2));
4150 return ISOLATE_FROM_HEAP(heap)->Throw(*error); 4150 return heap->isolate()->Throw(*error);
4151 } 4151 }
4152 4152
4153 // If the object isn't a JavaScript object, we ignore the store. 4153 // If the object isn't a JavaScript object, we ignore the store.
4154 if (!object->IsJSObject()) return *value; 4154 if (!object->IsJSObject()) return *value;
4155 4155
4156 Handle<JSObject> js_object = Handle<JSObject>::cast(object); 4156 Handle<JSObject> js_object = Handle<JSObject>::cast(object);
4157 4157
4158 // Check if the given key is an array index. 4158 // Check if the given key is an array index.
4159 uint32_t index; 4159 uint32_t index;
4160 if (key->ToArrayIndex(&index)) { 4160 if (key->ToArrayIndex(&index)) {
(...skipping 1033 matching lines...) Expand 10 before | Expand all | Expand 10 after
5194 while (buffer->has_more()) { 5194 while (buffer->has_more()) {
5195 current = buffer->GetNext(); 5195 current = buffer->GetNext();
5196 // NOTE: we use 0 as the next character here because, while 5196 // NOTE: we use 0 as the next character here because, while
5197 // the next character may affect what a character converts to, 5197 // the next character may affect what a character converts to,
5198 // it does not in any case affect the length of what it convert 5198 // it does not in any case affect the length of what it convert
5199 // to. 5199 // to.
5200 int char_length = mapping->get(current, 0, chars); 5200 int char_length = mapping->get(current, 0, chars);
5201 if (char_length == 0) char_length = 1; 5201 if (char_length == 0) char_length = 1;
5202 current_length += char_length; 5202 current_length += char_length;
5203 if (current_length > Smi::kMaxValue) { 5203 if (current_length > Smi::kMaxValue) {
5204 ISOLATE_FROM_HEAP(heap)->context()->mark_out_of_memory(); 5204 heap->isolate()->context()->mark_out_of_memory();
5205 return Failure::OutOfMemoryException(); 5205 return Failure::OutOfMemoryException();
5206 } 5206 }
5207 } 5207 }
5208 // Try again with the real length. 5208 // Try again with the real length.
5209 return Smi::FromInt(current_length); 5209 return Smi::FromInt(current_length);
5210 } else { 5210 } else {
5211 for (int j = 0; j < char_length; j++) { 5211 for (int j = 0; j < char_length; j++) {
5212 result->Set(i, chars[j]); 5212 result->Set(i, chars[j]);
5213 i++; 5213 i++;
5214 } 5214 }
(...skipping 1868 matching lines...) Expand 10 before | Expand all | Expand 10 after
7083 // Convert the object to a proper JavaScript object. 7083 // Convert the object to a proper JavaScript object.
7084 Object* js_object = object; 7084 Object* js_object = object;
7085 if (!js_object->IsJSObject()) { 7085 if (!js_object->IsJSObject()) {
7086 js_object = js_object->ToObject(); 7086 js_object = js_object->ToObject();
7087 if (js_object->IsFailure()) { 7087 if (js_object->IsFailure()) {
7088 if (!Failure::cast(js_object)->IsInternalError()) return js_object; 7088 if (!Failure::cast(js_object)->IsInternalError()) return js_object;
7089 HandleScope scope; 7089 HandleScope scope;
7090 Handle<Object> handle(object); 7090 Handle<Object> handle(object);
7091 Handle<Object> result = 7091 Handle<Object> result =
7092 Factory::NewTypeError("with_expression", HandleVector(&handle, 1)); 7092 Factory::NewTypeError("with_expression", HandleVector(&handle, 1));
7093 return ISOLATE_FROM_HEAP(heap)->Throw(*result); 7093 return heap->isolate()->Throw(*result);
7094 } 7094 }
7095 } 7095 }
7096 7096
7097 Object* result = 7097 Object* result =
7098 heap->AllocateWithContext(ISOLATE_FROM_HEAP(heap)->context(), 7098 heap->AllocateWithContext(heap->isolate()->context(),
7099 JSObject::cast(js_object), 7099 JSObject::cast(js_object),
7100 is_catch_context); 7100 is_catch_context);
7101 if (result->IsFailure()) return result; 7101 if (result->IsFailure()) return result;
7102 7102
7103 Context* context = Context::cast(result); 7103 Context* context = Context::cast(result);
7104 ISOLATE_FROM_HEAP(heap)->set_context(context); 7104 heap->isolate()->set_context(context);
7105 7105
7106 return result; 7106 return result;
7107 } 7107 }
7108 7108
7109 7109
7110 static Object* Runtime_PushContext(RUNTIME_CALLING_CONVENTION) { 7110 static Object* Runtime_PushContext(RUNTIME_CALLING_CONVENTION) {
7111 RUNTIME_GET_ISOLATE; 7111 RUNTIME_GET_ISOLATE;
7112 NoHandleAllocation ha; 7112 NoHandleAllocation ha;
7113 ASSERT(args.length() == 1); 7113 ASSERT(args.length() == 1);
7114 return PushContextHelper(isolate->heap(), args[0], false); 7114 return PushContextHelper(isolate->heap(), args[0], false);
(...skipping 1320 matching lines...) Expand 10 before | Expand all | Expand 10 after
8435 } 8435 }
8436 return value; 8436 return value;
8437 case CONSTANT_FUNCTION: 8437 case CONSTANT_FUNCTION:
8438 return result->GetConstantFunction(); 8438 return result->GetConstantFunction();
8439 case CALLBACKS: { 8439 case CALLBACKS: {
8440 Object* structure = result->GetCallbackObject(); 8440 Object* structure = result->GetCallbackObject();
8441 if (structure->IsProxy() || structure->IsAccessorInfo()) { 8441 if (structure->IsProxy() || structure->IsAccessorInfo()) {
8442 value = receiver->GetPropertyWithCallback( 8442 value = receiver->GetPropertyWithCallback(
8443 receiver, structure, name, result->holder()); 8443 receiver, structure, name, result->holder());
8444 if (value->IsException()) { 8444 if (value->IsException()) {
8445 value = ISOLATE_FROM_HEAP(heap)->pending_exception(); 8445 value = heap->isolate()->pending_exception();
8446 ISOLATE_FROM_HEAP(heap)->clear_pending_exception(); 8446 heap->isolate()->clear_pending_exception();
8447 if (caught_exception != NULL) { 8447 if (caught_exception != NULL) {
8448 *caught_exception = true; 8448 *caught_exception = true;
8449 } 8449 }
8450 } 8450 }
8451 return value; 8451 return value;
8452 } else { 8452 } else {
8453 return heap->undefined_value(); 8453 return heap->undefined_value();
8454 } 8454 }
8455 } 8455 }
8456 case INTERCEPTOR: 8456 case INTERCEPTOR:
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after
8962 static Handle<JSObject> MaterializeLocalScope(Heap* heap, 8962 static Handle<JSObject> MaterializeLocalScope(Heap* heap,
8963 JavaScriptFrame* frame) { 8963 JavaScriptFrame* frame) {
8964 Handle<JSFunction> function(JSFunction::cast(frame->function())); 8964 Handle<JSFunction> function(JSFunction::cast(frame->function()));
8965 Handle<SharedFunctionInfo> shared(function->shared()); 8965 Handle<SharedFunctionInfo> shared(function->shared());
8966 Handle<SerializedScopeInfo> serialized_scope_info(shared->scope_info()); 8966 Handle<SerializedScopeInfo> serialized_scope_info(shared->scope_info());
8967 ScopeInfo<> scope_info(*serialized_scope_info); 8967 ScopeInfo<> scope_info(*serialized_scope_info);
8968 8968
8969 // Allocate and initialize a JSObject with all the arguments, stack locals 8969 // Allocate and initialize a JSObject with all the arguments, stack locals
8970 // heap locals and extension properties of the debugged function. 8970 // heap locals and extension properties of the debugged function.
8971 Handle<JSObject> local_scope = 8971 Handle<JSObject> local_scope =
8972 Factory::NewJSObject(ISOLATE_FROM_HEAP(heap)->object_function()); 8972 Factory::NewJSObject(heap->isolate()->object_function());
8973 8973
8974 // First fill all parameters. 8974 // First fill all parameters.
8975 for (int i = 0; i < scope_info.number_of_parameters(); ++i) { 8975 for (int i = 0; i < scope_info.number_of_parameters(); ++i) {
8976 SetProperty(local_scope, 8976 SetProperty(local_scope,
8977 scope_info.parameter_name(i), 8977 scope_info.parameter_name(i),
8978 Handle<Object>(frame->GetParameter(i)), NONE); 8978 Handle<Object>(frame->GetParameter(i)), NONE);
8979 } 8979 }
8980 8980
8981 // Second fill all stack locals. 8981 // Second fill all stack locals.
8982 for (int i = 0; i < scope_info.number_of_stack_slots(); i++) { 8982 for (int i = 0; i < scope_info.number_of_stack_slots(); i++) {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
9016 Handle<Context> context) { 9016 Handle<Context> context) {
9017 ASSERT(context->is_function_context()); 9017 ASSERT(context->is_function_context());
9018 9018
9019 Handle<SharedFunctionInfo> shared(context->closure()->shared()); 9019 Handle<SharedFunctionInfo> shared(context->closure()->shared());
9020 Handle<SerializedScopeInfo> serialized_scope_info(shared->scope_info()); 9020 Handle<SerializedScopeInfo> serialized_scope_info(shared->scope_info());
9021 ScopeInfo<> scope_info(*serialized_scope_info); 9021 ScopeInfo<> scope_info(*serialized_scope_info);
9022 9022
9023 // Allocate and initialize a JSObject with all the content of theis function 9023 // Allocate and initialize a JSObject with all the content of theis function
9024 // closure. 9024 // closure.
9025 Handle<JSObject> closure_scope = 9025 Handle<JSObject> closure_scope =
9026 Factory::NewJSObject(ISOLATE_FROM_HEAP(heap)->object_function()); 9026 Factory::NewJSObject(heap->isolate()->object_function());
9027 9027
9028 // Check whether the arguments shadow object exists. 9028 // Check whether the arguments shadow object exists.
9029 int arguments_shadow_index = 9029 int arguments_shadow_index =
9030 shared->scope_info()->ContextSlotIndex( 9030 shared->scope_info()->ContextSlotIndex(
9031 heap->arguments_shadow_symbol(), NULL); 9031 heap->arguments_shadow_symbol(), NULL);
9032 if (arguments_shadow_index >= 0) { 9032 if (arguments_shadow_index >= 0) {
9033 // In this case all the arguments are available in the arguments shadow 9033 // In this case all the arguments are available in the arguments shadow
9034 // object. 9034 // object.
9035 Handle<JSObject> arguments_shadow( 9035 Handle<JSObject> arguments_shadow(
9036 JSObject::cast(context->get(arguments_shadow_index))); 9036 JSObject::cast(context->get(arguments_shadow_index)));
(...skipping 1870 matching lines...) Expand 10 before | Expand all | Expand 10 after
10907 #define SETUP_RUNTIME_ENTRIES(Name, argc, resize) \ 10907 #define SETUP_RUNTIME_ENTRIES(Name, argc, resize) \
10908 entries_[lut_index].method = &CodeGenerator::Generate##Name; \ 10908 entries_[lut_index].method = &CodeGenerator::Generate##Name; \
10909 entries_[lut_index].name = "_" #Name; \ 10909 entries_[lut_index].name = "_" #Name; \
10910 entries_[lut_index++].nargs = argc; 10910 entries_[lut_index++].nargs = argc;
10911 INLINE_RUNTIME_FUNCTION_LIST(SETUP_RUNTIME_ENTRIES); 10911 INLINE_RUNTIME_FUNCTION_LIST(SETUP_RUNTIME_ENTRIES);
10912 #undef SETUP_RUNTIME_ENTRIES 10912 #undef SETUP_RUNTIME_ENTRIES
10913 } 10913 }
10914 10914
10915 10915
10916 } } // namespace v8::internal 10916 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/isolate.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698